Bug 889599, part 2 - Remove unnecessary FunctionBox out-parameter from Parser::standaloneFunctionBody. r=Waldo.

This commit is contained in:
Jason Orendorff 2013-07-12 12:20:58 -05:00
parent 22ea8dbac9
commit a68f8013b5
3 changed files with 15 additions and 19 deletions

View File

@ -472,11 +472,9 @@ frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileO
parser.tokenStream.tell(&start);
bool strict = options.strictOption;
bool becameStrict;
FunctionBox *funbox;
ParseNode *pn;
while (true) {
pn = parser.standaloneFunctionBody(fun, formals, script, fn, &funbox,
strict, &becameStrict);
pn = parser.standaloneFunctionBody(fun, formals, script, fn, strict, &becameStrict);
if (pn)
break;
@ -498,12 +496,10 @@ frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileO
if (!NameFunctions(cx, pn))
return false;
if (fn->pn_body) {
JS_ASSERT(fn->pn_body == argsbody);
JS_ASSERT(fn->pn_body->isKind(PNK_ARGSBODY));
fn->pn_body->append(pn);
fn->pn_body->pn_pos = pn->pn_pos;
pn = fn->pn_body;
}
bool generateBytecode = true;
#ifdef JS_ION
@ -516,7 +512,7 @@ frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileO
return false;
if (moduleFun) {
funbox->object = moduleFun;
fn->pn_funbox->object = moduleFun;
fun.set(moduleFun); // replace the existing function with the LinkAsmJS native
generateBytecode = false;
}
@ -531,14 +527,14 @@ frontend::CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, CompileO
* 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,
BytecodeEmitter funbce(/* parent = */ NULL, &parser, fn->pn_funbox, script,
/* insideEval = */ false, /* evalCaller = */ NullPtr(),
fun->environment() && fun->environment()->is<GlobalObject>(),
options.lineno);
if (!funbce.init())
return false;
if (!EmitFunctionScript(cx, &funbce, pn))
if (!EmitFunctionScript(cx, &funbce, fn->pn_body))
return false;
}

View File

@ -836,18 +836,18 @@ Parser<ParseHandler>::checkStrictBinding(HandlePropertyName name, Node pn)
template <>
ParseNode *
Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun, const AutoNameVector &formals,
HandleScript script, Node fn, FunctionBox **funbox,
HandleScript script, Node fn,
bool strict, bool *becameStrict)
{
if (becameStrict)
*becameStrict = false;
*funbox = newFunctionBox(fun, /* outerpc = */ NULL, strict);
FunctionBox *funbox = newFunctionBox(fun, /* outerpc = */ NULL, strict);
if (!funbox)
return null();
handler.setFunctionBox(fn, *funbox);
handler.setFunctionBox(fn, funbox);
ParseContext<FullParseHandler> funpc(this, pc, *funbox, /* staticLevel = */ 0, /* bodyid = */ 0);
ParseContext<FullParseHandler> funpc(this, pc, funbox, /* staticLevel = */ 0, /* bodyid = */ 0);
if (!funpc.init())
return null();
@ -878,7 +878,7 @@ Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun, const AutoN
// Also populate the internal bindings of the function box, so that
// heavyweight tests while emitting bytecode work.
InternalHandle<Bindings*> funboxBindings =
InternalHandle<Bindings*>::fromMarkedLocation(&(*funbox)->bindings);
InternalHandle<Bindings*>::fromMarkedLocation(&funbox->bindings);
if (!funpc.generateFunctionBindings(context, alloc, funboxBindings))
return null();

View File

@ -402,8 +402,8 @@ class Parser : private AutoGCRooter, public StrictModeGetter
bool maybeParseDirective(Node pn, bool *cont);
// Parse a function, given only its body. Used for the Function constructor.
Node standaloneFunctionBody(HandleFunction fun, const AutoNameVector &formals, HandleScript script,
Node fn, FunctionBox **funbox, bool strict,
Node standaloneFunctionBody(HandleFunction fun, const AutoNameVector &formals,
HandleScript script, Node fn, bool strict,
bool *becameStrict = NULL);
// Parse a function, given only its arguments and body. Used for lazily