mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Need to prevent GC activation during compile on the compiling context, not
just when evaluating old-style switch case expressions.
This commit is contained in:
parent
bf3beb5a03
commit
fa72057162
@ -756,18 +756,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
script = js_NewScriptFromCG(cx, &cg2, NULL);
|
||||
if (!script)
|
||||
return JS_FALSE;
|
||||
|
||||
/*
|
||||
* XXX The GC must not run during this case expr eval, so
|
||||
* kludge cx->gcDisabled to keep it at bay. The current GC
|
||||
* rules say that the GC can run only when no requests are
|
||||
* active, or when the only active request explicitly calls
|
||||
* JS_GC or JS_MaybeGC from its branch callback.
|
||||
*/
|
||||
cx->gcDisabled++;
|
||||
ok = js_Execute(cx, cx->fp->scopeChain, script, NULL,
|
||||
cx->fp, JS_FALSE, &pn3->pn_val);
|
||||
cx->gcDisabled--;
|
||||
js_DestroyScript(cx, script);
|
||||
if (!ok)
|
||||
return JS_FALSE;
|
||||
|
@ -204,6 +204,14 @@ js_CompileTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts,
|
||||
stop = TOK_EOF;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent GC activation on this context (possible if out of memory when
|
||||
* atomizing, or from pre-ECMAv2 switch case expr eval in the unlikely
|
||||
* case of a branch-callback -- unlikely because it means the switch case
|
||||
* must have called a function).
|
||||
*/
|
||||
cx->gcDisabled++;
|
||||
|
||||
ok = JS_TRUE;
|
||||
do {
|
||||
ts->flags |= TSF_REGEXP;
|
||||
@ -245,6 +253,7 @@ js_CompileTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts,
|
||||
} while (ok);
|
||||
|
||||
out:
|
||||
cx->gcDisabled--;
|
||||
cx->fp = fp;
|
||||
if (!ok)
|
||||
CLEAR_PUSHBACK(ts);
|
||||
@ -353,6 +362,9 @@ js_CompileFunctionBody(JSContext *cx, JSTokenStream *ts, JSFunction *fun)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
/* Prevent GC activation on this context during compilation. */
|
||||
cx->gcDisabled++;
|
||||
|
||||
/* Satisfy the assertion at the top of Statements. */
|
||||
ts->token.type = TOK_LC;
|
||||
pn = FunctionBody(cx, ts, fun, &funcg.treeContext);
|
||||
@ -364,6 +376,8 @@ js_CompileFunctionBody(JSContext *cx, JSTokenStream *ts, JSFunction *fun)
|
||||
if (ok)
|
||||
ok = js_EmitFunctionBody(cx, &funcg, pn, fun);
|
||||
}
|
||||
|
||||
cx->gcDisabled--;
|
||||
js_ResetCodeGenerator(cx, &funcg);
|
||||
return ok;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user