Bug 1266434 - Make Debugger::findScripts delazify scipts in a separate phase now this can GC r=jimb a=abuillings

This commit is contained in:
Jon Coppeard 2016-04-27 10:44:40 +01:00
parent e1c63550ed
commit 4f9ed10d72
2 changed files with 21 additions and 8 deletions

View File

@ -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);

View File

@ -3973,7 +3973,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery
* this query, and append the matching scripts to |vector|.
*/
bool findScripts() {
if (!prepareQuery())
if (!prepareQuery() || !delazifyScripts())
return false;
JSCompartment* singletonComp = nullptr;
@ -4099,13 +4099,6 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery
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);
}
@ -4150,6 +4143,18 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery
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);