Bug 758509 (part 1) - Create JSScript before starting bytecode generation. r=luke.

This commit is contained in:
Nicholas Nethercote
2012-05-30 23:27:51 -07:00
parent 7ac4047b88
commit 1e4a4af92b
8 changed files with 166 additions and 100 deletions

View File

@@ -112,7 +112,12 @@ frontend::CompileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF
if (!tc.init())
return NULL;
BytecodeEmitter bce(&parser, &sc, lineno, noScriptRval, needScriptGlobal);
Rooted<JSScript*> script(cx);
script = JSScript::Create(cx);
if (!script)
return NULL;
BytecodeEmitter bce(&parser, &sc, script, lineno, noScriptRval, needScriptGlobal);
if (!bce.init())
return NULL;
@@ -240,9 +245,7 @@ frontend::CompileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF
JS_ASSERT(bce.version() == version);
Rooted<JSScript*> script(cx);
script = JSScript::NewScriptFromEmitter(cx, &bce);
if (!script)
if (!script->fullyInitFromEmitter(cx, &bce))
return NULL;
JS_ASSERT(script->savedCallerFun == savedCallerFun);
@@ -276,7 +279,12 @@ frontend::CompileFunctionBody(JSContext *cx, JSFunction *fun,
if (!funtc.init())
return false;
BytecodeEmitter funbce(&parser, &funsc, lineno,
Rooted<JSScript*> script(cx);
script = JSScript::Create(cx);
if (!script)
return false;
BytecodeEmitter funbce(&parser, &funsc, script, lineno,
/* noScriptRval = */ false, /* needsScriptGlobal = */ false);
if (!funbce.init())
return false;