Bug 1511891 part 5 - Refactor DefLexicalOperation to make it easier to call directly from JIT code in the next patch. r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D13703

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2019-01-11 09:13:31 +00:00
Родитель c95d95c2e8
Коммит b9ee882ac8
2 изменённых файлов: 17 добавлений и 20 удалений

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

@ -3627,16 +3627,8 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_CALLER bool Interpret(JSContext* cx,
CASE(JSOP_DEFCONST) CASE(JSOP_DEFCONST)
CASE(JSOP_DEFLET) { CASE(JSOP_DEFLET) {
LexicalEnvironmentObject* lexicalEnv; HandleObject env = REGS.fp()->environmentChain();
JSObject* varObj; if (!DefLexicalOperation(cx, env, script, REGS.pc)) {
if (script->hasNonSyntacticScope()) {
lexicalEnv = &REGS.fp()->extensibleLexicalEnvironment();
varObj = &REGS.fp()->varObj();
} else {
lexicalEnv = &cx->global()->lexicalEnvironment();
varObj = cx->global();
}
if (!DefLexicalOperation(cx, lexicalEnv, varObj, script, REGS.pc)) {
goto error; goto error;
} }
} }
@ -4641,11 +4633,10 @@ bool js::DefLexicalOperation(JSContext* cx,
return NativeDefineDataProperty(cx, lexicalEnv, id, uninitialized, attrs); return NativeDefineDataProperty(cx, lexicalEnv, id, uninitialized, attrs);
} }
bool js::DefLexicalOperation(JSContext* cx, bool js::DefLexicalOperation(JSContext* cx, HandleObject envChain,
LexicalEnvironmentObject* lexicalEnvArg, HandleScript script, jsbytecode* pc) {
JSObject* varObjArg, JSScript* script,
jsbytecode* pc) {
MOZ_ASSERT(*pc == JSOP_DEFLET || *pc == JSOP_DEFCONST); MOZ_ASSERT(*pc == JSOP_DEFLET || *pc == JSOP_DEFCONST);
RootedPropertyName name(cx, script->getName(pc)); RootedPropertyName name(cx, script->getName(pc));
unsigned attrs = JSPROP_ENUMERATE | JSPROP_PERMANENT; unsigned attrs = JSPROP_ENUMERATE | JSPROP_PERMANENT;
@ -4653,8 +4644,16 @@ bool js::DefLexicalOperation(JSContext* cx,
attrs |= JSPROP_READONLY; attrs |= JSPROP_READONLY;
} }
Rooted<LexicalEnvironmentObject*> lexicalEnv(cx, lexicalEnvArg); Rooted<LexicalEnvironmentObject*> lexicalEnv(cx);
RootedObject varObj(cx, varObjArg); RootedObject varObj(cx);
if (script->hasNonSyntacticScope()) {
lexicalEnv = &NearestEnclosingExtensibleLexicalEnvironment(envChain);
varObj = &GetVariablesObject(envChain);
} else {
lexicalEnv = &cx->global()->lexicalEnvironment();
varObj = cx->global();
}
MOZ_ASSERT_IF(!script->hasNonSyntacticScope(), MOZ_ASSERT_IF(!script->hasNonSyntacticScope(),
lexicalEnv == &cx->global()->lexicalEnvironment() && lexicalEnv == &cx->global()->lexicalEnvironment() &&
varObj == cx->global()); varObj == cx->global());

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

@ -454,10 +454,8 @@ bool DefLexicalOperation(JSContext* cx,
HandleObject varObj, HandlePropertyName name, HandleObject varObj, HandlePropertyName name,
unsigned attrs); unsigned attrs);
bool DefLexicalOperation(JSContext* cx, bool DefLexicalOperation(JSContext* cx, HandleObject envChain,
LexicalEnvironmentObject* lexicalEnvArg, HandleScript script, jsbytecode* pc);
JSObject* varObjArg, JSScript* script,
jsbytecode* pc);
bool DefFunOperation(JSContext* cx, HandleScript script, HandleObject envChain, bool DefFunOperation(JSContext* cx, HandleScript script, HandleObject envChain,
HandleFunction funArg); HandleFunction funArg);