Bug 1522837 part 4 - Implement JSOP_CALLSITEOBJ in BaselineInterpreterCodeGen. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Sun, 03 Feb 2019 10:08:41 +0000
changeset 456586 8d112cd492e7443a9a3225425c798f8093c75c98
parent 456585 56d070f54c699b2ecc88500921c15459f161dcce
child 456587 8d612e0b0258f31a836bb163457605e0b4edd198
push id35492
push usercbrindusan@mozilla.com
push dateSun, 03 Feb 2019 21:40:38 +0000
treeherdermozilla-central@be2f62a541cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1522837
milestone67.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 1522837 part 4 - Implement JSOP_CALLSITEOBJ in BaselineInterpreterCodeGen. r=tcampbell This is just a VM call in the interpreter. We could optimize this with an IC or inline path if it ever becomes a problem. Differential Revision: https://phabricator.services.mozilla.com/D17935
js/src/jit/BaselineCompiler.cpp
js/src/vm/Interpreter-inl.h
js/src/vm/Interpreter.cpp
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -2087,35 +2087,47 @@ bool BaselineCodeGen<Handler>::emit_JSOP
   // Box and push return value.
   masm.tagValue(JSVAL_TYPE_OBJECT, ReturnReg, R0);
   frame.push(R0);
   return true;
 }
 
 template <>
 bool BaselineCompilerCodeGen::emit_JSOP_CALLSITEOBJ() {
-  JSScript* script = handler.script();
-  jsbytecode* pc = handler.pc();
-  RootedObject cso(cx, script->getObject(pc));
-  RootedObject raw(cx, script->getObject(GET_UINT32_INDEX(pc) + 1));
-  if (!cso || !raw) {
-    return false;
-  }
-
-  if (!ProcessCallSiteObjOperation(cx, cso, raw)) {
+  RootedScript script(cx, handler.script());
+  JSObject* cso = ProcessCallSiteObjOperation(cx, script, handler.pc());
+  if (!cso) {
     return false;
   }
 
   frame.push(ObjectValue(*cso));
   return true;
 }
 
+typedef ArrayObject* (*ProcessCallSiteObjFn)(JSContext*, HandleScript,
+                                             jsbytecode*);
+static const VMFunction ProcessCallSiteObjInfo =
+    FunctionInfo<ProcessCallSiteObjFn>(ProcessCallSiteObjOperation,
+                                       "ProcessCallSiteObjOperation");
+
 template <>
 bool BaselineInterpreterCodeGen::emit_JSOP_CALLSITEOBJ() {
-  MOZ_CRASH("NYI: interpreter JSOP_CALLSITEOBJ");
+  prepareVMCall();
+
+  pushBytecodePCArg();
+  pushScriptArg(R2.scratchReg());
+
+  if (!callVM(ProcessCallSiteObjInfo)) {
+    return false;
+  }
+
+  // Box and push return value.
+  masm.tagValue(JSVAL_TYPE_OBJECT, ReturnReg, R0);
+  frame.push(R0);
+  return true;
 }
 
 typedef JSObject* (*CloneRegExpObjectFn)(JSContext*, Handle<RegExpObject*>);
 static const VMFunction CloneRegExpObjectInfo =
     FunctionInfo<CloneRegExpObjectFn>(CloneRegExpObject, "CloneRegExpObject");
 
 template <typename Handler>
 bool BaselineCodeGen<Handler>::emit_JSOP_REGEXP() {
--- a/js/src/vm/Interpreter-inl.h
+++ b/js/src/vm/Interpreter-inl.h
@@ -667,35 +667,40 @@ static MOZ_ALWAYS_INLINE bool InitArrayE
     if (!DefineDataElement(cx, obj, index, val, JSPROP_ENUMERATE)) {
       return false;
     }
   }
 
   return true;
 }
 
-static MOZ_ALWAYS_INLINE bool ProcessCallSiteObjOperation(JSContext* cx,
-                                                          HandleObject cso,
-                                                          HandleObject raw) {
-  MOZ_ASSERT(cso->is<ArrayObject>());
-  MOZ_ASSERT(raw->is<ArrayObject>());
+static inline ArrayObject* ProcessCallSiteObjOperation(JSContext* cx,
+                                                       HandleScript script,
+                                                       jsbytecode* pc) {
+  MOZ_ASSERT(*pc == JSOP_CALLSITEOBJ);
 
-  if (cso->nonProxyIsExtensible()) {
+  RootedArrayObject cso(cx, &script->getObject(pc)->as<ArrayObject>());
+
+  if (cso->isExtensible()) {
+    RootedObject raw(cx, script->getObject(GET_UINT32_INDEX(pc) + 1));
+    MOZ_ASSERT(raw->is<ArrayObject>());
+
     RootedValue rawValue(cx, ObjectValue(*raw));
     if (!DefineDataProperty(cx, cso, cx->names().raw, rawValue, 0)) {
-      return false;
+      return nullptr;
     }
     if (!FreezeObject(cx, raw)) {
-      return false;
+      return nullptr;
     }
     if (!FreezeObject(cx, cso)) {
-      return false;
+      return nullptr;
     }
   }
-  return true;
+
+  return cso;
 }
 
 // BigInt proposal 3.2.4 Abstract Relational Comparison
 // Returns Nothing when at least one operand is a NaN, or when
 // ToNumeric or StringToBigInt can't interpret a string as a numeric
 // value. (These cases correspond to a NaN result in the spec.)
 // Otherwise, return a boolean to indicate whether lhs is less than
 // rhs. The operands must be primitives; the caller is responsible for
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -3294,24 +3294,20 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_
       if (!obj) {
         goto error;
       }
       PUSH_OBJECT(*obj);
     }
     END_CASE(JSOP_OBJECT)
 
     CASE(JSOP_CALLSITEOBJ) {
-      ReservedRooted<JSObject*> cso(&rootObject0, script->getObject(REGS.pc));
-      ReservedRooted<JSObject*> raw(
-          &rootObject1, script->getObject(GET_UINT32_INDEX(REGS.pc) + 1));
-
-      if (!ProcessCallSiteObjOperation(cx, cso, raw)) {
+      JSObject* cso = ProcessCallSiteObjOperation(cx, script, REGS.pc);
+      if (!cso) {
         goto error;
       }
-
       PUSH_OBJECT(*cso);
     }
     END_CASE(JSOP_CALLSITEOBJ)
 
     CASE(JSOP_REGEXP) {
       /*
        * Push a regexp object cloned from the regexp literal object mapped by
        * the bytecode at pc.