diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 530a3c101147..e70613dc7bd2 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -943,6 +943,7 @@ class MacroAssembler : public MacroAssemblerSpecific // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) PER_SHARED_ARCH; private: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index e795fa675d0e..d82370b22509 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -870,6 +870,13 @@ MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) ma_b(label, c); } +void +MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) +{ + Condition c = testDoubleTruthy(truthy, reg); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 45ec3f16062d..3829aa8f4d90 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -811,10 +811,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition c = testBooleanTruthy(truthy, operand); ma_b(label, c); } - void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) { - Condition c = testDoubleTruthy(truthy, reg); - ma_b(label, c); - } void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) { Condition c = testStringTruthy(truthy, value); ma_b(label, c); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index b8cc1fa05557..feb3caea3e10 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -957,6 +957,25 @@ MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) B(label, c); } +void +MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) +{ + Fcmp(ARMFPRegister(reg, 64), 0.0); + if (!truthy) { + // falsy values are zero, and NaN. + branch(Zero, label); + branch(Overflow, label); + } else { + // truthy values are non-zero and not nan. + // If it is overflow + Label onFalse; + branch(Zero, &onFalse); + branch(Overflow, &onFalse); + B(label); + bind(&onFalse); + } +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index ebeb384ba81c..3c480d5ebb4d 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1948,23 +1948,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return truthy ? NonZero : Zero; } - void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) { - Fcmp(ARMFPRegister(reg, 64), 0.0); - if (!truthy) { - // falsy values are zero, and NaN. - branch(Zero, label); - branch(Overflow, label); - } else { - // truthy values are non-zero and not nan. - // If it is overflow - Label onFalse; - branch(Zero, &onFalse); - branch(Overflow, &onFalse); - B(label); - bind(&onFalse); - } - } - Condition testBooleanTruthy(bool truthy, const ValueOperand& operand) { ARMRegister payload32(operand.valueReg(), 32); Tst(payload32, payload32); 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 514a571e1923..0060aa9354bc 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -548,6 +548,14 @@ MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label branchTestDouble(cond, scratch2, label); } +void +MacroAssembler::branchTestDoubleTruthy(bool b, FloatRegister value, Label* label) +{ + ma_lid(ScratchDoubleReg, 0.0); + DoubleCondition cond = b ? DoubleNotEqual : DoubleEqualOrUnordered; + ma_bc1d(value, ScratchDoubleReg, label, cond); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index de2f8462ac78..037221fd7b76 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1613,14 +1613,6 @@ MacroAssemblerMIPSCompat::branchTestStringTruthy(bool b, const ValueOperand& val ma_b(SecondScratchReg, Imm32(0), label, b ? NotEqual : Equal); } -void -MacroAssemblerMIPSCompat::branchTestDoubleTruthy(bool b, FloatRegister value, Label* label) -{ - ma_lid(ScratchDoubleReg, 0.0); - DoubleCondition cond = b ? DoubleNotEqual : DoubleEqualOrUnordered; - ma_bc1d(value, ScratchDoubleReg, label, cond); -} - void MacroAssemblerMIPSCompat::branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label) diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 655f1ca7d813..862794dbf7c5 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -424,8 +424,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void branchTestStringTruthy(bool b, const ValueOperand& value, Label* label); - void branchTestDoubleTruthy(bool b, FloatRegister value, Label* label); - void branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label); // higher level tag testing code diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 35dcfed8c54c..f9c20fb25726 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1837,14 +1837,6 @@ MacroAssemblerMIPS64Compat::branchTestStringTruthy(bool b, const ValueOperand& v ma_b(SecondScratchReg, Imm32(0), label, b ? NotEqual : Equal); } -void -MacroAssemblerMIPS64Compat::branchTestDoubleTruthy(bool b, FloatRegister value, Label* label) -{ - ma_lid(ScratchDoubleReg, 0.0); - DoubleCondition cond = b ? DoubleNotEqual : DoubleEqualOrUnordered; - ma_bc1d(value, ScratchDoubleReg, label, cond); -} - void MacroAssemblerMIPS64Compat::branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label) diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index d7afd0885457..fb0ba049f613 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -465,8 +465,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void branchTestStringTruthy(bool b, const ValueOperand& value, Label* label); - void branchTestDoubleTruthy(bool b, FloatRegister value, Label* label); - void branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label); // higher level tag testing code diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 3e525a8c3359..535ff6dfb00a 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -395,7 +395,6 @@ class MacroAssemblerNone : public Assembler Condition testStringTruthy(bool, ValueOperand) { MOZ_CRASH(); } void branchTestBooleanTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); } void branchTestStringTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); } - void branchTestDoubleTruthy(bool, FloatRegister, Label*) { MOZ_CRASH(); } template void loadUnboxedValue(T, MIRType, AnyRegister) { MOZ_CRASH(); } template void storeUnboxedValue(ConstantOrRegister, MIRType, T, MIRType) { 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 850ed462b1ce..cd4ec49be918 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -499,6 +499,13 @@ MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) +{ + Condition cond = testDoubleTruthy(truthy, reg); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h index 963191e5da38..27ceaa6734ba 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h @@ -582,10 +582,6 @@ class MacroAssemblerX86Shared : public Assembler vucomisd(reg, scratch); return truthy ? NonZero : Zero; } - void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) { - Condition cond = testDoubleTruthy(truthy, reg); - j(cond, label); - } // Class which ensures that registers used in byte ops are compatible with // such instructions, even if the original register passed in wasn't. This