Bug 765907 - Don't save frame variables of dead generators in the debugger (r=billm)

This commit is contained in:
Luke Wagner 2012-06-20 08:57:29 -07:00
parent 0526922dc1
commit 44fc2c4d2b
2 changed files with 14 additions and 12 deletions

View File

@ -1,16 +1,24 @@
var g = newGlobal('new-compartment');
var dbg = new Debugger(g);
var hits = 0;
dbg.onDebuggerStatement = function(frame) {
++hits;
frame.older.eval("escaped = function() { return y }");
}
g.escaped = undefined;
g.eval("function h() { debugger }");
g.eval("(function () { var y = 42; h(); yield })().next();");
assertEq(g.eval("escaped()"), 42);
var arr = [];
const N = 10;
for (var i = 0; i < N; ++i) {
g.escaped = undefined;
g.eval("function h() { debugger }");
g.eval("(function () { var y = {p:42}; h(); yield })().next();");
assertEq(g.eval("escaped().p"), 42);
arr.push(g.escaped);
}
gc();
assertEq(g.eval("escaped()"), 42);
for (var i = 0; i < N; ++i)
arr[i]();

View File

@ -1522,16 +1522,10 @@ DebugScopes::sweep()
* As explained in onGeneratorFrameChange, liveScopes includes
* suspended generator frames. Since a generator can be finalized while
* its scope is live, we must explicitly detect finalized generators.
* Since the scope is still live, we simulate the onPop* call by
* copying unaliased variables into the scope object.
*/
if (JSGenerator *gen = fp->maybeSuspendedGenerator(rt)) {
JS_ASSERT(gen->state == JSGEN_NEWBORN || gen->state == JSGEN_OPEN);
if (!IsObjectMarked(&gen->obj)) {
if (scope->isCall())
scope->asCall().copyUnaliasedValues(fp);
else if (scope->isBlock())
scope->asClonedBlock().copyUnaliasedValues(fp);
e.removeFront();
continue;
}