diff --git a/js/src/jit/MacroAssembler-inl.h b/js/src/jit/MacroAssembler-inl.h index f02ce4c6054..a4c871b8fd2 100644 --- a/js/src/jit/MacroAssembler-inl.h +++ b/js/src/jit/MacroAssembler-inl.h @@ -525,15 +525,6 @@ MacroAssembler::canonicalizeFloat(FloatRegister reg) bind(¬NaN); } -void -MacroAssembler::canonicalizeDouble(FloatRegister reg) -{ - Label notNaN; - branchDouble(DoubleOrdered, reg, reg, ¬NaN); - loadConstantDouble(JS::GenericNaN(), reg); - bind(¬NaN); -} - template void MacroAssembler::storeObjectOrNull(Register src, const T& dest) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 5e1e05c6df1..f14482425eb 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -846,9 +846,6 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTruncateFloat32(FloatRegister src, Register dest, Label* fail) DEFINED_ON(arm, arm64, mips_shared, x86, x64); - inline void branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, - Label* label) PER_SHARED_ARCH; - template inline void branchTest32(Condition cond, Register lhs, Register rhs, L label) PER_SHARED_ARCH; template @@ -1123,7 +1120,12 @@ class MacroAssembler : public MacroAssemblerSpecific bind(&done); } - inline void canonicalizeDouble(FloatRegister reg); + void canonicalizeDouble(FloatRegister reg) { + Label notNaN; + branchDouble(DoubleOrdered, reg, reg, ¬NaN); + loadConstantDouble(JS::GenericNaN(), reg); + bind(¬NaN); + } inline void canonicalizeFloat(FloatRegister reg); diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 08bf343b3c5..8cf154d1b8b 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -610,30 +610,6 @@ MacroAssembler::branchTruncateFloat32(FloatRegister src, Register dest, Label* f ma_b(fail, Assembler::Equal); } -void -MacroAssembler::branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, - Label* label) -{ - compareDouble(lhs, rhs); - - if (cond == DoubleNotEqual) { - // Force the unordered cases not to jump. - Label unordered; - ma_b(&unordered, VFP_Unordered); - ma_b(label, VFP_NotEqualOrUnordered); - bind(&unordered); - return; - } - - if (cond == DoubleEqualOrUnordered) { - ma_b(label, VFP_Unordered); - ma_b(label, VFP_Equal); - return; - } - - ma_b(label, ConditionFromDoubleCondition(cond)); -} - template void MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label) diff --git a/js/src/jit/arm/MacroAssembler-arm.cpp b/js/src/jit/arm/MacroAssembler-arm.cpp index e0decce759b..46964d59a00 100644 --- a/js/src/jit/arm/MacroAssembler-arm.cpp +++ b/js/src/jit/arm/MacroAssembler-arm.cpp @@ -2491,6 +2491,30 @@ MacroAssemblerARMCompat::compareDouble(FloatRegister lhs, FloatRegister rhs) as_vmrs(pc); } +void +MacroAssemblerARMCompat::branchDouble(DoubleCondition cond, FloatRegister lhs, + FloatRegister rhs, Label* label) +{ + compareDouble(lhs, rhs); + + if (cond == DoubleNotEqual) { + // Force the unordered cases not to jump. + Label unordered; + ma_b(&unordered, VFP_Unordered); + ma_b(label, VFP_NotEqualOrUnordered); + bind(&unordered); + return; + } + + if (cond == DoubleEqualOrUnordered) { + ma_b(label, VFP_Unordered); + ma_b(label, VFP_Equal); + return; + } + + ma_b(label, ConditionFromDoubleCondition(cond)); +} + void MacroAssemblerARMCompat::compareFloat(FloatRegister lhs, FloatRegister rhs) { diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 0fdc8942d5c..768ca8e17ca 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -1451,6 +1451,8 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM void simulatorStop(const char* msg); void compareDouble(FloatRegister lhs, FloatRegister rhs); + void branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, + Label* label); void compareFloat(FloatRegister lhs, FloatRegister rhs); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index e0a2082c151..4ab470d5627 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -693,29 +693,6 @@ MacroAssembler::branchTruncateFloat32(FloatRegister src, Register dest, Label* f And(dest64, dest64, Operand(0xffffffff)); } -void -MacroAssembler::branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, - Label* label) -{ - compareDouble(cond, lhs, rhs); - switch (cond) { - case DoubleNotEqual: { - Label unordered; - // not equal *and* ordered - branch(Overflow, &unordered); - branch(NotEqual, label); - bind(&unordered); - break; - } - case DoubleEqualOrUnordered: - branch(Overflow, label); - branch(Equal, label); - break; - default: - branch(Condition(cond), label); - } -} - template void MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label) diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index c3a2aec3260..422e42236fb 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1582,6 +1582,25 @@ class MacroAssemblerCompat : public vixl::MacroAssembler void compareDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs) { Fcmp(ARMFPRegister(lhs, 64), ARMFPRegister(rhs, 64)); } + void branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, Label* label) { + compareDouble(cond, lhs, rhs); + switch (cond) { + case DoubleNotEqual: { + Label unordered; + // not equal *and* ordered + branch(Overflow, &unordered); + branch(NotEqual, label); + bind(&unordered); + break; + } + case DoubleEqualOrUnordered: + branch(Overflow, label); + branch(Equal, label); + break; + default: + branch(Condition(cond), label); + } + } void compareFloat(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs) { Fcmp(ARMFPRegister(lhs, 32), ARMFPRegister(rhs, 32)); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 4bdbb430a8e..0f3776b1747 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -362,13 +362,6 @@ MacroAssembler::branchTruncateFloat32(FloatRegister src, Register dest, Label* f ma_b(dest, Imm32(INT32_MAX), fail, Assembler::Equal); } -void -MacroAssembler::branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, - Label* label) -{ - ma_bc1d(lhs, rhs, label, cond); -} - template void MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label) diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index f3f47bc8b97..6467a5e0a2b 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1098,6 +1098,13 @@ MacroAssembler::clampDoubleToUint8(FloatRegister input, Register output) bind(&done); } +void +MacroAssemblerMIPSCompat::branchDouble(DoubleCondition cond, FloatRegister lhs, + FloatRegister rhs, Label* label) +{ + ma_bc1d(lhs, rhs, label, cond); +} + // higher level tag testing code Operand MacroAssemblerMIPSCompat::ToPayload(Operand base) diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index d6d661e8a59..2cb15430b37 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -1074,6 +1074,9 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void breakpoint(); + void branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, + Label* label); + void checkStackAlignment(); void alignStackPointer(); diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 750be2a165d..f088318ead4 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1238,6 +1238,13 @@ MacroAssembler::clampDoubleToUint8(FloatRegister input, Register output) bind(&done); } +void +MacroAssemblerMIPS64Compat::branchDouble(DoubleCondition cond, FloatRegister lhs, + FloatRegister rhs, Label* label) +{ + ma_bc1d(lhs, rhs, label, cond); +} + void MacroAssemblerMIPS64Compat::branchTestGCThing(Condition cond, const Address& address, Label* label) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 9631a7ac8bf..979a8be7026 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -1084,6 +1084,9 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void breakpoint(); + void branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, + Label* label); + void checkStackAlignment(); static void calculateAlignedStackPointer(void** stackPointer); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 6cf7027e5ea..c21a0e63bac 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -246,6 +246,7 @@ class MacroAssemblerNone : public Assembler template void branchAdd32(Condition, T, S, Label*) { MOZ_CRASH(); } template void branchSub32(Condition, T, S, Label*) { MOZ_CRASH(); } + template void branchDouble(DoubleCondition, T, S, Label*) { MOZ_CRASH(); } template void decBranchPtr(Condition, T, S, Label*) { MOZ_CRASH(); } template void mov(T, S) { MOZ_CRASH(); } template void movq(T, S) { MOZ_CRASH(); } diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index f32e011f443..9f058def458 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -318,29 +318,6 @@ MacroAssembler::branchFloat(DoubleCondition cond, FloatRegister lhs, FloatRegist j(ConditionFromDoubleCondition(cond), label); } -void -MacroAssembler::branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, - Label* label) -{ - compareDouble(cond, lhs, rhs); - - if (cond == DoubleEqual) { - Label unordered; - j(Parity, &unordered); - j(Equal, label); - bind(&unordered); - return; - } - if (cond == DoubleNotEqualOrUnordered) { - j(NotEqual, label); - j(Parity, label); - return; - } - - MOZ_ASSERT(!(cond & DoubleConditionBitSpecial)); - j(ConditionFromDoubleCondition(cond), label); -} - template void MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label) diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared.cpp b/js/src/jit/x86-shared/MacroAssembler-x86-shared.cpp index 7834be729a1..1c0e86386ed 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared.cpp +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared.cpp @@ -105,7 +105,7 @@ MacroAssemblerX86Shared::branchNegativeZero(FloatRegister reg, zeroDouble(scratchDouble); // If reg is non-zero, jump to nonZero. - asMasm().branchDouble(DoubleNotEqual, reg, scratchDouble, &nonZero); + branchDouble(DoubleNotEqual, reg, scratchDouble, &nonZero); } // Input register is either zero or negative zero. Retrieve sign of input. vmovmskpd(reg, scratch); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h index 2a136a042c2..dcb8c3836a9 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h @@ -109,6 +109,26 @@ class MacroAssemblerX86Shared : public Assembler else vucomisd(rhs, lhs); } + void branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs, Label* label) + { + compareDouble(cond, lhs, rhs); + + if (cond == DoubleEqual) { + Label unordered; + j(Parity, &unordered); + j(Equal, label); + bind(&unordered); + return; + } + if (cond == DoubleNotEqualOrUnordered) { + j(NotEqual, label); + j(Parity, label); + return; + } + + MOZ_ASSERT(!(cond & DoubleConditionBitSpecial)); + j(ConditionFromDoubleCondition(cond), label); + } void compareFloat(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs) { if (cond & DoubleConditionBitInvert)