Bug 1229057 - Part 8: Move MacroAssembler::subPtr into generic macro assembler. r=lth
authorTooru Fujisawa <arai_a@mac.com>
Tue, 01 Dec 2015 17:03:07 +0900
changeset 316149 81fddea678a7bfea7225c96d00c25a149f52889e
parent 316148 39dc8792221d9205de8dd10a519e620841d6980c
child 316150 0d087c8f5c73979f28167cd39df8795836c39959
push id8516
push userjlund@mozilla.com
push dateFri, 18 Dec 2015 00:52:34 +0000
reviewerslth
bugs1229057
milestone46.0a1
Bug 1229057 - Part 8: Move MacroAssembler::subPtr into generic macro assembler. r=lth
js/src/jit/MacroAssembler.h
js/src/jit/arm/MacroAssembler-arm-inl.h
js/src/jit/arm/MacroAssembler-arm.cpp
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/mips-shared/MacroAssembler-mips-shared-inl.h
js/src/jit/mips32/MacroAssembler-mips32-inl.h
js/src/jit/mips32/MacroAssembler-mips32.cpp
js/src/jit/mips32/MacroAssembler-mips32.h
js/src/jit/mips64/MacroAssembler-mips64-inl.h
js/src/jit/mips64/MacroAssembler-mips64.cpp
js/src/jit/mips64/MacroAssembler-mips64.h
js/src/jit/none/MacroAssembler-none.h
js/src/jit/x64/MacroAssembler-x64-inl.h
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
@@ -753,16 +753,21 @@ class MacroAssembler : public MacroAssem
 
     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;
 
+    inline void subPtr(Register src, Register dest) PER_ARCH;
+    inline void subPtr(Register src, const Address& dest) DEFINED_ON(mips_shared, arm, arm64, x86, x64);
+    inline void subPtr(Imm32 imm, Register dest) PER_ARCH;
+    inline void subPtr(const Address& addr, Register dest) DEFINED_ON(mips_shared, arm, arm64, x86, x64);
+
     // ===============================================================
     // Shift functions
 
     inline void lshiftPtr(Imm32 imm, Register dest) PER_ARCH;
 
     inline void lshift64(Imm32 imm, Register64 dest) PER_ARCH;
 
     inline void rshiftPtr(Imm32 imm, Register dest) PER_ARCH;
--- a/js/src/jit/arm/MacroAssembler-arm-inl.h
+++ b/js/src/jit/arm/MacroAssembler-arm-inl.h
@@ -229,16 +229,45 @@ MacroAssembler::sub32(Imm32 imm, Registe
 void
 MacroAssembler::sub32(const Address& src, Register dest)
 {
     ScratchRegisterScope scratch(*this);
     load32(src, scratch);
     ma_sub(scratch, dest, SetCC);
 }
 
+void
+MacroAssembler::subPtr(Register src, Register dest)
+{
+    ma_sub(src, dest);
+}
+
+void
+MacroAssembler::subPtr(Register src, const Address& dest)
+{
+    ScratchRegisterScope scratch(*this);
+    loadPtr(dest, scratch);
+    ma_sub(src, scratch);
+    storePtr(scratch, dest);
+}
+
+void
+MacroAssembler::subPtr(Imm32 imm, Register dest)
+{
+    ma_sub(imm, dest);
+}
+
+void
+MacroAssembler::subPtr(const Address& addr, Register dest)
+{
+    ScratchRegisterScope scratch(*this);
+    loadPtr(addr, scratch);
+    ma_sub(scratch, dest);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     ma_lsl(imm, dest, dest);
 }
@@ -283,12 +312,19 @@ MacroAssemblerARMCompat::branchAdd32(Con
 }
 
 void
 MacroAssemblerARMCompat::incrementInt32Value(const Address& addr)
 {
     asMasm().add32(Imm32(1), ToPayload(addr));
 }
 
+void
+MacroAssemblerARMCompat::decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label)
+{
+    asMasm().subPtr(imm, lhs);
+    branch32(cond, lhs, Imm32(0), label);
+}
+
 } // namespace jit
 } // namespace js
 
 #endif /* jit_arm_MacroAssembler_arm_inl_h */
--- a/js/src/jit/arm/MacroAssembler-arm.cpp
+++ b/js/src/jit/arm/MacroAssembler-arm.cpp
@@ -2581,45 +2581,16 @@ MacroAssemblerARMCompat::cmpPtr(const Ad
 void
 MacroAssemblerARMCompat::setStackArg(Register reg, uint32_t arg)
 {
     ma_dataTransferN(IsStore, 32, true, sp, Imm32(arg * sizeof(intptr_t)), reg);
 
 }
 
 void
-MacroAssemblerARMCompat::subPtr(Imm32 imm, const Register dest)
-{
-    ma_sub(imm, dest);
-}
-
-void
-MacroAssemblerARMCompat::subPtr(const Address& addr, const Register dest)
-{
-    ScratchRegisterScope scratch(asMasm());
-    loadPtr(addr, scratch);
-    ma_sub(scratch, dest);
-}
-
-void
-MacroAssemblerARMCompat::subPtr(Register src, Register dest)
-{
-    ma_sub(src, dest);
-}
-
-void
-MacroAssemblerARMCompat::subPtr(Register src, const Address& dest)
-{
-    ScratchRegisterScope scratch(asMasm());
-    loadPtr(dest, scratch);
-    ma_sub(src, scratch);
-    storePtr(scratch, dest);
-}
-
-void
 MacroAssemblerARMCompat::compareDouble(FloatRegister lhs, FloatRegister rhs)
 {
     // Compare the doubles, setting vector status flags.
     if (rhs.isMissing())
         ma_vcmpz(lhs);
     else
         ma_vcmp(lhs, rhs);
 
--- a/js/src/jit/arm/MacroAssembler-arm.h
+++ b/js/src/jit/arm/MacroAssembler-arm.h
@@ -976,20 +976,17 @@ class MacroAssemblerARMCompat : public M
     void branchPtr(Condition cond, Register lhs, wasm::SymbolicAddress imm, Label* label) {
         ScratchRegisterScope scratch(asMasm());
         movePtr(imm, scratch);
         branchPtr(cond, lhs, scratch, label);
     }
     void branchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
         branch32(cond, lhs, imm, label);
     }
-    void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
-        subPtr(imm, lhs);
-        branch32(cond, lhs, Imm32(0), label);
-    }
+    inline void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label);
     void branchTest64(Condition cond, Register64 lhs, Register64 rhs, Register temp, Label* label);
     void moveValue(const Value& val, Register type, Register data);
 
     CodeOffsetJump jumpWithPatch(RepatchLabel* label, Condition cond = Always,
                                  Label* documentation = nullptr);
     CodeOffsetJump backedgeJump(RepatchLabel* label, Label* documentation) {
         return jumpWithPatch(label, Always, documentation);
     }
@@ -1630,20 +1627,16 @@ class MacroAssemblerARMCompat : public M
     void cmpPtr(Register lhs, ImmGCPtr rhs);
     void cmpPtr(Register lhs, Imm32 rhs);
     void cmpPtr(const Address& lhs, Register rhs);
     void cmpPtr(const Address& lhs, ImmWord rhs);
     void cmpPtr(const Address& lhs, ImmPtr rhs);
     void cmpPtr(const Address& lhs, ImmGCPtr rhs);
     void cmpPtr(const Address& lhs, Imm32 rhs);
 
-    void subPtr(Imm32 imm, const Register dest);
-    void subPtr(const Address& addr, const Register dest);
-    void subPtr(Register src, Register dest);
-    void subPtr(Register src, const Address& dest);
     void mulBy3(const Register& src, const Register& dest) {
         as_add(dest, src, lsl(src, 1));
     }
     void mul64(Imm64 imm, const Register64& dest) {
         // LOW32  = LOW(LOW(dest) * LOW(imm));
         // HIGH32 = LOW(HIGH(dest) * LOW(imm)) [multiply imm into upper bits]
         //        + LOW(LOW(dest) * HIGH(imm)) [multiply dest into upper bits]
         //        + HIGH(LOW(dest) * LOW(imm)) [carry]
--- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h
+++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h
@@ -262,16 +262,51 @@ MacroAssembler::sub32(const Address& src
 {
     vixl::UseScratchRegisterScope temps(this);
     const ARMRegister scratch32 = temps.AcquireW();
     MOZ_ASSERT(scratch32.asUnsized() != src.base);
     load32(src, scratch32.asUnsized());
     Sub(ARMRegister(dest, 32), ARMRegister(dest, 32), Operand(scratch32));
 }
 
+void
+MacroAssembler::subPtr(Register src, Register dest)
+{
+    Sub(ARMRegister(dest, 64), ARMRegister(dest, 64), Operand(ARMRegister(src, 64)));
+}
+
+void
+MacroAssembler::subPtr(Register src, const Address& dest)
+{
+    vixl::UseScratchRegisterScope temps(this);
+    const ARMRegister scratch64 = temps.AcquireX();
+    MOZ_ASSERT(scratch64.asUnsized() != dest.base);
+
+    Ldr(scratch64, MemOperand(ARMRegister(dest.base, 64), dest.offset));
+    Sub(scratch64, scratch64, Operand(ARMRegister(src, 64)));
+    Str(scratch64, MemOperand(ARMRegister(dest.base, 64), dest.offset));
+}
+
+void
+MacroAssembler::subPtr(Imm32 imm, Register dest)
+{
+    Sub(ARMRegister(dest, 64), ARMRegister(dest, 64), Operand(imm.value));
+}
+
+void
+MacroAssembler::subPtr(const Address& addr, Register dest)
+{
+    vixl::UseScratchRegisterScope temps(this);
+    const ARMRegister scratch64 = temps.AcquireX();
+    MOZ_ASSERT(scratch64.asUnsized() != addr.base);
+
+    Ldr(scratch64, MemOperand(ARMRegister(addr.base, 64), addr.offset));
+    Sub(ARMRegister(dest, 64), ARMRegister(dest, 64), Operand(scratch64));
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     Lsl(ARMRegister(dest, 64), ARMRegister(dest, 64), imm.value);
 }
@@ -320,16 +355,30 @@ template <typename T>
 void
 MacroAssemblerCompat::addStackPtrTo(T t)
 {
     asMasm().addPtr(getStackPointer(), t);
 }
 
 template <typename T>
 void
+MacroAssemblerCompat::subFromStackPtr(T t)
+{
+    asMasm().subPtr(t, getStackPointer()); syncStackPtr();
+}
+
+template <typename T>
+void
+MacroAssemblerCompat::subStackPtrFrom(T t)
+{
+    asMasm().subPtr(getStackPointer(), t);
+}
+
+template <typename T>
+void
 MacroAssemblerCompat::andToStackPtr(T t)
 {
     asMasm().andPtr(t, getStackPointer());
     syncStackPtr();
 }
 
 template <typename T>
 void
--- a/js/src/jit/arm64/MacroAssembler-arm64.h
+++ b/js/src/jit/arm64/MacroAssembler-arm64.h
@@ -1027,20 +1027,18 @@ class MacroAssemblerCompat : public vixl
     void loadUnalignedFloat32x4(const BaseIndex& addr, FloatRegister dest) { MOZ_CRASH("NYI"); }
     void storeUnalignedFloat32x4(FloatRegister dest, const Address& addr) { MOZ_CRASH("NYI"); }
     void storeUnalignedFloat32x4(FloatRegister dest, const BaseIndex& addr) { MOZ_CRASH("NYI"); }
 
     // StackPointer manipulation.
     template <typename T> void addToStackPtr(T t);
     template <typename T> void addStackPtrTo(T t);
 
-    template <typename T>
-    void subFromStackPtr(T t) { subPtr(t, getStackPointer()); syncStackPtr(); }
-    template <typename T>
-    void subStackPtrFrom(T t) { subPtr(getStackPointer(), t); }
+    template <typename T> inline void subFromStackPtr(T t);
+    template <typename T> inline void subStackPtrFrom(T t);
 
     template <typename T> void andToStackPtr(T t);
     template <typename T> void andStackPtrTo(T t);
 
     template <typename T>
     void moveToStackPtr(T t) { movePtr(t, getStackPointer()); syncStackPtr(); }
     template <typename T>
     void moveStackPtrTo(T t) { movePtr(getStackPointer(), t); }
@@ -1341,39 +1339,16 @@ class MacroAssemblerCompat : public vixl
 
     void subs32(Imm32 imm, Register dest) {
         Subs(ARMRegister(dest, 32), ARMRegister(dest, 32), Operand(imm.value));
     }
     void subs32(Register src, Register dest) {
         Subs(ARMRegister(dest, 32), ARMRegister(dest, 32), Operand(ARMRegister(src, 32)));
     }
 
-    void subPtr(Imm32 imm, Register dest) {
-        Sub(ARMRegister(dest, 64), ARMRegister(dest, 64), Operand(imm.value));
-    }
-    void subPtr(Register src, Register dest) {
-        Sub(ARMRegister(dest, 64), ARMRegister(dest, 64), Operand(ARMRegister(src, 64)));
-    }
-    void subPtr(const Address& addr, Register dest) {
-        vixl::UseScratchRegisterScope temps(this);
-        const ARMRegister scratch64 = temps.AcquireX();
-        MOZ_ASSERT(scratch64.asUnsized() != addr.base);
-
-        Ldr(scratch64, MemOperand(ARMRegister(addr.base, 64), addr.offset));
-        Sub(ARMRegister(dest, 64), ARMRegister(dest, 64), Operand(scratch64));
-    }
-    void subPtr(Register src, const Address& dest) {
-        vixl::UseScratchRegisterScope temps(this);
-        const ARMRegister scratch64 = temps.AcquireX();
-        MOZ_ASSERT(scratch64.asUnsized() != dest.base);
-
-        Ldr(scratch64, MemOperand(ARMRegister(dest.base, 64), dest.offset));
-        Sub(scratch64, scratch64, Operand(ARMRegister(src, 64)));
-        Str(scratch64, MemOperand(ARMRegister(dest.base, 64), dest.offset));
-    }
     void mul32(Register src1, Register src2, Register dest, Label* onOver, Label* onZero) {
         Smull(ARMRegister(dest, 64), ARMRegister(src1, 32), ARMRegister(src2, 32));
         if (onOver) {
             Cmp(ARMRegister(dest, 64), Operand(ARMRegister(dest, 32), vixl::SXTW));
             B(onOver, NotEqual);
         }
         if (onZero)
             Cbz(ARMRegister(dest, 32), onZero);
--- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h
+++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h
@@ -133,15 +133,30 @@ MacroAssembler::sub32(Imm32 imm, Registe
 
 void
 MacroAssembler::sub32(const Address& src, Register dest)
 {
     load32(src, SecondScratchReg);
     as_subu(dest, dest, SecondScratchReg);
 }
 
+void
+MacroAssembler::subPtr(Register src, const Address& dest)
+{
+    loadPtr(dest, SecondScratchReg);
+    subPtr(src, SecondScratchReg);
+    storePtr(SecondScratchReg, dest);
+}
+
+void
+MacroAssembler::subPtr(const Address& addr, Register dest)
+{
+    loadPtr(addr, SecondScratchReg);
+    subPtr(SecondScratchReg, dest);
+}
+
 //}}} check_macroassembler_style
 // ===============================================================
 
 } // namespace jit
 } // namespace js
 
 #endif /* jit_mips_shared_MacroAssembler_mips_shared_inl_h */
--- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h
+++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h
@@ -108,16 +108,28 @@ MacroAssembler::add64(Register64 src, Re
 void
 MacroAssembler::add64(Imm32 imm, Register64 dest)
 {
     as_addiu(dest.low, dest.low, imm.value);
     as_sltiu(ScratchRegister, dest.low, imm.value);
     as_addu(dest.high, dest.high, ScratchRegister);
 }
 
+void
+MacroAssembler::subPtr(Register src, Register dest)
+{
+    as_subu(dest, dest, src);
+}
+
+void
+MacroAssembler::subPtr(Imm32 imm, Register dest)
+{
+    ma_subu(dest, dest, imm);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     ma_sll(dest, dest, imm);
 }
@@ -175,12 +187,19 @@ void
 MacroAssemblerMIPSCompat::retn(Imm32 n) {
     // pc <- [sp]; sp += n
     loadPtr(Address(StackPointer, 0), ra);
     asMasm().addPtr(n, StackPointer);
     as_jr(ra);
     as_nop();
 }
 
+void
+MacroAssemblerMIPSCompat::decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label)
+{
+    asMasm().subPtr(imm, lhs);
+    branchPtr(cond, lhs, Imm32(0), label);
+}
+
 } // namespace jit
 } // namespace js
 
 #endif /* jit_mips32_MacroAssembler_mips32_inl_h */
--- a/js/src/jit/mips32/MacroAssembler-mips32.cpp
+++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp
@@ -802,22 +802,16 @@ MacroAssemblerMIPSCompat::buildOOLFakeEx
 
     asMasm().Push(Imm32(descriptor)); // descriptor_
     asMasm().Push(ImmPtr(fakeReturnAddr));
 
     return true;
 }
 
 void
-MacroAssemblerMIPSCompat::subPtr(Register src, Register dest)
-{
-    as_subu(dest, dest, src);
-}
-
-void
 MacroAssemblerMIPSCompat::move32(Imm32 imm, Register dest)
 {
     ma_li(dest, imm);
 }
 
 void
 MacroAssemblerMIPSCompat::move32(Register src, Register dest)
 {
@@ -1197,37 +1191,16 @@ MacroAssembler::clampDoubleToUint8(Float
     {
         move32(Imm32(255), output);
     }
 
     bind(&done);
 }
 
 void
-MacroAssemblerMIPSCompat::subPtr(Imm32 imm, const Register dest)
-{
-    ma_subu(dest, dest, imm);
-}
-
-void
-MacroAssemblerMIPSCompat::subPtr(const Address& addr, const Register dest)
-{
-    loadPtr(addr, SecondScratchReg);
-    subPtr(SecondScratchReg, dest);
-}
-
-void
-MacroAssemblerMIPSCompat::subPtr(Register src, const Address& dest)
-{
-    loadPtr(dest, SecondScratchReg);
-    subPtr(src, SecondScratchReg);
-    storePtr(SecondScratchReg, dest);
-}
-
-void
 MacroAssemblerMIPSCompat::branchDouble(DoubleCondition cond, FloatRegister lhs,
                                        FloatRegister rhs, Label* label)
 {
     ma_bc1d(lhs, rhs, label, cond);
 }
 
 void
 MacroAssemblerMIPSCompat::branchFloat(DoubleCondition cond, FloatRegister lhs,
@@ -2116,17 +2089,17 @@ MacroAssemblerMIPSCompat::tagValue(JSVal
     if (payload != dest.payloadReg())
         ma_move(dest.payloadReg(), payload);
 }
 
 void
 MacroAssemblerMIPSCompat::pushValue(ValueOperand val)
 {
     // Allocate stack slots for type and payload. One for each.
-    subPtr(Imm32(sizeof(Value)), StackPointer);
+    asMasm().subPtr(Imm32(sizeof(Value)), StackPointer);
     // Store type and payload.
     storeValue(val, Address(StackPointer, 0));
 }
 
 void
 MacroAssemblerMIPSCompat::pushValue(const Address& addr)
 {
     // Allocate stack slots for type and payload. One for each.
@@ -2234,17 +2207,17 @@ MacroAssemblerMIPSCompat::checkStackAlig
     bind(&aligned);
 #endif
 }
 
 void
 MacroAssemblerMIPSCompat::alignStackPointer()
 {
     movePtr(StackPointer, SecondScratchReg);
-    subPtr(Imm32(sizeof(uintptr_t)), StackPointer);
+    asMasm().subPtr(Imm32(sizeof(uintptr_t)), StackPointer);
     asMasm().andPtr(Imm32(~(ABIStackAlignment - 1)), StackPointer);
     storePtr(SecondScratchReg, Address(StackPointer, 0));
 }
 
 void
 MacroAssemblerMIPSCompat::restoreStackPointer()
 {
     loadPtr(Address(StackPointer, 0), StackPointer);
@@ -2270,17 +2243,17 @@ MacroAssembler::restoreFrameAlignmentFor
         freeStack(aic.alignmentPadding);
 }
 
 void
 MacroAssemblerMIPSCompat::handleFailureWithHandlerTail(void* handler)
 {
     // Reserve space for exception information.
     int size = (sizeof(ResumeFromException) + ABIStackAlignment) & ~(ABIStackAlignment - 1);
-    subPtr(Imm32(size), StackPointer);
+    asMasm().subPtr(Imm32(size), StackPointer);
     ma_move(a0, StackPointer); // Use a0 since it is a first function argument
 
     // Call the handler.
     asMasm().setupUnalignedABICall(a1);
     asMasm().passABIArg(a0);
     asMasm().callWithABI(handler);
 
     Label entryFrame;
@@ -2588,33 +2561,33 @@ MacroAssembler::PopRegsInMaskIgnore(Live
     freeStack(reservedG);
     MOZ_ASSERT(diffG == 0);
 }
 
 void
 MacroAssembler::reserveStack(uint32_t amount)
 {
     if (amount)
-        subPtr(Imm32(amount), StackPointer);
+        asMasm().subPtr(Imm32(amount), StackPointer);
     adjustFrame(amount);
 }
 
 // ===============================================================
 // ABI function calls.
 
 void
 MacroAssembler::setupUnalignedABICall(Register scratch)
 {
     setupABICall();
     dynamicAlignment_ = true;
 
     ma_move(scratch, StackPointer);
 
     // Force sp to be aligned
-    subPtr(Imm32(sizeof(uintptr_t)), StackPointer);
+    asMasm().subPtr(Imm32(sizeof(uintptr_t)), StackPointer);
     ma_and(StackPointer, StackPointer, Imm32(~(ABIStackAlignment - 1)));
     storePtr(scratch, Address(StackPointer, 0));
 }
 
 void
 MacroAssembler::callWithABIPre(uint32_t* stackAdjust, bool callFromAsmJS)
 {
     MOZ_ASSERT(inCall_);
--- a/js/src/jit/mips32/MacroAssembler-mips32.h
+++ b/js/src/jit/mips32/MacroAssembler-mips32.h
@@ -549,20 +549,17 @@ class MacroAssemblerMIPSCompat : public 
     }
     void branchPtr(Condition cond, Register lhs, wasm::SymbolicAddress imm, Label* label) {
         movePtr(imm, SecondScratchReg);
         ma_b(lhs, SecondScratchReg, label, cond);
     }
     void branchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
         ma_b(lhs, imm, label, cond);
     }
-    void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
-        subPtr(imm, lhs);
-        branchPtr(cond, lhs, Imm32(0), label);
-    }
+    inline void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label);
 
     // higher level tag testing code
     Operand ToPayload(Operand base);
     Address ToPayload(Address base) {
         return ToPayload(Operand(base)).toAddress();
     }
 
   protected:
@@ -1083,18 +1080,16 @@ class MacroAssemblerMIPSCompat : public 
             ma_subu(dest, src);
             ma_b(dest, dest, overflow, cond);
             break;
           default:
             MOZ_CRASH("NYI");
         }
     }
 
-    void subPtr(Register src, Register dest);
-
     void move32(Imm32 imm, Register dest);
     void move32(Register src, Register dest);
     void move64(Register64 src, Register64 dest) {
         move32(src.low, dest.low);
         move32(src.high, dest.high);
     }
 
     void movePtr(Register src, Register dest);
@@ -1225,19 +1220,16 @@ class MacroAssemblerMIPSCompat : public 
 
     void zeroDouble(FloatRegister reg) {
         moveToDoubleLo(zero, reg);
         moveToDoubleHi(zero, reg);
     }
 
     void clampIntToUint8(Register reg);
 
-    void subPtr(Imm32 imm, const Register dest);
-    void subPtr(const Address& addr, const Register dest);
-    void subPtr(Register src, const Address& dest);
     void mulBy3(const Register& src, const Register& dest) {
         as_addu(dest, src, src);
         as_addu(dest, dest, src);
     }
 
     void mul64(Imm64 imm, const Register64& dest);
 
     void convertUInt64ToDouble(Register64 src, Register temp, FloatRegister dest);
--- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h
+++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h
@@ -102,16 +102,28 @@ MacroAssembler::add64(Register64 src, Re
 }
 
 void
 MacroAssembler::add64(Imm32 imm, Register64 dest)
 {
     ma_daddu(dest.reg, imm);
 }
 
+void
+MacroAssembler::subPtr(Register src, Register dest)
+{
+    as_dsubu(dest, dest, src);
+}
+
+void
+MacroAssembler::subPtr(Imm32 imm, Register dest)
+{
+    ma_dsubu(dest, dest, imm);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     ma_dsll(dest, dest, imm);
 }
@@ -162,12 +174,19 @@ MacroAssemblerMIPS64Compat::retn(Imm32 n
 {
     // pc <- [sp]; sp += n
     loadPtr(Address(StackPointer, 0), ra);
     asMasm().addPtr(n, StackPointer);
     as_jr(ra);
     as_nop();
 }
 
+void
+MacroAssemblerMIPS64Compat::decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label)
+{
+    asMasm().subPtr(imm, lhs);
+    branchPtr(cond, lhs, Imm32(0), label);
+}
+
 } // namespace jit
 } // namespace js
 
 #endif /* jit_mips64_MacroAssembler_mips64_inl_h */
--- a/js/src/jit/mips64/MacroAssembler-mips64.cpp
+++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp
@@ -887,22 +887,16 @@ MacroAssemblerMIPS64Compat::buildOOLFake
 
     asMasm().Push(Imm32(descriptor)); // descriptor_
     asMasm().Push(ImmPtr(fakeReturnAddr));
 
     return true;
 }
 
 void
-MacroAssemblerMIPS64Compat::subPtr(Register src, Register dest)
-{
-    as_dsubu(dest, dest, src);
-}
-
-void
 MacroAssemblerMIPS64Compat::move32(Imm32 imm, Register dest)
 {
     ma_li(dest, imm);
 }
 
 void
 MacroAssemblerMIPS64Compat::move32(Register src, Register dest)
 {
@@ -1283,37 +1277,16 @@ MacroAssembler::clampDoubleToUint8(Float
     {
         move32(Imm32(255), output);
     }
 
     bind(&done);
 }
 
 void
-MacroAssemblerMIPS64Compat::subPtr(Imm32 imm, const Register dest)
-{
-    ma_dsubu(dest, dest, imm);
-}
-
-void
-MacroAssemblerMIPS64Compat::subPtr(const Address& addr, const Register dest)
-{
-    loadPtr(addr, SecondScratchReg);
-    subPtr(SecondScratchReg, dest);
-}
-
-void
-MacroAssemblerMIPS64Compat::subPtr(Register src, const Address& dest)
-{
-    loadPtr(dest, SecondScratchReg);
-    subPtr(src, SecondScratchReg);
-    storePtr(SecondScratchReg, dest);
-}
-
-void
 MacroAssemblerMIPS64Compat::branchDouble(DoubleCondition cond, FloatRegister lhs,
                                          FloatRegister rhs, Label* label)
 {
     ma_bc1d(lhs, rhs, label, cond);
 }
 
 void
 MacroAssemblerMIPS64Compat::branchFloat(DoubleCondition cond, FloatRegister lhs,
@@ -2265,17 +2238,17 @@ MacroAssemblerMIPS64Compat::tagValue(JSV
     ma_li(ScratchRegister, ImmTag(JSVAL_TYPE_TO_TAG(type)));
     ma_dins(dest.valueReg(), ScratchRegister, Imm32(JSVAL_TAG_SHIFT), Imm32(64 - JSVAL_TAG_SHIFT));
 }
 
 void
 MacroAssemblerMIPS64Compat::pushValue(ValueOperand val)
 {
     // Allocate stack slots for Value. One for each.
-    subPtr(Imm32(sizeof(Value)), StackPointer);
+    asMasm().subPtr(Imm32(sizeof(Value)), StackPointer);
     // Store Value
     storeValue(val, Address(StackPointer, 0));
 }
 
 void
 MacroAssemblerMIPS64Compat::pushValue(const Address& addr)
 {
     // Load value before allocate stack, addr.base may be is sp.
@@ -2373,17 +2346,17 @@ MacroAssembler::restoreFrameAlignmentFor
         freeStack(aic.alignmentPadding);
 }
 
 void
 MacroAssemblerMIPS64Compat::handleFailureWithHandlerTail(void* handler)
 {
     // Reserve space for exception information.
     int size = (sizeof(ResumeFromException) + ABIStackAlignment) & ~(ABIStackAlignment - 1);
-    subPtr(Imm32(size), StackPointer);
+    asMasm().subPtr(Imm32(size), StackPointer);
     ma_move(a0, StackPointer); // Use a0 since it is a first function argument
 
     // Call the handler.
     asMasm().setupUnalignedABICall(a1);
     asMasm().passABIArg(a0);
     asMasm().callWithABI(handler);
 
     Label entryFrame;
@@ -2676,33 +2649,33 @@ MacroAssembler::PopRegsInMaskIgnore(Live
     MOZ_ASSERT(diff == 0);
     freeStack(reserved);
 }
 
 void
 MacroAssembler::reserveStack(uint32_t amount)
 {
     if (amount)
-        subPtr(Imm32(amount), StackPointer);
+        asMasm().subPtr(Imm32(amount), StackPointer);
     adjustFrame(amount);
 }
 
 // ===============================================================
 // ABI function calls.
 
 void
 MacroAssembler::setupUnalignedABICall(Register scratch)
 {
     setupABICall();
     dynamicAlignment_ = true;
 
     ma_move(scratch, StackPointer);
 
     // Force sp to be aligned
-    subPtr(Imm32(sizeof(uintptr_t)), StackPointer);
+    asMasm().subPtr(Imm32(sizeof(uintptr_t)), StackPointer);
     ma_and(StackPointer, StackPointer, Imm32(~(ABIStackAlignment - 1)));
     storePtr(scratch, Address(StackPointer, 0));
 }
 
 void
 MacroAssembler::callWithABIPre(uint32_t* stackAdjust, bool callFromAsmJS)
 {
     MOZ_ASSERT(inCall_);
--- a/js/src/jit/mips64/MacroAssembler-mips64.h
+++ b/js/src/jit/mips64/MacroAssembler-mips64.h
@@ -593,20 +593,17 @@ class MacroAssemblerMIPS64Compat : publi
     }
     void branchPtr(Condition cond, Register lhs, wasm::SymbolicAddress imm, Label* label) {
         movePtr(imm, SecondScratchReg);
         ma_b(lhs, SecondScratchReg, label, cond);
     }
     void branchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
         ma_b(lhs, imm, label, cond);
     }
-    void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
-        subPtr(imm, lhs);
-        branchPtr(cond, lhs, Imm32(0), label);
-    }
+    inline void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label);
 
     // higher level tag testing code
     Address ToPayload(Address value) {
         return value;
     }
 
     void moveValue(const Value& val, Register dest);
 
@@ -1100,18 +1097,16 @@ class MacroAssemblerMIPS64Compat : publi
             ma_subu(dest, src);
             ma_b(dest, dest, overflow, cond);
             break;
           default:
             MOZ_CRASH("NYI");
         }
     }
 
-    void subPtr(Register src, Register dest);
-
     void move32(Imm32 imm, Register dest);
     void move32(Register src, Register dest);
     void move64(Register64 src, Register64 dest) {
         movePtr(src.reg, dest.reg);
     }
 
     void movePtr(Register src, Register dest);
     void movePtr(ImmWord imm, Register dest);
@@ -1238,19 +1233,16 @@ class MacroAssemblerMIPS64Compat : publi
     }
 
     void zeroDouble(FloatRegister reg) {
         moveToDouble(zero, reg);
     }
 
     void clampIntToUint8(Register reg);
 
-    void subPtr(Imm32 imm, const Register dest);
-    void subPtr(const Address& addr, const Register dest);
-    void subPtr(Register src, const Address& dest);
     void mulBy3(const Register& src, const Register& dest) {
         as_daddu(dest, src, src);
         as_daddu(dest, dest, src);
     }
 
     void mul64(Imm64 imm, const Register64& dest) {
         MOZ_ASSERT(dest.reg != ScratchRegister);
         mov(ImmWord(imm.value), ScratchRegister);
--- a/js/src/jit/none/MacroAssembler-none.h
+++ b/js/src/jit/none/MacroAssembler-none.h
@@ -229,17 +229,16 @@ class MacroAssemblerNone : public Assemb
     template <typename T, typename S> void branchTestValue(Condition, T, S, Label*) { MOZ_CRASH(); }
     void testNullSet(Condition, ValueOperand, Register) { MOZ_CRASH(); }
     void testObjectSet(Condition, ValueOperand, Register) { MOZ_CRASH(); }
     void testUndefinedSet(Condition, ValueOperand, Register) { MOZ_CRASH(); }
 
     template <typename T, typename S> void cmpPtrSet(Condition, T, S, Register) { MOZ_CRASH(); }
     template <typename T, typename S> void cmp32Set(Condition, T, S, Register) { MOZ_CRASH(); }
 
-    template <typename T, typename S> void subPtr(T, S) { MOZ_CRASH(); }
     void neg32(Register) { MOZ_CRASH(); }
     void mulBy3(Register, Register) { MOZ_CRASH(); }
     void mul64(Imm64, const Register64&) { MOZ_CRASH(); }
 
     void negateDouble(FloatRegister) { MOZ_CRASH(); }
     void subDouble(FloatRegister, FloatRegister) { MOZ_CRASH(); }
     void mulDouble(FloatRegister, FloatRegister) { MOZ_CRASH(); }
     void divDouble(FloatRegister, FloatRegister) { MOZ_CRASH(); }
--- a/js/src/jit/x64/MacroAssembler-x64-inl.h
+++ b/js/src/jit/x64/MacroAssembler-x64-inl.h
@@ -125,16 +125,40 @@ MacroAssembler::add64(Register64 src, Re
 }
 
 void
 MacroAssembler::add64(Imm32 imm, Register64 dest)
 {
     addq(imm, dest.reg);
 }
 
+void
+MacroAssembler::subPtr(Register src, Register dest)
+{
+    subq(src, dest);
+}
+
+void
+MacroAssembler::subPtr(Register src, const Address& dest)
+{
+    subq(src, Operand(dest));
+}
+
+void
+MacroAssembler::subPtr(Imm32 imm, Register dest)
+{
+    subq(imm, dest);
+}
+
+void
+MacroAssembler::subPtr(const Address& addr, Register dest)
+{
+    subq(Operand(addr), dest);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     shlq(imm, dest);
 }
--- a/js/src/jit/x64/MacroAssembler-x64.h
+++ b/js/src/jit/x64/MacroAssembler-x64.h
@@ -538,28 +538,16 @@ class MacroAssemblerX64 : public MacroAs
         cmpPtr(lhs, rhs);
         emitSet(cond, dest);
     }
 
     /////////////////////////////////////////////////////////////////
     // Common interface.
     /////////////////////////////////////////////////////////////////
 
-    void subPtr(Imm32 imm, Register dest) {
-        subq(imm, dest);
-    }
-    void subPtr(Register src, Register dest) {
-        subq(src, dest);
-    }
-    void subPtr(const Address& addr, Register dest) {
-        subq(Operand(addr), dest);
-    }
-    void subPtr(Register src, const Address& dest) {
-        subq(src, Operand(dest));
-    }
     void mulBy3(const Register& src, const Register& dest) {
         lea(Operand(src, src, TimesTwo), dest);
     }
     void mul64(Imm64 imm, const Register64& dest) {
         movq(ImmWord(uintptr_t(imm.value)), ScratchReg);
         imulq(ScratchReg, dest.reg);
     }
 
@@ -668,17 +656,17 @@ class MacroAssemblerX64 : public MacroAs
         testPtr(lhs, imm);
         j(cond, label);
     }
     void branchTestPtr(Condition cond, const Address& lhs, Imm32 imm, Label* label) {
         testPtr(Operand(lhs), imm);
         j(cond, label);
     }
     void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
-        subPtr(imm, lhs);
+        subq(imm, lhs);
         j(cond, label);
     }
 
     void branchTest64(Condition cond, Register64 lhs, Register64 rhs, Register temp, Label* label) {
         branchTestPtr(cond, lhs.reg, rhs.reg, label);
     }
 
     void movePtr(Register src, Register dest) {
--- a/js/src/jit/x86/MacroAssembler-x86-inl.h
+++ b/js/src/jit/x86/MacroAssembler-x86-inl.h
@@ -133,16 +133,40 @@ MacroAssembler::addConstantDouble(double
 {
     Double* dbl = getDouble(d);
     if (!dbl)
         return;
     masm.vaddsd_mr(nullptr, dest.encoding(), dest.encoding());
     propagateOOM(dbl->uses.append(CodeOffset(masm.size())));
 }
 
+void
+MacroAssembler::subPtr(Register src, Register dest)
+{
+    subl(src, dest);
+}
+
+void
+MacroAssembler::subPtr(Register src, const Address& dest)
+{
+    subl(src, Operand(dest));
+}
+
+void
+MacroAssembler::subPtr(Imm32 imm, Register dest)
+{
+    subl(imm, dest);
+}
+
+void
+MacroAssembler::subPtr(const Address& addr, Register dest)
+{
+    subl(Operand(addr), dest);
+}
+
 // ===============================================================
 // Shift functions
 
 void
 MacroAssembler::lshiftPtr(Imm32 imm, Register dest)
 {
     shll(imm, dest);
 }
--- a/js/src/jit/x86/MacroAssembler-x86.h
+++ b/js/src/jit/x86/MacroAssembler-x86.h
@@ -561,28 +561,16 @@ class MacroAssemblerX86 : public MacroAs
         cmpPtr(lhs, rhs);
         emitSet(cond, dest);
     }
 
     /////////////////////////////////////////////////////////////////
     // Common interface.
     /////////////////////////////////////////////////////////////////
 
-    void subPtr(Imm32 imm, Register dest) {
-        subl(imm, dest);
-    }
-    void subPtr(Register src, Register dest) {
-        subl(src, dest);
-    }
-    void subPtr(const Address& addr, Register dest) {
-        subl(Operand(addr), dest);
-    }
-    void subPtr(Register src, const Address& dest) {
-        subl(src, Operand(dest));
-    }
     void mulBy3(const Register& src, const Register& dest) {
         lea(Operand(src, src, TimesTwo), dest);
     }
     // Note: this function clobbers eax and edx.
     void mul64(Imm64 imm, const Register64& dest) {
         // LOW32  = LOW(LOW(dest) * LOW(imm));
         // HIGH32 = LOW(HIGH(dest) * LOW(imm)) [multiply imm into upper bits]
         //        + LOW(LOW(dest) * HIGH(imm)) [multiply dest into upper bits]
@@ -693,17 +681,17 @@ class MacroAssemblerX86 : public MacroAs
         testPtr(lhs, imm);
         j(cond, label);
     }
     void branchTestPtr(Condition cond, const Address& lhs, Imm32 imm, Label* label) {
         testPtr(Operand(lhs), imm);
         j(cond, label);
     }
     void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
-        subPtr(imm, lhs);
+        subl(imm, lhs);
         j(cond, label);
     }
 
     void branchTest64(Condition cond, Register64 lhs, Register64 rhs, Register temp, Label* label) {
         if (cond == Assembler::Zero) {
             MOZ_ASSERT(lhs.low == rhs.low);
             MOZ_ASSERT(lhs.high == rhs.high);
             movl(lhs.low, temp);