Bug 1266434 - Make Debugger::findScripts delazify scipts in a separate phase now this can GC r=jimb a=abuillings
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 27 Apr 2016 10:44:40 +0100
changeset 295130 9892ac28ce0df4d20bb19c6cc882211e07ba355e
parent 295129 b6dd238180e9165c83e7def9186b65414ded0d28
child 295131 03b88e129a66b82605b0d450b6c221358d4cea1f
push id30220
push usercbook@mozilla.com
push dateThu, 28 Apr 2016 14:31:09 +0000
treeherdermozilla-central@4292da9df16b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb, abuillings
bugs1266434
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1266434 - Make Debugger::findScripts delazify scipts in a separate phase now this can GC r=jimb a=abuillings
js/src/jit-test/tests/debug/bug1266434.js
js/src/vm/Debugger.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1266434.js
@@ -0,0 +1,8 @@
+var g = newGlobal();
+var dbg = new Debugger(g);
+var g = newGlobal();
+g.evaluate("function f(x) { return x + 1; }");
+var gw = dbg.addDebuggee(g);
+gczeal(2, 1);
+var s = dbg.findScripts();
+gczeal(0);
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -3968,17 +3968,17 @@ class MOZ_STACK_CLASS Debugger::ScriptQu
         return matchAllDebuggeeGlobals();
     }
 
     /*
      * Search all relevant compartments and the stack for scripts matching
      * this query, and append the matching scripts to |vector|.
      */
     bool findScripts() {
-        if (!prepareQuery())
+        if (!prepareQuery() || !delazifyScripts())
             return false;
 
         JSCompartment* singletonComp = nullptr;
         if (compartments.count() == 1)
             singletonComp = compartments.all().front();
 
         /* Search each compartment for debuggee scripts. */
         MOZ_ASSERT(vector.empty());
@@ -4094,23 +4094,16 @@ class MOZ_STACK_CLASS Debugger::ScriptQu
      * Like above, but for wasm modules.
      */
     Rooted<WasmModuleObjectVector> wasmModuleVector;
 
     /* Indicates whether OOM has occurred while matching. */
     bool oom;
 
     bool addCompartment(JSCompartment* comp) {
-        {
-            // All scripts in the debuggee compartment must be visible, so
-            // delazify everything.
-            AutoCompartment ac(cx, comp);
-            if (!comp->ensureDelazifyScriptsForDebugger(cx))
-                return false;
-        }
         return compartments.put(comp);
     }
 
     /* Arrange for this ScriptQuery to match only scripts that run in |global|. */
     bool matchSingleGlobal(GlobalObject* global) {
         MOZ_ASSERT(compartments.count() == 0);
         if (!addCompartment(global->compartment())) {
             ReportOutOfMemory(cx);
@@ -4145,16 +4138,28 @@ class MOZ_STACK_CLASS Debugger::ScriptQu
         if (url.isString()) {
             if (!urlCString.encodeLatin1(cx, url.toString()))
                 return false;
         }
 
         return true;
     }
 
+    bool delazifyScripts() {
+        // All scripts in debuggee compartments must be visible, so delazify
+        // everything.
+        for (auto r = compartments.all(); !r.empty(); r.popFront()) {
+            JSCompartment* comp = r.front();
+            AutoCompartment ac(cx, comp);
+            if (!comp->ensureDelazifyScriptsForDebugger(cx))
+                return false;
+        }
+        return true;
+    }
+
     static void considerScript(JSRuntime* rt, void* data, JSScript* script) {
         ScriptQuery* self = static_cast<ScriptQuery*>(data);
         self->consider(script);
     }
 
     /*
      * If |script| matches this query, append it to |vector| or place it in
      * |innermostForCompartment|, as appropriate. Set |oom| if an out of memory