Bug 1203964 - Part 1: Move MacroAssembler::rshiftPtr into generic macro assembler. r=h4writer
authorTooru Fujisawa <arai_a@mac.com>
Sat, 12 Sep 2015 11:01:17 +0900
changeset 294593 354d9854c2792868732db1509cef3477891b8fad
parent 294592 17f698573ccc32ac312350f896e962d6d9760a33
child 294594 87d424cf36cab9daabb68552f54cd2782eb2167a
push id5619
push userj.parkouss@gmail.com
push dateMon, 21 Sep 2015 17:26:04 +0000
reviewersh4writer
bugs1203964
milestone43.0a1
Bug 1203964 - Part 1: Move MacroAssembler::rshiftPtr into generic macro assembler. r=h4writer
js/src/jit/MacroAssembler.h
js/src/jit/arm/MacroAssembler-arm-inl.h
js/src/jit/arm/MacroAssembler-arm.h
js/src/jit/arm64/MacroAssembler-arm64-inl.h
js/src/jit/arm64/MacroAssembler-arm64.h
js/src/jit/mips32/MacroAssembler-mips32-inl.h
js/src/jit/mips32/MacroAssembler-mips32.h
js/src/jit/none/MacroAssembler-none.h
js/src/jit/x64/MacroAssembler-x64-inl.h
js/src/jit/x64/MacroAssembler-x64.cpp
js/src/jit/x64/MacroAssembler-x64.h
js/src/jit/x86/MacroAssembler-x86-inl.h
js/src/jit/x86/MacroAssembler-x86.h
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -692,16 +692,22 @@ class MacroAssembler : public MacroAssem
     inline void or64(Register64 src, Register64 dest) PER_ARCH;
 
     inline void xor32(Register src, Register dest) DEFINED_ON(x86_shared);
     inline void xor32(Imm32 imm, Register dest) PER_SHARED_ARCH;
 
     inline void xorPtr(Register src, Register dest) PER_ARCH;
     inline void xorPtr(Imm32 imm, Register dest) PER_ARCH;
 
+    // ===============================================================
+    // Shift functions
+
+    inline void rshiftPtr(Imm32 imm, Register dest) PER_ARCH;
+    inline void rshiftPtr(Imm32 imm, Register src, Register dest) DEFINED_ON(arm64);
+
     //}}} check_macroassembler_style
   public:
 
     // Emits a test of a value against all types in a TypeSet. A scratch
     // register is required.
     template <typename Source>
     void guardTypeSet(const Source& address, const TypeSet* types, BarrierKind kind, Register scratch, Label* miss);
 
--- a/js/src/jit/arm/MacroAssembler-arm-inl.h
+++ b/js/src/jit/arm/MacroAssembler-arm-inl.h
@@ -123,15 +123,24 @@ MacroAssembler::xorPtr(Register src, Reg
 }
 
 void
 MacroAssembler::xorPtr(Imm32 imm, Register dest)
 {
     ma_eor(imm, dest);
 }
 
+// ===============================================================
+// Shift functions
+
+void
+MacroAssembler::rshiftPtr(Imm32 imm, Register dest)
+{
+    ma_lsr(imm, dest, dest);
+}
+
 //}}} check_macroassembler_style
 // ===============================================================
 
 } // namespace jit
 } // namespace js
 
 #endif /* jit_arm_MacroAssembler_arm_inl_h */
--- a/js/src/jit/arm/MacroAssembler-arm.h
+++ b/js/src/jit/arm/MacroAssembler-arm.h
@@ -1711,19 +1711,16 @@ class MacroAssemblerARMCompat : public M
                       Label* label);
 
     void compareFloat(FloatRegister lhs, FloatRegister rhs);
     void branchFloat(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs,
                      Label* label);
 
     void checkStackAlignment();
 
-    void rshiftPtr(Imm32 imm, Register dest) {
-        ma_lsr(imm, dest, dest);
-    }
     void rshiftPtrArithmetic(Imm32 imm, Register dest) {
         ma_asr(imm, dest, dest);
     }
     void rshift64(Imm32 imm, Register64 dest) {
         as_mov(dest.low, lsr(dest.low, imm.value));
         as_orr(dest.low, dest.low, lsl(dest.high, 32 - imm.value));
         as_mov(dest.high, lsr(dest.high, imm.value));
     }
--- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h
+++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h
@@ -136,19 +136,40 @@ MacroAssembler::xorPtr(Register src, Reg
 }
 
 void
 MacroAssembler::xorPtr(Imm32 imm, Register dest)
 {
     Eor(ARMRegister(dest, 64), ARMRegister(dest, 64), Operand(imm.value));
 }
 
+// ===============================================================
+// Shift functions
+
+void
+MacroAssembler::rshiftPtr(Imm32 imm, Register dest)
+{
+    Lsr(ARMRegister(dest, 64), ARMRegister(dest, 64), imm.value);
+}
+
+void
+MacroAssembler::rshiftPtr(Imm32 imm, Register src, Register dest)
+{
+    Lsr(ARMRegister(dest, 64), ARMRegister(src, 64), imm.value);
+}
+
 //}}} check_macroassembler_style
 // ===============================================================
 
+void
+MacroAssemblerCompat::rshift64(Imm32 imm, Register64 dest)
+{
+    asMasm().rshiftPtr(imm, dest.reg);
+}
+
 template <typename T>
 void
 MacroAssemblerCompat::andToStackPtr(T t)
 {
     asMasm().andPtr(t, getStackPointer());
     syncStackPtr();
 }
 
--- a/js/src/jit/arm64/MacroAssembler-arm64.h
+++ b/js/src/jit/arm64/MacroAssembler-arm64.h
@@ -1064,25 +1064,17 @@ class MacroAssemblerCompat : public vixl
     void branchStackPtr(Condition cond, T rhs, Label* label) {
         branchPtr(cond, getStackPointer(), rhs, label);
     }
     template <typename T>
     void branchStackPtrRhs(Condition cond, T lhs, Label* label) {
         branchPtr(cond, lhs, getStackPointer(), label);
     }
 
-    void rshiftPtr(Imm32 imm, Register dest) {
-        Lsr(ARMRegister(dest, 64), ARMRegister(dest, 64), imm.value);
-    }
-    void rshiftPtr(Imm32 imm, Register src, Register dest) {
-        Lsr(ARMRegister(dest, 64), ARMRegister(src, 64), imm.value);
-    }
-    void rshift64(Imm32 imm, Register64 dest) {
-        rshiftPtr(imm, dest.reg);
-    }
+    inline void rshift64(Imm32 imm, Register64 dest);
 
     void rshiftPtrArithmetic(Imm32 imm, Register dest) {
         Asr(ARMRegister(dest, 64), ARMRegister(dest, 64), imm.value);
     }
     void lshiftPtr(Imm32 imm, Register dest) {
         Lsl(ARMRegister(dest, 64), ARMRegister(dest, 64), imm.value);
     }
     void lshift64(Imm32 imm, Register64 dest) {
--- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h
+++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h
@@ -120,15 +120,24 @@ MacroAssembler::xorPtr(Register src, Reg
 }
 
 void
 MacroAssembler::xorPtr(Imm32 imm, Register dest)
 {
     ma_xor(dest, imm);
 }
 
+// ===============================================================
+// Shift functions
+
+void
+MacroAssembler::rshiftPtr(Imm32 imm, Register dest)
+{
+    ma_srl(dest, dest, imm);
+}
+
 //}}} check_macroassembler_style
 // ===============================================================
 
 } // namespace jit
 } // namespace js
 
 #endif /* jit_mips32_MacroAssembler_mips32_inl_h */
--- a/js/src/jit/mips32/MacroAssembler-mips32.h
+++ b/js/src/jit/mips32/MacroAssembler-mips32.h
@@ -1344,19 +1344,16 @@ class MacroAssemblerMIPSCompat : public 
                      Label* label);
 
     void checkStackAlignment();
 
     void alignStackPointer();
     void restoreStackPointer();
     static void calculateAlignedStackPointer(void** stackPointer);
 
-    void rshiftPtr(Imm32 imm, Register dest) {
-        ma_srl(dest, dest, imm);
-    }
     void rshiftPtrArithmetic(Imm32 imm, Register dest) {
         ma_sra(dest, dest, imm);
     }
     void rshift64(Imm32 imm, Register64 dest) {
         as_srl(dest.low, dest.low, imm.value);
         as_sll(ScratchRegister, dest.high, 32 - imm.value);
         as_or(dest.low, dest.low, ScratchRegister);
         as_srl(dest.high, dest.high, imm.value);
--- a/js/src/jit/none/MacroAssembler-none.h
+++ b/js/src/jit/none/MacroAssembler-none.h
@@ -417,17 +417,16 @@ class MacroAssemblerNone : public Assemb
     void branchTestBooleanTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); }
     void branchTestStringTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); }
     void branchTestDoubleTruthy(bool, FloatRegister, Label*) { MOZ_CRASH(); }
 
     template <typename T> void loadUnboxedValue(T, MIRType, AnyRegister) { MOZ_CRASH(); }
     template <typename T> void storeUnboxedValue(ConstantOrRegister, MIRType, T, MIRType) { MOZ_CRASH(); }
     template <typename T> void storeUnboxedPayload(ValueOperand value, T, size_t) { MOZ_CRASH(); }
 
-    void rshiftPtr(Imm32, Register) { MOZ_CRASH(); }
     void rshiftPtrArithmetic(Imm32, Register) { MOZ_CRASH(); }
     void lshiftPtr(Imm32, Register) { MOZ_CRASH(); }
     void convertUInt32ToDouble(Register, FloatRegister) { MOZ_CRASH(); }
     void convertUInt32ToFloat32(Register, FloatRegister) { MOZ_CRASH(); }
     void inc64(AbsoluteAddress) { MOZ_CRASH(); }
     void incrementInt32Value(Address) { MOZ_CRASH(); }
     void ensureDouble(ValueOperand, FloatRegister, Label*) { MOZ_CRASH(); }
     void handleFailureWithHandlerTail(void*) { MOZ_CRASH(); }
--- a/js/src/jit/x64/MacroAssembler-x64-inl.h
+++ b/js/src/jit/x64/MacroAssembler-x64-inl.h
@@ -61,15 +61,24 @@ MacroAssembler::xorPtr(Register src, Reg
 }
 
 void
 MacroAssembler::xorPtr(Imm32 imm, Register dest)
 {
     xorq(imm, dest);
 }
 
+// ===============================================================
+// Shift functions
+
+void
+MacroAssembler::rshiftPtr(Imm32 imm, Register dest)
+{
+    shrq(imm, dest);
+}
+
 //}}} check_macroassembler_style
 // ===============================================================
 
 } // namespace jit
 } // namespace js
 
 #endif /* jit_x64_MacroAssembler_x64_inl_h */
--- a/js/src/jit/x64/MacroAssembler-x64.cpp
+++ b/js/src/jit/x64/MacroAssembler-x64.cpp
@@ -179,16 +179,26 @@ MacroAssemblerX64::finish()
           default: MOZ_CRASH("unexpected SimdConstant type");
         }
     }
 
     MacroAssemblerX86Shared::finish();
 }
 
 void
+MacroAssemblerX64::branchPrivatePtr(Condition cond, Address lhs, Register ptr, Label* label)
+{
+    ScratchRegisterScope scratch(asMasm());
+    if (ptr != scratch)
+        movePtr(ptr, scratch);
+    asMasm().rshiftPtr(Imm32(1), scratch);
+    branchPtr(cond, lhs, scratch, label);
+}
+
+void
 MacroAssemblerX64::handleFailureWithHandlerTail(void* handler)
 {
     // Reserve space for exception information.
     subq(Imm32(sizeof(ResumeFromException)), rsp);
     movq(rsp, rax);
 
     // Call the handler.
     asMasm().setupUnalignedABICall(rcx);
--- a/js/src/jit/x64/MacroAssembler-x64.h
+++ b/js/src/jit/x64/MacroAssembler-x64.h
@@ -687,24 +687,17 @@ class MacroAssemblerX64 : public MacroAs
         mov(AsmJSImmPtr(addr.kind()), scratch);
         branchPtr(cond, Operand(scratch, 0x0), ptr, label);
     }
 
     void branchPrivatePtr(Condition cond, Address lhs, ImmPtr ptr, Label* label) {
         branchPtr(cond, lhs, ImmWord(uintptr_t(ptr.value) >> 1), label);
     }
 
-    void branchPrivatePtr(Condition cond, Address lhs, Register ptr, Label* label) {
-        ScratchRegisterScope scratch(asMasm());
-        if (ptr != scratch)
-            movePtr(ptr, scratch);
-        rshiftPtr(Imm32(1), scratch);
-        branchPtr(cond, lhs, scratch, label);
-    }
-
+    void branchPrivatePtr(Condition cond, Address lhs, Register ptr, Label* label);
     template <typename T, typename S>
     void branchPtr(Condition cond, const T& lhs, const S& ptr, Label* label) {
         cmpPtr(Operand(lhs), ptr);
         j(cond, label);
     }
 
     CodeOffsetJump jumpWithPatch(RepatchLabel* label, Label* documentation = nullptr) {
         JmpSrc src = jmpSrc(label);
@@ -852,19 +845,16 @@ class MacroAssemblerX64 : public MacroAs
             ScratchRegisterScope scratch(asMasm());
             mov(ImmPtr(address.addr), scratch);
             store32(src, Address(scratch, 0x0));
         }
     }
     void store64(Register64 src, Address address) {
         movq(src.reg, Operand(address));
     }
-    void rshiftPtr(Imm32 imm, Register dest) {
-        shrq(imm, dest);
-    }
     void rshiftPtrArithmetic(Imm32 imm, Register dest) {
         sarq(imm, dest);
     }
     void rshift64(Imm32 imm, Register64 dest) {
         shrq(imm, dest.reg);
     }
     void lshiftPtr(Imm32 imm, Register dest) {
         shlq(imm, dest);
--- a/js/src/jit/x86/MacroAssembler-x86-inl.h
+++ b/js/src/jit/x86/MacroAssembler-x86-inl.h
@@ -62,15 +62,24 @@ MacroAssembler::xorPtr(Register src, Reg
 }
 
 void
 MacroAssembler::xorPtr(Imm32 imm, Register dest)
 {
     xorl(imm, dest);
 }
 
+// ===============================================================
+// Shift functions
+
+void
+MacroAssembler::rshiftPtr(Imm32 imm, Register dest)
+{
+    shrl(imm, dest);
+}
+
 //}}} check_macroassembler_style
 // ===============================================================
 
 } // namespace jit
 } // namespace js
 
 #endif /* jit_x86_MacroAssembler_x86_inl_h */
--- a/js/src/jit/x86/MacroAssembler-x86.h
+++ b/js/src/jit/x86/MacroAssembler-x86.h
@@ -1117,19 +1117,16 @@ class MacroAssemblerX86 : public MacroAs
             return;
           case 1:
             store8(value.payloadReg(), address);
             return;
           default: MOZ_CRASH("Bad payload width");
         }
     }
 
-    void rshiftPtr(Imm32 imm, Register dest) {
-        shrl(imm, dest);
-    }
     void rshiftPtrArithmetic(Imm32 imm, Register dest) {
         sarl(imm, dest);
     }
     void rshift64(Imm32 imm, Register64 dest) {
         shrdl(imm, dest.high, dest.low);
         shrl(imm, dest.high);
     }
     void lshiftPtr(Imm32 imm, Register dest) {