Bug 1511891 part 2 - Move DefVarOperation from Interpreter-inl.h to Interpreter.cpp. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 11 Jan 2019 09:12:15 +0000
changeset 453456 3523e71282fd2bbb093866671f80cd923ba189b8
parent 453455 582477c043dd5367a4acb02ca0b5032ad6d9997d
child 453457 452034cea923027f9db55730d5156210ff8e8ad6
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 2 - Move DefVarOperation from Interpreter-inl.h to Interpreter.cpp. r=tcampbell No change in behavior. Differential Revision: https://phabricator.services.mozilla.com/D13700
js/src/vm/Interpreter-inl.h
js/src/vm/Interpreter.cpp
js/src/vm/Interpreter.h
--- a/js/src/vm/Interpreter-inl.h
+++ b/js/src/vm/Interpreter-inl.h
@@ -404,53 +404,16 @@ inline bool InitPropertyOperation(JSCont
                                     propAttrs);
   }
 
   MOZ_ASSERT(obj->as<UnboxedPlainObject>().layout().lookup(name));
   RootedId id(cx, NameToId(name));
   return PutProperty(cx, obj, id, rhs, false);
 }
 
-inline bool DefVarOperation(JSContext* cx, HandleObject varobj,
-                            HandlePropertyName dn, unsigned attrs) {
-  MOZ_ASSERT(varobj->isQualifiedVarObj());
-
-#ifdef DEBUG
-  // Per spec, it is an error to redeclare a lexical binding. This should
-  // have already been checked.
-  if (JS_HasExtensibleLexicalEnvironment(varobj)) {
-    Rooted<LexicalEnvironmentObject*> lexicalEnv(cx);
-    lexicalEnv = &JS_ExtensibleLexicalEnvironment(varobj)
-                      ->as<LexicalEnvironmentObject>();
-    MOZ_ASSERT(CheckVarNameConflict(cx, lexicalEnv, dn));
-  }
-#endif
-
-  Rooted<PropertyResult> prop(cx);
-  RootedObject obj2(cx);
-  if (!LookupProperty(cx, varobj, dn, &obj2, &prop)) {
-    return false;
-  }
-
-  /* Steps 8c, 8d. */
-  if (!prop || (obj2 != varobj && varobj->is<GlobalObject>())) {
-    if (!DefineDataProperty(cx, varobj, dn, UndefinedHandleValue, attrs)) {
-      return false;
-    }
-  }
-
-  if (varobj->is<GlobalObject>()) {
-    if (!varobj->as<GlobalObject>().realm()->addToVarNames(cx, dn)) {
-      return false;
-    }
-  }
-
-  return true;
-}
-
 static MOZ_ALWAYS_INLINE bool NegOperation(JSContext* cx,
                                            MutableHandleValue val,
                                            MutableHandleValue res) {
   /*
    * When the operand is int jsval, INT32_FITS_IN_JSVAL(i) implies
    * INT32_FITS_IN_JSVAL(-i) unless i is 0 or INT32_MIN when the
    * results, -0.0 or INT32_MAX + 1, are double values.
    */
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -4587,16 +4587,53 @@ JSObject* js::LambdaArrow(JSContext* cx,
 }
 
 JSObject* js::BindVarOperation(JSContext* cx, JSObject* envChain) {
   // Note: BindVarOperation has an unused cx argument because the JIT callVM
   // machinery requires this.
   return &GetVariablesObject(envChain);
 }
 
+bool js::DefVarOperation(JSContext* cx, HandleObject varobj,
+                         HandlePropertyName dn, unsigned attrs) {
+  MOZ_ASSERT(varobj->isQualifiedVarObj());
+
+#ifdef DEBUG
+  // Per spec, it is an error to redeclare a lexical binding. This should
+  // have already been checked.
+  if (JS_HasExtensibleLexicalEnvironment(varobj)) {
+    Rooted<LexicalEnvironmentObject*> lexicalEnv(cx);
+    lexicalEnv = &JS_ExtensibleLexicalEnvironment(varobj)
+                      ->as<LexicalEnvironmentObject>();
+    MOZ_ASSERT(CheckVarNameConflict(cx, lexicalEnv, dn));
+  }
+#endif
+
+  Rooted<PropertyResult> prop(cx);
+  RootedObject obj2(cx);
+  if (!LookupProperty(cx, varobj, dn, &obj2, &prop)) {
+    return false;
+  }
+
+  /* Steps 8c, 8d. */
+  if (!prop || (obj2 != varobj && varobj->is<GlobalObject>())) {
+    if (!DefineDataProperty(cx, varobj, dn, UndefinedHandleValue, attrs)) {
+      return false;
+    }
+  }
+
+  if (varobj->is<GlobalObject>()) {
+    if (!varobj->as<GlobalObject>().realm()->addToVarNames(cx, dn)) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
 bool js::DefFunOperation(JSContext* cx, HandleScript script,
                          HandleObject envChain, HandleFunction fun) {
   /*
    * We define the function as a property of the variable object and not the
    * current scope chain even for the case of function expression statements
    * and functions defined by eval inside let or with blocks.
    */
   RootedObject parent(cx, envChain);
--- a/js/src/vm/Interpreter.h
+++ b/js/src/vm/Interpreter.h
@@ -441,16 +441,19 @@ bool DeletePropertyJit(JSContext* ctx, H
                        bool* bv);
 
 template <bool strict>
 bool DeleteElementJit(JSContext* cx, HandleValue val, HandleValue index,
                       bool* bv);
 
 JSObject* BindVarOperation(JSContext* cx, JSObject* envChain);
 
+bool DefVarOperation(JSContext* cx, HandleObject varobj, HandlePropertyName dn,
+                     unsigned attrs);
+
 bool DefFunOperation(JSContext* cx, HandleScript script, HandleObject envChain,
                      HandleFunction funArg);
 
 bool ThrowMsgOperation(JSContext* cx, const unsigned errorNum);
 
 bool GetAndClearException(JSContext* cx, MutableHandleValue res);
 
 bool DeleteNameOperation(JSContext* cx, HandlePropertyName name,