Bug 1535137 - Store inline-doubles as Values in bytecode r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Tue, 09 Apr 2019 09:59:37 +0000
changeset 468555 7366858bc6ada4d4839937a3f3e69df1fa2a0aa3
parent 468554 17ae35a549afd32c827d9031db5628d23c41c4f7
child 468556 bbfe142d94f9569c59266550d6dc3ba5f5ac98b4
push id35843
push usernbeleuzu@mozilla.com
push dateTue, 09 Apr 2019 22:08:13 +0000
treeherdermozilla-central@a31032a16330 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1535137
milestone68.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 1535137 - Store inline-doubles as Values in bytecode r=jandem Differential Revision: https://phabricator.services.mozilla.com/D26622
js/src/frontend/BytecodeEmitter.cpp
js/src/jit/BaselineCompiler.cpp
js/src/jit/IonBuilder.cpp
js/src/vm/BytecodeUtil.cpp
js/src/vm/BytecodeUtil.h
js/src/vm/Interpreter.cpp
js/src/vm/Opcodes.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -2014,17 +2014,17 @@ bool BytecodeEmitter::emitCallIncDec(Una
 bool BytecodeEmitter::emitDouble(double d) {
   ptrdiff_t offset;
   if (!emitCheck(JSOP_DOUBLE, 9, &offset)) {
     return false;
   }
 
   jsbytecode* code = this->code(offset);
   code[0] = jsbytecode(JSOP_DOUBLE);
-  SET_DOUBLE(code, d);
+  SET_INLINE_VALUE(code, DoubleValue(d));
   updateDepth(offset);
   return true;
 }
 
 bool BytecodeEmitter::emitNumberOp(double dval) {
   int32_t ival;
   if (NumberIsInt32(dval, &ival)) {
     if (ival == 0) {
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -2158,17 +2158,17 @@ bool BaselineInterpreterCodeGen::emit_JS
 
 template <typename Handler>
 bool BaselineCodeGen<Handler>::emit_JSOP_RESUMEINDEX() {
   return emit_JSOP_UINT24();
 }
 
 template <>
 bool BaselineCompilerCodeGen::emit_JSOP_DOUBLE() {
-  frame.push(DoubleValue(GET_DOUBLE(handler.pc())));
+  frame.push(GET_INLINE_VALUE(handler.pc()));
   return true;
 }
 
 template <>
 bool BaselineInterpreterCodeGen::emit_JSOP_DOUBLE() {
   MOZ_CRASH("NYI: interpreter JSOP_DOUBLE");
 }
 
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -1962,17 +1962,17 @@ AbortReasonOr<Ok> IonBuilder::inspectOpc
     case JSOP_STRICTNE:
     case JSOP_LT:
     case JSOP_LE:
     case JSOP_GT:
     case JSOP_GE:
       return jsop_compare(op);
 
     case JSOP_DOUBLE:
-      pushConstant(DoubleValue(GET_DOUBLE(pc)));
+      pushConstant(GET_INLINE_VALUE(pc));
       return Ok();
 
     case JSOP_BIGINT:
       pushConstant(info().getConst(pc));
       return Ok();
 
     case JSOP_STRING:
       pushConstant(StringValue(info().getAtom(pc)));
--- a/js/src/vm/BytecodeUtil.cpp
+++ b/js/src/vm/BytecodeUtil.cpp
@@ -1470,17 +1470,17 @@ static unsigned Disassemble1(JSContext* 
       }
       if (!sp->jsprintf(" %s", bytes.get())) {
         return 0;
       }
       break;
     }
 
     case JOF_DOUBLE: {
-      double d = GET_DOUBLE(pc);
+      double d = GET_INLINE_VALUE(pc).toDouble();
       if (!sp->jsprintf(" %lf", d)) {
         return 0;
       }
       break;
     }
 
     case JOF_BIGINT: {
       RootedValue v(cx, script->getConst(GET_UINT32_INDEX(pc)));
@@ -2014,17 +2014,17 @@ bool ExpressionDecompiler::decompilePC(j
       case JSOP_CALLSITEOBJ:
         return write("OBJ");
 
       case JSOP_CLASSCONSTRUCTOR:
       case JSOP_DERIVEDCONSTRUCTOR:
         return write("CONSTRUCTOR");
 
       case JSOP_DOUBLE:
-        return sprinter.printf("%lf", GET_DOUBLE(pc));
+        return sprinter.printf("%lf", GET_INLINE_VALUE(pc).toDouble());
 
       case JSOP_EXCEPTION:
         return write("EXCEPTION");
 
       case JSOP_FINALLY:
         if (defIndex == 0) {
           return write("THROWING");
         }
--- a/js/src/vm/BytecodeUtil.h
+++ b/js/src/vm/BytecodeUtil.h
@@ -52,17 +52,17 @@ enum {
   JOF_ENVCOORD = 9,     /* embedded ScopeCoordinate immediate */
   JOF_ARGC = 10,        /* uint16_t argument count */
   JOF_QARG = 11,        /* function argument index */
   JOF_LOCAL = 12,       /* var or block-local variable */
   JOF_RESUMEINDEX = 13, /* yield, await, or gosub resume index */
   JOF_ATOM = 14,        /* uint32_t constant index */
   JOF_OBJECT = 15,      /* uint32_t object index */
   JOF_REGEXP = 16,      /* uint32_t regexp index */
-  JOF_DOUBLE = 17,      /* inline double value */
+  JOF_DOUBLE = 17,      /* inline DoubleValue */
   JOF_SCOPE = 18,       /* uint32_t scope index */
   JOF_CODE_OFFSET = 19, /* int32_t bytecode offset */
   JOF_ICINDEX = 20,     /* uint32_t IC index */
   JOF_LOOPENTRY = 21,   /* JSOP_LOOPENTRY, combines JOF_ICINDEX and JOF_UINT8 */
   JOF_BIGINT = 22,      /* uint32_t index for BigInt value */
   JOF_TYPEMASK = 0x001f, /* mask for above immediate types */
 
   JOF_NAME = 1 << 5,     /* name operation */
@@ -158,24 +158,26 @@ static MOZ_ALWAYS_INLINE uint32_t GET_UI
   mozilla::NativeEndian::copyAndSwapFromLittleEndian(&result, pc + 1, 1);
   return result;
 }
 
 static MOZ_ALWAYS_INLINE void SET_UINT32(jsbytecode* pc, uint32_t u) {
   mozilla::NativeEndian::copyAndSwapToLittleEndian(pc + 1, &u, 1);
 }
 
-static MOZ_ALWAYS_INLINE double GET_DOUBLE(const jsbytecode* pc) {
-  double result;
-  mozilla::NativeEndian::copyAndSwapFromLittleEndian(&result, pc + 1, 1);
-  return result;
+static MOZ_ALWAYS_INLINE JS::Value GET_INLINE_VALUE(const jsbytecode* pc) {
+  uint64_t raw;
+  mozilla::NativeEndian::copyAndSwapFromLittleEndian(&raw, pc + 1, 1);
+  return JS::Value::fromRawBits(raw);
 }
 
-static MOZ_ALWAYS_INLINE void SET_DOUBLE(jsbytecode* pc, double d) {
-  mozilla::NativeEndian::copyAndSwapToLittleEndian(pc + 1, &d, 1);
+static MOZ_ALWAYS_INLINE void SET_INLINE_VALUE(jsbytecode* pc,
+                                               const JS::Value& v) {
+  uint64_t raw = v.asRawBits();
+  mozilla::NativeEndian::copyAndSwapToLittleEndian(pc + 1, &raw, 1);
 }
 
 static MOZ_ALWAYS_INLINE int32_t GET_INT32(const jsbytecode* pc) {
   return static_cast<int32_t>(GET_UINT32(pc));
 }
 
 static MOZ_ALWAYS_INLINE void SET_INT32(jsbytecode* pc, int32_t i) {
   SET_UINT32(pc, static_cast<uint32_t>(i));
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -3261,17 +3261,17 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_
     END_CASE(JSOP_UINT24)
 
     CASE(JSOP_INT8) { PUSH_INT32(GET_INT8(REGS.pc)); }
     END_CASE(JSOP_INT8)
 
     CASE(JSOP_INT32) { PUSH_INT32(GET_INT32(REGS.pc)); }
     END_CASE(JSOP_INT32)
 
-    CASE(JSOP_DOUBLE) { PUSH_DOUBLE(GET_DOUBLE(REGS.pc)); }
+    CASE(JSOP_DOUBLE) { PUSH_COPY(GET_INLINE_VALUE(REGS.pc)); }
     END_CASE(JSOP_DOUBLE)
 
     CASE(JSOP_STRING) { PUSH_STRING(script->getAtom(REGS.pc)); }
     END_CASE(JSOP_STRING)
 
     CASE(JSOP_TOSTRING) {
       MutableHandleValue oper = REGS.stackHandleAt(-1);
 
--- a/js/src/vm/Opcodes.h
+++ b/js/src/vm/Opcodes.h
@@ -611,17 +611,17 @@
      *   Stack: => val
      */ \
     MACRO(JSOP_GETNAME, 59, "getname", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET|JOF_IC) \
     /*
      * Pushes numeric constant onto the stack.
      *
      *   Category: Literals
      *   Type: Constants
-     *   Operands: double literal
+     *   Operands: DoubleValue literal
      *   Stack: => val
      */ \
     MACRO(JSOP_DOUBLE, 60, "double", NULL, 9, 0, 1, JOF_DOUBLE) \
     /*
      * Pushes string constant onto the stack.
      *
      *   Category: Literals
      *   Type: Constants