Bug 880538 - set pn->pn_funbox immediately (r=bhackett)

--HG--
extra : rebase_source : 11b265e64f8355989632bd2556ed119a397cb10a
This commit is contained in:
Luke Wagner 2013-06-21 16:07:25 -07:00
Родитель 186ba1036c
Коммит 601b5bb5fc
5 изменённых файлов: 14 добавлений и 16 удалений

Просмотреть файл

@ -269,7 +269,7 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain,
*/
JSFunction *fun = evalCaller->functionOrCallerFunction();
Directives directives(/* strict = */ fun->strict());
ObjectBox *funbox = parser.newFunctionBox(fun, pc.addr(), directives);
ObjectBox *funbox = parser.newFunctionBox(/* fn = */ NULL, fun, pc.addr(), directives);
if (!funbox)
return NULL;
bce.objectList.add(funbox);

Просмотреть файл

@ -329,6 +329,7 @@ class FullParseHandler
pn->pn_body = kid;
}
void setFunctionBox(ParseNode *pn, FunctionBox *funbox) {
JS_ASSERT(pn->isKind(PNK_FUNCTION));
pn->pn_funbox = funbox;
}
void addFunctionArgument(ParseNode *pn, ParseNode *argpn) {

Просмотреть файл

@ -384,7 +384,7 @@ Parser<FullParseHandler>::cloneParseTree(ParseNode *opn)
MOZ_ASSUME_UNREACHABLE("module nodes cannot be cloned");
}
NULLCHECK(pn->pn_funbox =
newFunctionBox(opn->pn_funbox->function(), pc,
newFunctionBox(pn, opn->pn_funbox->function(), pc,
Directives(/* strict = */ opn->pn_funbox->strict)));
NULLCHECK(pn->pn_body = cloneParseTree(opn->pn_body));
pn->pn_cookie = opn->pn_cookie;

Просмотреть файл

@ -517,7 +517,7 @@ FunctionBox::FunctionBox(ExclusiveContext *cx, ObjectBox* traceListHead, JSFunct
template <typename ParseHandler>
FunctionBox *
Parser<ParseHandler>::newFunctionBox(JSFunction *fun, ParseContext<ParseHandler> *outerpc,
Parser<ParseHandler>::newFunctionBox(Node fn, JSFunction *fun, ParseContext<ParseHandler> *outerpc,
Directives inheritedDirectives)
{
JS_ASSERT(fun && !IsPoisonedPtr(fun));
@ -538,6 +538,8 @@ Parser<ParseHandler>::newFunctionBox(JSFunction *fun, ParseContext<ParseHandler>
}
traceListHead = funbox;
if (fn)
handler.setFunctionBox(fn, funbox);
return funbox;
}
@ -860,7 +862,7 @@ Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun, const AutoN
argsbody->makeEmpty();
fn->pn_body = argsbody;
FunctionBox *funbox = newFunctionBox(fun, /* outerpc = */ NULL, inheritedDirectives);
FunctionBox *funbox = newFunctionBox(fn, fun, /* outerpc = */ NULL, inheritedDirectives);
if (!funbox)
return null();
handler.setFunctionBox(fn, funbox);
@ -1797,10 +1799,9 @@ Parser<FullParseHandler>::checkFunctionDefinition(HandlePropertyName funName,
// so we can skip over them after accounting for their free variables.
if (LazyScript *lazyOuter = handler.lazyOuterFunction()) {
JSFunction *fun = handler.nextLazyInnerFunction();
FunctionBox *funbox = newFunctionBox(fun, pc, Directives(/* strict = */ false));
FunctionBox *funbox = newFunctionBox(pn, fun, pc, Directives(/* strict = */ false));
if (!funbox)
return false;
handler.setFunctionBox(pn, funbox);
if (!addFreeVariablesFromLazyFunction(fun, pc))
return false;
@ -2002,7 +2003,7 @@ Parser<FullParseHandler>::finishFunctionDefinition(ParseNode *pn, FunctionBox *f
}
#endif
pn->pn_funbox = funbox;
JS_ASSERT(pn->pn_funbox == funbox);
pn->pn_body->append(body);
pn->pn_body->pn_pos = body->pn_pos;
@ -2061,7 +2062,7 @@ Parser<FullParseHandler>::functionArgsAndBody(ParseNode *pn, HandleFunction fun,
ParseContext<FullParseHandler> *outerpc = pc;
// Create box for fun->object early to protect against last-ditch GC.
FunctionBox *funbox = newFunctionBox(fun, pc, inheritedDirectives);
FunctionBox *funbox = newFunctionBox(pn, fun, pc, inheritedDirectives);
if (!funbox)
return false;
@ -2100,8 +2101,6 @@ Parser<FullParseHandler>::functionArgsAndBody(ParseNode *pn, HandleFunction fun,
tokenStream.seek(position, parser->tokenStream);
}
pn->pn_funbox = funbox;
if (!addFreeVariablesFromLazyFunction(fun, pc))
return false;
@ -2144,7 +2143,7 @@ Parser<SyntaxParseHandler>::functionArgsAndBody(Node pn, HandleFunction fun,
ParseContext<SyntaxParseHandler> *outerpc = pc;
// Create box for fun->object early to protect against last-ditch GC.
FunctionBox *funbox = newFunctionBox(fun, pc, inheritedDirectives);
FunctionBox *funbox = newFunctionBox(pn, fun, pc, inheritedDirectives);
if (!funbox)
return false;
@ -2177,10 +2176,9 @@ Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, unsigned st
return null();
Directives directives(/* strict = */ strict);
FunctionBox *funbox = newFunctionBox(fun, /* outerpc = */ NULL, directives);
FunctionBox *funbox = newFunctionBox(pn, fun, /* outerpc = */ NULL, directives);
if (!funbox)
return null();
handler.setFunctionBox(pn, funbox);
Directives newDirectives = directives;
ParseContext<FullParseHandler> funpc(this, /* parent = */ NULL, funbox,
@ -5988,7 +5986,7 @@ Parser<FullParseHandler>::generatorExpr(ParseNode *kid)
/* Create box for fun->object early to protect against last-ditch GC. */
Directives directives(/* strict = */ outerpc->sc->strict);
FunctionBox *genFunbox = newFunctionBox(fun, outerpc, directives);
FunctionBox *genFunbox = newFunctionBox(genfn, fun, outerpc, directives);
if (!genFunbox)
return null();
@ -6009,7 +6007,6 @@ Parser<FullParseHandler>::generatorExpr(ParseNode *kid)
genFunbox->setIsGenerator();
genFunbox->inGenexpLambda = true;
genfn->pn_funbox = genFunbox;
genfn->pn_blockid = genpc.bodyid;
ParseNode *body = comprehensionTail(pn, outerpc->blockid(), true, outerpc);

Просмотреть файл

@ -379,7 +379,7 @@ class Parser : private AutoGCRooter, public StrictModeGetter
*/
ObjectBox *newObjectBox(JSObject *obj);
ModuleBox *newModuleBox(Module *module, ParseContext<ParseHandler> *pc);
FunctionBox *newFunctionBox(JSFunction *fun, ParseContext<ParseHandler> *pc,
FunctionBox *newFunctionBox(Node fn, JSFunction *fun, ParseContext<ParseHandler> *pc,
Directives directives);
/*