Bug 1389974 - Do not require ffi_call to exist, r=jonco
authorSteve Fink <sfink@mozilla.com>
Thu, 31 Aug 2017 11:53:53 -0700
changeset 662421 3c6ea99a33d94afaf7323696f39f73433ca1af04
parent 662420 f5a6df8b2f68c15ff0a00094b31cdd26cf19345b
child 662422 2b18295208be6a616d959f4f00e944f279dcca3f
push id79074
push userbmo:mstriemer@mozilla.com
push dateMon, 11 Sep 2017 17:17:14 +0000
reviewersjonco
bugs1389974
milestone57.0a1
Bug 1389974 - Do not require ffi_call to exist, r=jonco
js/src/devtools/rootAnalysis/annotations.js
js/src/devtools/rootAnalysis/loadCallgraph.js
--- a/js/src/devtools/rootAnalysis/annotations.js
+++ b/js/src/devtools/rootAnalysis/annotations.js
@@ -234,17 +234,17 @@ var ignoreFunctions = {
     "calloc" : true,
 
     "uint8 nsContentUtils::IsExpandedPrincipal(nsIPrincipal*)" : true,
 
     "void mozilla::AutoProfilerLabel::~AutoProfilerLabel(int32)" : true,
 };
 
 function extraGCFunctions() {
-    return ["ffi_call"];
+    return ["ffi_call"].filter(f => f in readableNames);
 }
 
 function isProtobuf(name)
 {
     return name.match(/\bgoogle::protobuf\b/) ||
            name.match(/\bmozilla::devtools::protobuf\b/);
 }
 
@@ -256,17 +256,17 @@ function isHeapSnapshotMockClass(name)
 
 function isGTest(name)
 {
     return name.match(/\btesting::/);
 }
 
 function ignoreGCFunction(mangled)
 {
-    assert(mangled in readableNames);
+    assert(mangled in readableNames, mangled + " not in readableNames");
     var fun = readableNames[mangled][0];
 
     if (fun in ignoreFunctions)
         return true;
 
     // The protobuf library, and [de]serialization code generated by the
     // protobuf compiler, uses a _ton_ of function pointers but they are all
     // internal. Easiest to just ignore that mess here.
--- a/js/src/devtools/rootAnalysis/loadCallgraph.js
+++ b/js/src/devtools/rootAnalysis/loadCallgraph.js
@@ -122,19 +122,21 @@ function loadCallgraph(file)
             if (tag == 'GC Call') {
                 addGCFunction(mangled, "GC");
                 numGCCalls++;
             }
         }
     }
 
     // Add in any extra functions at the end. (If we did this early, it would
-    // mess up the id <-> name correspondence.)
-    for (var func of extraGCFunctions())
+    // mess up the id <-> name correspondence. Also, we need to know if the
+    // functions even exist in the first place.)
+    for (var func of extraGCFunctions()) {
         addGCFunction(func, "annotation");
+    }
 
     // Initialize suppressedFunctions to the set of all functions, and the
     // worklist to all toplevel callers.
     var worklist = [];
     for (var callee in callerGraph)
         suppressedFunctions[callee] = true;
     for (var caller in calleeGraph) {
         if (!(caller in callerGraph)) {