Bug 1071646 - Support JSOP_BINDVAR in Baseline. (r=jandem)

This commit is contained in:
Shu-yu Guo 2015-12-18 13:18:20 -08:00 committed by Cameron Kaiser
parent feba46e3f4
commit 92b6a3b480
4 changed files with 36 additions and 13 deletions

View File

@ -2270,6 +2270,26 @@ BaselineCompiler::emit_JSOP_BINDGNAME()
return emit_JSOP_BINDNAME(); return emit_JSOP_BINDNAME();
} }
typedef JSObject* (*BindVarFn)(JSContext*, HandleObject);
static const VMFunction BindVarInfo = FunctionInfo<BindVarFn>(jit::BindVar);
bool
BaselineCompiler::emit_JSOP_BINDVAR()
{
frame.syncStack(0);
masm.loadPtr(frame.addressOfScopeChain(), R0.scratchReg());
prepareVMCall();
pushArg(R0.scratchReg());
if (!callVM(BindVarInfo))
return false;
masm.tagValue(JSVAL_TYPE_OBJECT, ReturnReg, R0);
frame.push(R0);
return true;
}
bool bool
BaselineCompiler::emit_JSOP_SETPROP() BaselineCompiler::emit_JSOP_SETPROP()
{ {

View File

@ -143,6 +143,7 @@ namespace jit {
_(JSOP_DELNAME) \ _(JSOP_DELNAME) \
_(JSOP_GETIMPORT) \ _(JSOP_GETIMPORT) \
_(JSOP_GETINTRINSIC) \ _(JSOP_GETINTRINSIC) \
_(JSOP_BINDVAR) \
_(JSOP_DEFVAR) \ _(JSOP_DEFVAR) \
_(JSOP_DEFCONST) \ _(JSOP_DEFCONST) \
_(JSOP_DEFLET) \ _(JSOP_DEFLET) \

View File

@ -167,14 +167,20 @@ CheckOverRecursedWithExtra(JSContext* cx, BaselineFrame* frame,
return cx->runtime()->handleInterrupt(cx); return cx->runtime()->handleInterrupt(cx);
} }
JSObject*
BindVar(JSContext* cx, HandleObject scopeChain)
{
JSObject* obj = scopeChain;
while (!obj->isQualifiedVarObj())
obj = obj->enclosingScope();
return obj;
}
bool bool
DefVar(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject scopeChain) DefVar(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject scopeChain)
{ {
// Given the ScopeChain, extract the VarObj. // Given the ScopeChain, extract the VarObj.
RootedObject obj(cx, scopeChain); RootedObject obj(cx, BindVar(cx, scopeChain));
while (!obj->isQualifiedVarObj())
obj = obj->enclosingScope();
return DefVarOperation(cx, obj, dn, attrs); return DefVarOperation(cx, obj, dn, attrs);
} }
@ -185,10 +191,7 @@ DefLexical(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject sc
Rooted<ClonedBlockObject*> lexical(cx, &NearestEnclosingExtensibleLexicalScope(scopeChain)); Rooted<ClonedBlockObject*> lexical(cx, &NearestEnclosingExtensibleLexicalScope(scopeChain));
// Find the variables object. // Find the variables object.
RootedObject varObj(cx, scopeChain); RootedObject varObj(cx, BindVar(cx, scopeChain));
while (!varObj->isQualifiedVarObj())
varObj = varObj->enclosingScope();
return DefLexicalOperation(cx, lexical, varObj, dn, attrs); return DefLexicalOperation(cx, lexical, varObj, dn, attrs);
} }
@ -853,9 +856,8 @@ bool
InitGlobalOrEvalScopeObjects(JSContext* cx, BaselineFrame* frame) InitGlobalOrEvalScopeObjects(JSContext* cx, BaselineFrame* frame)
{ {
RootedScript script(cx, frame->script()); RootedScript script(cx, frame->script());
RootedObject varObj(cx, frame->scopeChain()); RootedObject scopeChain(cx, frame->scopeChain());
while (!varObj->isQualifiedVarObj()) RootedObject varObj(cx, BindVar(cx, scopeChain));
varObj = varObj->enclosingScope();
if (script->isForEval()) { if (script->isForEval()) {
// Strict eval needs its own call object. // Strict eval needs its own call object.
@ -866,13 +868,12 @@ InitGlobalOrEvalScopeObjects(JSContext* cx, BaselineFrame* frame)
if (!frame->initStrictEvalScopeObjects(cx)) if (!frame->initStrictEvalScopeObjects(cx))
return false; return false;
} else { } else {
RootedObject scopeChain(cx, frame->scopeChain());
if (!CheckEvalDeclarationConflicts(cx, script, scopeChain, varObj)) if (!CheckEvalDeclarationConflicts(cx, script, scopeChain, varObj))
return false; return false;
} }
} else { } else {
Rooted<ClonedBlockObject*> lexicalScope(cx, Rooted<ClonedBlockObject*> lexicalScope(cx,
&NearestEnclosingExtensibleLexicalScope(frame->scopeChain())); &NearestEnclosingExtensibleLexicalScope(scopeChain));
if (!CheckGlobalDeclarationConflicts(cx, script, lexicalScope, varObj)) if (!CheckGlobalDeclarationConflicts(cx, script, lexicalScope, varObj))
return false; return false;
} }

View File

@ -588,6 +588,7 @@ bool CheckOverRecursed(JSContext* cx);
bool CheckOverRecursedWithExtra(JSContext* cx, BaselineFrame* frame, bool CheckOverRecursedWithExtra(JSContext* cx, BaselineFrame* frame,
uint32_t extra, uint32_t earlyCheck); uint32_t extra, uint32_t earlyCheck);
JSObject* BindVar(JSContext* cx, HandleObject scopeChain);
bool DefVar(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject scopeChain); bool DefVar(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject scopeChain);
bool DefLexical(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject scopeChain); bool DefLexical(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject scopeChain);
bool DefGlobalLexical(JSContext* cx, HandlePropertyName dn, unsigned attrs); bool DefGlobalLexical(JSContext* cx, HandlePropertyName dn, unsigned attrs);