Bug 1511891 part 5 - Refactor DefLexicalOperation to make it easier to call directly from JIT code in the next patch. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 11 Jan 2019 09:13:31 +0000
changeset 453459 c6e9f5fd0ee7df11463b1bec4b795794752c8fd5
parent 453458 8fccd1861a223be784a3cb3215ee341d9bacc5e6
child 453460 745cbd9ae616029f2f146b3ab810709755e4b692
push id35357
push usernerli@mozilla.com
push dateFri, 11 Jan 2019 21:54:07 +0000
treeherdermozilla-central@0ce024c91511 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1511891
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
js/src/vm/Interpreter.cpp
js/src/vm/Interpreter.h
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -3622,26 +3622,18 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_
       if (!DefVarOperation(cx, env, script, REGS.pc)) {
         goto error;
       }
     }
     END_CASE(JSOP_DEFVAR)
 
     CASE(JSOP_DEFCONST)
     CASE(JSOP_DEFLET) {
-      LexicalEnvironmentObject* lexicalEnv;
-      JSObject* varObj;
-      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)) {
+      HandleObject env = REGS.fp()->environmentChain();
+      if (!DefLexicalOperation(cx, env, script, REGS.pc)) {
         goto error;
       }
     }
     END_CASE(JSOP_DEFLET)
 
     CASE(JSOP_DEFFUN) {
       /*
        * A top-level function defined in Global or Eval code (see ECMA-262
@@ -4636,30 +4628,37 @@ bool js::DefLexicalOperation(JSContext* 
                              unsigned attrs) {
   // Redeclaration checks should have already been done.
   MOZ_ASSERT(CheckLexicalNameConflict(cx, lexicalEnv, varObj, name));
   RootedId id(cx, NameToId(name));
   RootedValue uninitialized(cx, MagicValue(JS_UNINITIALIZED_LEXICAL));
   return NativeDefineDataProperty(cx, lexicalEnv, id, uninitialized, attrs);
 }
 
-bool js::DefLexicalOperation(JSContext* cx,
-                             LexicalEnvironmentObject* lexicalEnvArg,
-                             JSObject* varObjArg, JSScript* script,
-                             jsbytecode* pc) {
+bool js::DefLexicalOperation(JSContext* cx, HandleObject envChain,
+                             HandleScript script, jsbytecode* pc) {
   MOZ_ASSERT(*pc == JSOP_DEFLET || *pc == JSOP_DEFCONST);
+
   RootedPropertyName name(cx, script->getName(pc));
 
   unsigned attrs = JSPROP_ENUMERATE | JSPROP_PERMANENT;
   if (*pc == JSOP_DEFCONST) {
     attrs |= JSPROP_READONLY;
   }
 
-  Rooted<LexicalEnvironmentObject*> lexicalEnv(cx, lexicalEnvArg);
-  RootedObject varObj(cx, varObjArg);
+  Rooted<LexicalEnvironmentObject*> lexicalEnv(cx);
+  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(),
                 lexicalEnv == &cx->global()->lexicalEnvironment() &&
                     varObj == cx->global());
 
   return DefLexicalOperation(cx, lexicalEnv, varObj, name, attrs);
 }
 
 bool js::DefFunOperation(JSContext* cx, HandleScript script,
--- a/js/src/vm/Interpreter.h
+++ b/js/src/vm/Interpreter.h
@@ -449,20 +449,18 @@ JSObject* BindVarOperation(JSContext* cx
 bool DefVarOperation(JSContext* cx, HandleObject envChain, HandleScript script,
                      jsbytecode* pc);
 
 bool DefLexicalOperation(JSContext* cx,
                          Handle<LexicalEnvironmentObject*> lexicalEnv,
                          HandleObject varObj, HandlePropertyName name,
                          unsigned attrs);
 
-bool DefLexicalOperation(JSContext* cx,
-                         LexicalEnvironmentObject* lexicalEnvArg,
-                         JSObject* varObjArg, JSScript* script,
-                         jsbytecode* pc);
+bool DefLexicalOperation(JSContext* cx, HandleObject envChain,
+                         HandleScript script, jsbytecode* pc);
 
 bool DefFunOperation(JSContext* cx, HandleScript script, HandleObject envChain,
                      HandleFunction funArg);
 
 bool ThrowMsgOperation(JSContext* cx, const unsigned errorNum);
 
 bool GetAndClearException(JSContext* cx, MutableHandleValue res);