Bug 646597 - Make functions made by the Function constructor compile-and-go. Most of patch was originally written by jorendorff. (r=luke)

This commit is contained in:
Shu-yu Guo
2013-05-04 20:53:21 -07:00
parent f874604be0
commit 3a5c1adefa
11 changed files with 42 additions and 21 deletions

View File

@@ -330,7 +330,6 @@ frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileO
return false;
}
options.setCompileAndGo(false);
Parser<FullParseHandler> parser(cx, options, chars, length, /* foldConstants = */ true);
if (!parser.init())
return false;
@@ -413,9 +412,17 @@ frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileO
#endif
if (generateBytecode) {
/*
* The reason for checking fun->environment() below is that certain
* consumers of JS::CompileFunction, namely
* nsEventListenerManager::CompileEventHandlerInternal, passes in a
* NULL environment. This compiled function is never used, but instead
* is cloned immediately onto the right scope chain.
*/
BytecodeEmitter funbce(/* parent = */ NULL, &parser, funbox, script,
/* evalCaller = */ NullPtr(),
/* hasGlobalScope = */ false, options.lineno);
fun->environment() && fun->environment()->isGlobal(),
options.lineno);
if (!funbce.init())
return false;