Bug 1245112 - Part 9: Move MacroAssembler::branchDouble into generic macro assembler. r=nbp

This commit is contained in:
Tooru Fujisawa 2016-02-15 23:01:49 +09:00
parent 64b2cb020b
commit 33147eea93
16 changed files with 91 additions and 93 deletions

View File

@ -525,6 +525,15 @@ MacroAssembler::canonicalizeFloat(FloatRegister reg)
bind(&notNaN);
}
void
MacroAssembler::canonicalizeDouble(FloatRegister reg)
{
Label notNaN;
branchDouble(DoubleOrdered, reg, reg, &notNaN);
loadConstantDouble(JS::GenericNaN(), reg);
bind(&notNaN);
}
template <typename T>
void
MacroAssembler::storeObjectOrNull(Register src, const T& dest)

View File

@ -846,6 +846,9 @@ 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 <class L>
inline void branchTest32(Condition cond, Register lhs, Register rhs, L label) PER_SHARED_ARCH;
template <class L>
@ -1120,12 +1123,7 @@ class MacroAssembler : public MacroAssemblerSpecific
bind(&done);
}
void canonicalizeDouble(FloatRegister reg) {
Label notNaN;
branchDouble(DoubleOrdered, reg, reg, &notNaN);
loadConstantDouble(JS::GenericNaN(), reg);
bind(&notNaN);
}
inline void canonicalizeDouble(FloatRegister reg);
inline void canonicalizeFloat(FloatRegister reg);

View File

@ -610,6 +610,30 @@ 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 <class L>
void
MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label)

View File

@ -2491,30 +2491,6 @@ 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)
{

View File

@ -1451,8 +1451,6 @@ 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);

View File

@ -693,6 +693,29 @@ 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 <class L>
void
MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label)

View File

@ -1582,25 +1582,6 @@ 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));

View File

@ -362,6 +362,13 @@ 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 <class L>
void
MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label)

View File

@ -1098,13 +1098,6 @@ 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)

View File

@ -1074,9 +1074,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS
void breakpoint();
void branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs,
Label* label);
void checkStackAlignment();
void alignStackPointer();

View File

@ -1238,13 +1238,6 @@ 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)
{

View File

@ -1084,9 +1084,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64
void breakpoint();
void branchDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs,
Label* label);
void checkStackAlignment();
static void calculateAlignedStackPointer(void** stackPointer);

View File

@ -246,7 +246,6 @@ class MacroAssemblerNone : public Assembler
template <typename T, typename S> void branchAdd32(Condition, T, S, Label*) { MOZ_CRASH(); }
template <typename T, typename S> void branchSub32(Condition, T, S, Label*) { MOZ_CRASH(); }
template <typename T, typename S> void branchDouble(DoubleCondition, T, S, Label*) { MOZ_CRASH(); }
template <typename T, typename S> void decBranchPtr(Condition, T, S, Label*) { MOZ_CRASH(); }
template <typename T, typename S> void mov(T, S) { MOZ_CRASH(); }
template <typename T, typename S> void movq(T, S) { MOZ_CRASH(); }

View File

@ -318,6 +318,29 @@ 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 <class L>
void
MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label)

View File

@ -105,7 +105,7 @@ MacroAssemblerX86Shared::branchNegativeZero(FloatRegister reg,
zeroDouble(scratchDouble);
// If reg is non-zero, jump to nonZero.
branchDouble(DoubleNotEqual, reg, scratchDouble, &nonZero);
asMasm().branchDouble(DoubleNotEqual, reg, scratchDouble, &nonZero);
}
// Input register is either zero or negative zero. Retrieve sign of input.
vmovmskpd(reg, scratch);

View File

@ -109,26 +109,6 @@ 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)