Bug 1522837 part 12 - Support JSOP_NEWARRAY and JSOP_INITELEM_ARRAY in BaselineCodeGen. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Sun, 10 Mar 2019 19:43:44 +0000
changeset 524297 cbba4888990efd52952797d97b60e06dfddc7aac
parent 524296 7a376bfac6dea0340625911e8bb02ad30c21d5e8
child 524298 0360f25e31db4b8a9358d13152f3c0b44b0369e4
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdjvj
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 12 - Support JSOP_NEWARRAY and JSOP_INITELEM_ARRAY in BaselineCodeGen. r=djvj Differential Revision: https://phabricator.services.mozilla.com/D19173
js/src/jit/BaselineCompiler.cpp
js/src/jit/BaselineCompiler.h
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -904,16 +904,49 @@ void BaselineCompilerCodeGen::loadResume
   masm.move32(Imm32(GET_RESUMEINDEX(handler.pc())), dest);
 }
 
 template <>
 void BaselineInterpreterCodeGen::loadResumeIndexBytecodeOperand(Register dest) {
   MOZ_CRASH("NYI: interpreter loadResumeIndexBytecodeOperand");
 }
 
+template <>
+void BaselineCompilerCodeGen::loadInt32LengthBytecodeOperand(Register dest) {
+  uint32_t length = GET_UINT32(handler.pc());
+  MOZ_ASSERT(length <= INT32_MAX,
+             "the bytecode emitter must fail to compile code that would "
+             "produce a length exceeding int32_t range");
+  masm.move32(Imm32(AssertedCast<int32_t>(length)), dest);
+}
+
+template <>
+void BaselineInterpreterCodeGen::loadInt32LengthBytecodeOperand(Register dest) {
+  masm.loadPtr(frame.addressOfInterpreterPC(), dest);
+  LoadInt32Operand(masm, dest, dest);
+}
+
+template <>
+void BaselineCompilerCodeGen::loadInt32IndexBytecodeOperand(ValueOperand dest) {
+  uint32_t index = GET_UINT32(handler.pc());
+  MOZ_ASSERT(index <= INT32_MAX,
+             "the bytecode emitter must fail to compile code that would "
+             "produce an index exceeding int32_t range");
+  masm.moveValue(Int32Value(AssertedCast<int32_t>(index)), dest);
+}
+
+template <>
+void BaselineInterpreterCodeGen::loadInt32IndexBytecodeOperand(
+    ValueOperand dest) {
+  Register scratch = dest.scratchReg();
+  masm.loadPtr(frame.addressOfInterpreterPC(), scratch);
+  LoadInt32Operand(masm, scratch, scratch);
+  masm.tagValue(JSVAL_TYPE_INT32, scratch, dest);
+}
+
 template <typename Handler>
 bool BaselineCodeGen<Handler>::emitDebugPrologue() {
   auto ifDebuggee = [this]() {
     // Load pointer to BaselineFrame in R0.
     masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
 
     prepareVMCall();
     pushBytecodePCArg();
@@ -2508,42 +2541,32 @@ bool BaselineCodeGen<Handler>::emit_JSOP
   return emit_JSOP_GOTO();
 }
 
 template <typename Handler>
 bool BaselineCodeGen<Handler>::emit_JSOP_LINENO() {
   return true;
 }
 
-template <>
-bool BaselineCompilerCodeGen::emit_JSOP_NEWARRAY() {
+template <typename Handler>
+bool BaselineCodeGen<Handler>::emit_JSOP_NEWARRAY() {
   frame.syncStack(0);
 
-  uint32_t length = GET_UINT32(handler.pc());
-  MOZ_ASSERT(length <= INT32_MAX,
-             "the bytecode emitter must fail to compile code that would "
-             "produce JSOP_NEWARRAY with a length exceeding int32_t range");
-
   // Pass length in R0.
-  masm.move32(Imm32(AssertedCast<int32_t>(length)), R0.scratchReg());
+  loadInt32LengthBytecodeOperand(R0.scratchReg());
 
   if (!emitNextIC()) {
     return false;
   }
 
   frame.push(R0);
   return true;
 }
 
 template <>
-bool BaselineInterpreterCodeGen::emit_JSOP_NEWARRAY() {
-  MOZ_CRASH("NYI: interpreter JSOP_NEWARRAY");
-}
-
-template <>
 bool BaselineCompilerCodeGen::emit_JSOP_NEWARRAY_COPYONWRITE() {
   // This is like the interpreter implementation, but we can call
   // getOrFixupCopyOnWriteObject at compile-time.
 
   RootedScript scriptRoot(cx, handler.script());
   JSObject* obj =
       ObjectGroup::getOrFixupCopyOnWriteObject(cx, scriptRoot, handler.pc());
   if (!obj) {
@@ -2578,45 +2601,35 @@ bool BaselineInterpreterCodeGen::emit_JS
   }
 
   // Box and push return value.
   masm.tagValue(JSVAL_TYPE_OBJECT, ReturnReg, R0);
   frame.push(R0);
   return true;
 }
 
-template <>
-bool BaselineCompilerCodeGen::emit_JSOP_INITELEM_ARRAY() {
+template <typename Handler>
+bool BaselineCodeGen<Handler>::emit_JSOP_INITELEM_ARRAY() {
   // Keep the object and rhs on the stack.
   frame.syncStack(0);
 
   // Load object in R0, index in R1.
   masm.loadValue(frame.addressOfStackValue(-2), R0);
-  uint32_t index = GET_UINT32(handler.pc());
-  MOZ_ASSERT(index <= INT32_MAX,
-             "the bytecode emitter must fail to compile code that would "
-             "produce JSOP_INITELEM_ARRAY with a length exceeding "
-             "int32_t range");
-  masm.moveValue(Int32Value(AssertedCast<int32_t>(index)), R1);
+  loadInt32IndexBytecodeOperand(R1);
 
   // Call IC.
   if (!emitNextIC()) {
     return false;
   }
 
   // Pop the rhs, so that the object is on the top of the stack.
   frame.pop();
   return true;
 }
 
-template <>
-bool BaselineInterpreterCodeGen::emit_JSOP_INITELEM_ARRAY() {
-  MOZ_CRASH("NYI: interpreter JSOP_INITELEM_ARRAY");
-}
-
 template <typename Handler>
 bool BaselineCodeGen<Handler>::emit_JSOP_NEWOBJECT() {
   frame.syncStack(0);
 
   if (!emitNextIC()) {
     return false;
   }
 
--- a/js/src/jit/BaselineCompiler.h
+++ b/js/src/jit/BaselineCompiler.h
@@ -316,16 +316,18 @@ class BaselineCodeGen {
   void pushScriptNameArg();
   void pushScriptScopeArg();
 
   // Pushes a bytecode operand as argument for a VM function.
   void pushUint8BytecodeOperandArg();
   void pushUint16BytecodeOperandArg();
 
   void loadResumeIndexBytecodeOperand(Register dest);
+  void loadInt32LengthBytecodeOperand(Register dest);
+  void loadInt32IndexBytecodeOperand(ValueOperand dest);
 
   // Loads the current JSScript* in dest.
   void loadScript(Register dest);
 
   // Subtracts |script->nslots() * sizeof(Value)| from reg.
   void subtractScriptSlotsSize(Register reg, Register scratch);
 
   // Jump to the script's resume entry indicated by resumeIndex.