Bug 1206247 - Do not collect coverage information if the source has no filename. r=bhackett
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Thu, 01 Oct 2015 12:41:40 +0200
changeset 265606 ccb996c662e30f3698283e1a3b8392a59e15bfb2
parent 265605 e5e97faa6d1d684ca019a2990b1cd91cb0130d36
child 265607 0a5dacb5bf9f745a333ce008415658b92bb8f63e
push id15472
push usercbook@mozilla.com
push dateFri, 02 Oct 2015 11:51:34 +0000
treeherderfx-team@2c33ef6b27e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1206247
milestone44.0a1
Bug 1206247 - Do not collect coverage information if the source has no filename. r=bhackett
js/src/jit-test/tests/coverage/bug1206247.js
js/src/jsopcode.cpp
js/src/vm/CodeCoverage.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/bug1206247.js
@@ -0,0 +1,4 @@
+evaluate("", {
+    fileName: null
+});
+getLcovInfo();
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -1950,18 +1950,22 @@ GenerateLcovInfo(JSContext* cx, JSCompar
 {
     JSRuntime* rt = cx->runtime();
 
     // Collect the list of scripts which are part of the current compartment.
     Rooted<ScriptVector> topScripts(cx, ScriptVector(cx));
     for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
         for (ZoneCellIter i(zone, AllocKind::SCRIPT); !i.done(); i.next()) {
             JSScript* script = i.get<JSScript>();
-            if (script->compartment() != comp || !script->isTopLevel())
+            if (script->compartment() != comp ||
+                !script->isTopLevel() ||
+                !script->filename())
+            {
                 continue;
+            }
 
             if (!topScripts.append(script))
                 return false;
         }
     }
 
     if (topScripts.length() == 0)
         return true;
--- a/js/src/vm/CodeCoverage.cpp
+++ b/js/src/vm/CodeCoverage.cpp
@@ -321,16 +321,20 @@ LCovCompartment::collectCodeCoverageInfo
         outTN_.reportOutOfMemory();
         return;
     }
 }
 
 void
 LCovCompartment::collectSourceFile(JSCompartment* comp, ScriptSourceObject* sso)
 {
+    // Do not add sources if there is no file name associated to it.
+    if (!sso->source()->filename())
+        return;
+
     // Skip any operation if we already some out-of memory issues.
     if (outTN_.hadOutOfMemory())
         return;
 
     // On the first call, write the compartment name, and allocate a LCovSource
     // vector in the LifoAlloc.
     if (!sources_) {
         if (!writeCompartmentName(comp))