Bug 1438727: [Part 14] Support Double DIV and Double MOD r=tcampbell
authorMatthew Gaudet <mgaudet@mozilla.com>
Tue, 08 May 2018 16:05:48 -0400
changeset 428601 c2bd712cb42bec7b55cc3a8e4b5cde6c6bc0f38c
parent 428600 8127fbd4988d8d5f0d4a3885ffa1992a4d656b05
child 428602 ede13cd0e89a85e9e1080edc2145f52a79fff72d
push id34337
push userncsoregi@mozilla.com
push dateThu, 26 Jul 2018 21:58:45 +0000
treeherdermozilla-central@8f2f847b2f9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1438727
milestone63.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 1438727: [Part 14] Support Double DIV and Double MOD r=tcampbell
js/src/jit/CacheIR.cpp
js/src/jit/CacheIR.h
js/src/jit/CacheIRCompiler.cpp
js/src/jit/CacheIRCompiler.h
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -5156,17 +5156,18 @@ BinaryArithIRGenerator::tryAttachDoubleW
     writer.returnFromIC();
     return true;
 }
 
 bool
 BinaryArithIRGenerator::tryAttachDouble()
 {
     if (op_ != JSOP_ADD && op_ != JSOP_SUB &&
-        op_ != JSOP_MUL)
+        op_ != JSOP_MUL && op_ != JSOP_DIV &&
+        op_ != JSOP_MOD)
         return false;
 
     if (!lhs_.isDouble() || !rhs_.isDouble() || !res_.isDouble())
         return false;
 
     if (!cx_->runtime()->jitSupportsFloatingPoint)
         return false;
 
@@ -5184,16 +5185,24 @@ BinaryArithIRGenerator::tryAttachDouble(
       case JSOP_SUB:
         writer.doubleSubResult(lhsId, rhsId);
         trackAttached("BinaryArith.Double.Sub");
         break;
       case JSOP_MUL:
         writer.doubleMulResult(lhsId, rhsId);
         trackAttached("BinaryArith.Double.Mul");
         break;
+      case JSOP_DIV:
+        writer.doubleDivResult(lhsId, rhsId);
+        trackAttached("BinaryArith.Double.Div");
+        break;
+      case JSOP_MOD:
+        writer.doubleModResult(lhsId, rhsId);
+        trackAttached("BinaryArith.Double.Mod");
+        break;
       default:
         MOZ_CRASH("Unhandled Op");
     }
     writer.returnFromIC();
     return true;
 }
 
 bool
--- a/js/src/jit/CacheIR.h
+++ b/js/src/jit/CacheIR.h
@@ -290,16 +290,18 @@ extern const char* CacheKindNames[];
     _(LoadUndefinedResult)                \
     _(LoadBooleanResult)                  \
     _(LoadStringResult)                   \
     _(LoadInstanceOfObjectResult)         \
     _(LoadTypeOfObjectResult)             \
     _(DoubleAddResult)                    \
     _(DoubleSubResult)                    \
     _(DoubleMulResult)                    \
+    _(DoubleDivResult)                    \
+    _(DoubleModResult)                    \
     _(Int32AddResult)                     \
     _(Int32SubResult)                     \
     _(Int32MulResult)                     \
     _(Int32DivResult)                     \
     _(Int32ModResult)                     \
     _(Int32BitOrResult)                   \
     _(Int32BitXorResult)                  \
     _(Int32BitAndResult)                  \
@@ -1015,16 +1017,25 @@ class MOZ_RAII CacheIRWriter : public JS
     void doubleSubResult(ValOperandId lhsId, ValOperandId rhsId) {
         writeOpWithOperandId(CacheOp::DoubleSubResult, lhsId);
         writeOperandId(rhsId);
     }
     void doubleMulResult(ValOperandId lhsId, ValOperandId rhsId) {
         writeOpWithOperandId(CacheOp::DoubleMulResult, lhsId);
         writeOperandId(rhsId);
     }
+    void doubleDivResult(ValOperandId lhsId, ValOperandId rhsId) {
+        writeOpWithOperandId(CacheOp::DoubleDivResult, lhsId);
+        writeOperandId(rhsId);
+    }
+    void doubleModResult(ValOperandId lhsId, ValOperandId rhsId) {
+        writeOpWithOperandId(CacheOp::DoubleModResult, lhsId);
+        writeOperandId(rhsId);
+    }
+
     void int32AddResult(Int32OperandId lhs, Int32OperandId rhs) {
         writeOpWithOperandId(CacheOp::Int32AddResult, lhs);
         writeOperandId(rhs);
     }
     void int32SubResult(Int32OperandId lhs, Int32OperandId rhs) {
         writeOpWithOperandId(CacheOp::Int32SubResult, lhs);
         writeOperandId(rhs);
     }
--- a/js/src/jit/CacheIRCompiler.cpp
+++ b/js/src/jit/CacheIRCompiler.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jit/CacheIRCompiler.h"
 
 #include "mozilla/ScopeExit.h"
 
 #include <utility>
 
+#include "jslibmath.h"
 #include "jit/IonIC.h"
 #include "jit/SharedICHelpers.h"
 
 #include "builtin/Boolean-inl.h"
 
 #include "jit/MacroAssembler-inl.h"
 #include "vm/Realm-inl.h"
 
@@ -1992,16 +1993,57 @@ CacheIRCompiler::emitDoubleMulResult()
     allocator.loadDouble(masm, reader.valOperandId(), FloatReg0);
     allocator.loadDouble(masm, reader.valOperandId(), FloatReg1);
 
     masm.mulDouble(FloatReg1, FloatReg0);
     masm.boxDouble(FloatReg0, output.valueReg(), FloatReg0);
 
     return true;
 }
+bool
+CacheIRCompiler::emitDoubleDivResult()
+{
+    AutoOutputRegister output(*this);
+
+    allocator.loadDouble(masm, reader.valOperandId(), FloatReg0);
+    allocator.loadDouble(masm, reader.valOperandId(), FloatReg1);
+
+    masm.divDouble(FloatReg1, FloatReg0);
+    masm.boxDouble(FloatReg0, output.valueReg(), FloatReg0);
+
+    return true;
+}
+bool
+CacheIRCompiler::emitDoubleModResult()
+{
+    AutoOutputRegister output(*this);
+    AutoScratchRegisterMaybeOutput scratch(allocator, masm, output);
+
+    allocator.loadDouble(masm, reader.valOperandId(), FloatReg0);
+    allocator.loadDouble(masm, reader.valOperandId(), FloatReg1);
+
+    LiveRegisterSet save(GeneralRegisterSet::Volatile(), liveVolatileFloatRegs());
+    masm.PushRegsInMask(save);
+
+
+    masm.setupUnalignedABICall(scratch);
+    masm.passABIArg(FloatReg0, MoveOp::DOUBLE);
+    masm.passABIArg(FloatReg1, MoveOp::DOUBLE);
+    masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, js::NumberMod),
+                     MoveOp::DOUBLE);
+    masm.storeCallFloatResult(FloatReg0);
+
+    LiveRegisterSet ignore;
+    ignore.add(FloatReg0);
+    masm.PopRegsInMaskIgnore(save, ignore);
+
+    masm.boxDouble(FloatReg0, output.valueReg(), FloatReg0);
+
+    return true;
+}
 
 bool
 CacheIRCompiler::emitInt32AddResult()
 {
     AutoOutputRegister output(*this);
     Register lhs = allocator.useRegister(masm, reader.int32OperandId());
     Register rhs = allocator.useRegister(masm, reader.int32OperandId());
 
--- a/js/src/jit/CacheIRCompiler.h
+++ b/js/src/jit/CacheIRCompiler.h
@@ -50,16 +50,18 @@ namespace jit {
     _(LoadDOMExpandoValue)                \
     _(LoadDOMExpandoValueIgnoreGeneration)\
     _(LoadUndefinedResult)                \
     _(LoadBooleanResult)                  \
     _(LoadInt32ArrayLengthResult)         \
     _(DoubleAddResult)                    \
     _(DoubleSubResult)                    \
     _(DoubleMulResult)                    \
+    _(DoubleDivResult)                    \
+    _(DoubleModResult)                    \
     _(Int32AddResult)                     \
     _(Int32SubResult)                     \
     _(Int32MulResult)                     \
     _(Int32DivResult)                     \
     _(Int32ModResult)                     \
     _(Int32BitOrResult)                   \
     _(Int32BitXorResult)                  \
     _(Int32BitAndResult)                  \