Bug 901178 - IonMonkey: Avoid parsing unused lambda functions. r=bhackett

This commit is contained in:
Nicolas B. Pierron 2013-08-05 18:09:19 -07:00
parent 1ad4e6db16
commit 2b33645d2e
3 changed files with 16 additions and 5 deletions

View File

@ -739,9 +739,22 @@ CodeGenerator::emitLambdaInit(const Register &output, const Register &scopeChain
JS_STATIC_ASSERT(offsetof(JSFunction, flags) == offsetof(JSFunction, nargs) + 2);
masm.store32(Imm32(u.word), Address(output, offsetof(JSFunction, nargs)));
masm.storePtr(ImmGCPtr(fun->nonLazyScript()),
Address(output, JSFunction::offsetOfNativeOrScript()));
// Initialize the JSFunction union with the script / native / lazyScript
// corresponding to the flag.
ImmGCPtr scriptOrLazyScript(NULL);
if (fun->isInterpretedLazy())
scriptOrLazyScript = ImmGCPtr(fun->lazyScriptOrNull());
else
scriptOrLazyScript = ImmGCPtr(fun->nonLazyScript());
masm.storePtr(scriptOrLazyScript, Address(output, JSFunction::offsetOfNativeOrScript()));
// Lambda scripted functions are given the scope chain as the environment in
// which the caller was at the time of the creation of the lambda.
masm.storePtr(scopeChain, Address(output, JSFunction::offsetOfEnvironment()));
// Copy the name of the function used for diagnostics.
masm.storePtr(ImmGCPtr(fun->displayAtom()), Address(output, JSFunction::offsetOfAtom()));
}

View File

@ -8248,9 +8248,6 @@ IonBuilder::jsop_object(JSObject *obj)
bool
IonBuilder::jsop_lambda(JSFunction *fun)
{
if (fun->isInterpreted() && !fun->getOrCreateScript(cx))
return false;
JS_ASSERT(script()->analysis()->usesScopeChain());
if (fun->isArrow())
return abort("bound arrow function");

View File

@ -322,6 +322,7 @@ class JSFunction : public JSObject
}
static unsigned offsetOfNativeOrScript() {
JS_STATIC_ASSERT(offsetof(U, n.native) == offsetof(U, i.s.lazy_));
JS_STATIC_ASSERT(offsetof(U, n.native) == offsetof(U, i.s.script_));
JS_STATIC_ASSERT(offsetof(U, n.native) == offsetof(U, nativeOrScript));
return offsetof(JSFunction, u.nativeOrScript);