mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 775801 - LambdaIsGetElem should optimize based on JSOP_GETALIASEDVAR, not JSOP_NAME (r=dvander)
--HG-- extra : rebase_source : 5995e62a63b47aa4abf88d8f16a2226bd9a991f1
This commit is contained in:
parent
dcb864530f
commit
c6ad094b0d
@ -2213,26 +2213,19 @@ LambdaIsGetElem(JSObject &lambda, JSContext *cx)
|
||||
JSScript *script = fun->script();
|
||||
jsbytecode *pc = script->code;
|
||||
|
||||
/* Look for an access to 'b' in the enclosing scope. */
|
||||
if (JSOp(*pc) != JSOP_NAME)
|
||||
return NULL;
|
||||
PropertyName *bname;
|
||||
GET_NAME_FROM_BYTECODE(script, pc, 0, bname);
|
||||
pc += JSOP_NAME_LENGTH;
|
||||
|
||||
/*
|
||||
* Do a conservative search for 'b' in the enclosing scope. Avoid using a
|
||||
* real name lookup since this can trigger observable effects.
|
||||
* JSOP_GETALIASEDVAR tells us exactly where to find the base object 'b'.
|
||||
* Rule out the (unlikely) possibility of a heavyweight function since it
|
||||
* would make our scope walk off by 1.
|
||||
*/
|
||||
Value b;
|
||||
RootedObject scope(cx, cx->stack.currentScriptedScopeChain());
|
||||
while (true) {
|
||||
if (!scope->isCall() && !scope->isBlock())
|
||||
return NULL;
|
||||
if (HasDataProperty(cx, scope, bname, &b))
|
||||
break;
|
||||
scope = &scope->asScope().enclosingScope();
|
||||
}
|
||||
if (JSOp(*pc) != JSOP_GETALIASEDVAR || fun->isHeavyweight())
|
||||
return NULL;
|
||||
ScopeCoordinate sc(pc);
|
||||
ScopeObject *scope = &cx->stack.currentScriptedScopeChain()->asScope();
|
||||
for (unsigned i = 0; i < sc.hops; ++i)
|
||||
scope = &scope->enclosingScope().asScope();
|
||||
Value b = scope->aliasedVar(sc);
|
||||
pc += JSOP_GETALIASEDVAR_LENGTH;
|
||||
|
||||
/* Look for 'a' to be the lambda's first argument. */
|
||||
if (JSOp(*pc) != JSOP_GETARG || GET_SLOTNO(pc) != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user