Bug 1229057 - Part 7: Move MacroAssembler::addConstantDouble into generic macro assembler. r=jandem
authorTooru Fujisawa <arai_a@mac.com>
Tue, 01 Dec 2015 17:02:59 +0900
changeset 316148 39dc8792221d9205de8dd10a519e620841d6980c
parent 316147 23bd21ccb964f7fafff6688bafb3f1b11215cb15
child 316149 81fddea678a7bfea7225c96d00c25a149f52889e
push id8516
push userjlund@mozilla.com
push dateFri, 18 Dec 2015 00:52:34 +0000
reviewersjandem
bugs1229057
milestone46.0a1
Bug 1229057 - Part 7: Move MacroAssembler::addConstantDouble into generic macro assembler. r=jandem
js/src/jit/MacroAssembler.h
js/src/jit/none/MacroAssembler-none.h
js/src/jit/x86/MacroAssembler-x86-inl.h
js/src/jit/x86/MacroAssembler-x86.cpp
js/src/jit/x86/MacroAssembler-x86.h
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -747,16 +747,17 @@ class MacroAssembler : public MacroAssem
     inline void addPtr(const Address& src, Register dest) DEFINED_ON(mips_shared, arm, arm64, x86, x64);
 
     inline void add64(Register64 src, Register64 dest) PER_ARCH;
     inline void add64(Imm32 imm, Register64 dest) PER_ARCH;
 
     inline void addFloat32(FloatRegister src, FloatRegister dest) DEFINED_ON(x86_shared);
 
     inline void addDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH;
+    inline void addConstantDouble(double d, FloatRegister dest) DEFINED_ON(x86);
 
     inline void sub32(const Address& src, Register dest) PER_SHARED_ARCH;
     inline void sub32(Register src, Register dest) PER_SHARED_ARCH;
     inline void sub32(Imm32 imm, Register dest) PER_SHARED_ARCH;
 
     // ===============================================================
     // Shift functions
 
--- a/js/src/jit/none/MacroAssembler-none.h
+++ b/js/src/jit/none/MacroAssembler-none.h
@@ -404,17 +404,16 @@ class MacroAssemblerNone : public Assemb
     void branchTruncateFloat32(FloatRegister, Register, Label*) { MOZ_CRASH(); }
 
     void boolValueToDouble(ValueOperand, FloatRegister) { MOZ_CRASH(); }
     void boolValueToFloat32(ValueOperand, FloatRegister) { MOZ_CRASH(); }
     void int32ValueToDouble(ValueOperand, FloatRegister) { MOZ_CRASH(); }
     void int32ValueToFloat32(ValueOperand, FloatRegister) { MOZ_CRASH(); }
 
     void loadConstantDouble(double, FloatRegister) { MOZ_CRASH(); }
-    void addConstantDouble(double, FloatRegister) { MOZ_CRASH(); }
     void loadConstantFloat32(float, FloatRegister) { MOZ_CRASH(); }
     Condition testInt32Truthy(bool, ValueOperand) { MOZ_CRASH(); }
     Condition testStringTruthy(bool, ValueOperand) { MOZ_CRASH(); }
     void branchTestInt32Truthy(bool, ValueOperand, Label*) { MOZ_CRASH(); }
     void branchTestBooleanTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); }
     void branchTestStringTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); }
     void branchTestDoubleTruthy(bool, FloatRegister, Label*) { MOZ_CRASH(); }
 
--- a/js/src/jit/x86/MacroAssembler-x86-inl.h
+++ b/js/src/jit/x86/MacroAssembler-x86-inl.h
@@ -123,16 +123,26 @@ MacroAssembler::add64(Register64 src, Re
 
 void
 MacroAssembler::add64(Imm32 imm, Register64 dest)
 {
     addl(imm, dest.low);
     adcl(Imm32(0), dest.high);
 }
 
+void
+MacroAssembler::addConstantDouble(double d, FloatRegister dest)
+{
+    Double* dbl = getDouble(d);
+    if (!dbl)
+        return;
+    masm.vaddsd_mr(nullptr, dest.encoding(), dest.encoding());
+    propagateOOM(dbl->uses.append(CodeOffset(masm.size())));
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     shll(imm, dest);
 }
@@ -161,12 +171,35 @@ MacroAssembler::rshift64(Imm32 imm, Regi
 {
     shrdl(imm, dest.high, dest.low);
     shrl(imm, dest.high);
 }
 
 //}}} check_macroassembler_style
 // ===============================================================
 
+// Note: this function clobbers the source register.
+void
+MacroAssemblerX86::convertUInt32ToDouble(Register src, FloatRegister dest)
+{
+    // src is [0, 2^32-1]
+    subl(Imm32(0x80000000), src);
+
+    // Now src is [-2^31, 2^31-1] - int range, but not the same value.
+    convertInt32ToDouble(src, dest);
+
+    // dest is now a double with the int range.
+    // correct the double value by adding 0x80000000.
+    asMasm().addConstantDouble(2147483648.0, dest);
+}
+
+// Note: this function clobbers the source register.
+void
+MacroAssemblerX86::convertUInt32ToFloat32(Register src, FloatRegister dest)
+{
+    convertUInt32ToDouble(src, dest);
+    convertDoubleToFloat32(dest, dest);
+}
+
 } // namespace jit
 } // namespace js
 
 #endif /* jit_x86_MacroAssembler_x86_inl_h */
--- a/js/src/jit/x86/MacroAssembler-x86.cpp
+++ b/js/src/jit/x86/MacroAssembler-x86.cpp
@@ -98,26 +98,16 @@ MacroAssemblerX86::loadConstantDouble(do
     Double* dbl = getDouble(d);
     if (!dbl)
         return;
     masm.vmovsd_mr(nullptr, dest.encoding());
     propagateOOM(dbl->uses.append(CodeOffset(masm.size())));
 }
 
 void
-MacroAssemblerX86::addConstantDouble(double d, FloatRegister dest)
-{
-    Double* dbl = getDouble(d);
-    if (!dbl)
-        return;
-    masm.vaddsd_mr(nullptr, dest.encoding(), dest.encoding());
-    propagateOOM(dbl->uses.append(CodeOffset(masm.size())));
-}
-
-void
 MacroAssemblerX86::loadConstantFloat32(float f, FloatRegister dest)
 {
     if (maybeInlineFloat(f, dest))
         return;
     Float* flt = getFloat(f);
     if (!flt)
         return;
     masm.vmovss_mr(nullptr, dest.encoding());
--- a/js/src/jit/x86/MacroAssembler-x86.h
+++ b/js/src/jit/x86/MacroAssembler-x86.h
@@ -981,17 +981,16 @@ class MacroAssemblerX86 : public MacroAs
     void int32ValueToDouble(const ValueOperand& operand, FloatRegister dest) {
         convertInt32ToDouble(operand.payloadReg(), dest);
     }
     void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest) {
         convertInt32ToFloat32(operand.payloadReg(), dest);
     }
 
     void loadConstantDouble(double d, FloatRegister dest);
-    void addConstantDouble(double d, FloatRegister dest);
     void loadConstantFloat32(float f, FloatRegister dest);
     void loadConstantInt32x4(const SimdConstant& v, FloatRegister dest);
     void loadConstantFloat32x4(const SimdConstant& v, FloatRegister dest);
 
     void branchTruncateDouble(FloatRegister src, Register dest, Label* fail) {
         vcvttsd2si(src, dest);
 
         // vcvttsd2si returns 0x80000000 on failure. Test for it by
@@ -1067,33 +1066,20 @@ class MacroAssemblerX86 : public MacroAs
         }
     }
 
     void loadInstructionPointerAfterCall(Register dest) {
         movl(Operand(StackPointer, 0x0), dest);
     }
 
     // Note: this function clobbers the source register.
-    void convertUInt32ToDouble(Register src, FloatRegister dest) {
-        // src is [0, 2^32-1]
-        subl(Imm32(0x80000000), src);
-
-        // Now src is [-2^31, 2^31-1] - int range, but not the same value.
-        convertInt32ToDouble(src, dest);
-
-        // dest is now a double with the int range.
-        // correct the double value by adding 0x80000000.
-        addConstantDouble(2147483648.0, dest);
-    }
+    inline void convertUInt32ToDouble(Register src, FloatRegister dest);
 
     // Note: this function clobbers the source register.
-    void convertUInt32ToFloat32(Register src, FloatRegister dest) {
-        convertUInt32ToDouble(src, dest);
-        convertDoubleToFloat32(dest, dest);
-    }
+    inline void convertUInt32ToFloat32(Register src, FloatRegister dest);
 
     void convertUInt64ToDouble(Register64 src, Register temp, FloatRegister dest);
 
     void mulDoublePtr(ImmPtr imm, Register temp, FloatRegister dest) {
         movl(imm, temp);
         vmulsd(Operand(temp, 0), dest, dest);
     }