Bug 770092 (part 4) - Move JSFunction initialization code out of JSScript::fullyInitFromEmitter().

--HG--
extra : rebase_source : ef54cd18e6bc28947ac49d4a11e6590ee697ffd6
This commit is contained in:
Nicholas Nethercote 2012-07-05 19:35:43 -07:00
parent d6cc43a799
commit 65965e2124
3 changed files with 19 additions and 23 deletions

View File

@ -2569,6 +2569,23 @@ frontend::EmitFunctionScript(JSContext *cx, BytecodeEmitter *bce, ParseNode *bod
if (!bce->script->fullyInitFromEmitter(cx, bce))
return false;
// Initialize fun->script() so that the debugger has a valid fun->script().
RootedFunction fun(cx, bce->script->function());
JS_ASSERT(fun->isInterpreted());
if (bce->sc->funIsHeavyweight())
fun->flags |= JSFUN_HEAVYWEIGHT;
/* Mark functions which will only be executed once as singletons. */
bool singleton =
cx->typeInferenceEnabled() &&
bce->parent &&
bce->parent->checkSingletonContext();
JS_ASSERT(!fun->script());
fun->setScript(bce->script);
if (!fun->setTypeForScriptedFunction(cx, singleton))
return false;
bce->tellDebuggerAboutCompiledScript(cx);
return true;

View File

@ -126,7 +126,7 @@ class ContextFlags {
};
struct SharedContext {
JSContext *context;
JSContext *const context;
private:
const RootedFunction fun_; /* function to store argument and variable

View File

@ -1340,29 +1340,8 @@ JSScript::fullyInitFromEmitter(JSContext *cx, BytecodeEmitter *bce)
RootedFunction fun(cx, NULL);
if (bce->sc->inFunction()) {
JS_ASSERT(!bce->script->noScriptRval);
script->isGenerator = bce->sc->funIsGenerator();
/*
* We initialize fun->script() to be the script constructed above
* so that the debugger has a valid fun->script().
*/
fun = bce->sc->fun();
JS_ASSERT(fun->isInterpreted());
JS_ASSERT(!fun->script());
if (bce->sc->funIsHeavyweight())
fun->flags |= JSFUN_HEAVYWEIGHT;
/* Mark functions which will only be executed once as singletons. */
bool singleton =
cx->typeInferenceEnabled() &&
bce->parent &&
bce->parent->checkSingletonContext();
fun->setScript(script);
script->setFunction(fun);
if (!fun->setTypeForScriptedFunction(cx, singleton))
return false;
script->setFunction(bce->sc->fun());
}
/*