Bug 1245112 - Part 20: Move MacroAssembler::branchTestDouble into generic macro assembler. r=nbp

This commit is contained in:
Tooru Fujisawa 2016-03-03 08:03:42 +09:00
parent 7a8287e541
commit 3297a75e4f
19 changed files with 158 additions and 132 deletions

View File

@ -924,6 +924,8 @@ class MacroAssembler : public MacroAssemblerSpecific
// Perform a type-test on a tag of a Value (32bits boxing), or the tagged
// value (64bits boxing).
inline void branchTestInt32(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
inline void branchTestDouble(Condition cond, Register tag, Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
// Perform a type-test on a Value, addressed by Address or BaseIndex, or
// loaded into ValueOperand.
@ -932,6 +934,11 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestInt32(Condition cond, const ValueOperand& value, Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
inline void branchTestDouble(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH;
inline void branchTestDouble(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH;
inline void branchTestDouble(Condition cond, const ValueOperand& value, Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
// Checks if given Value is evaluated to true or false in a condition.
// The type of the value should match the type of the method.
inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label)
@ -943,6 +950,9 @@ class MacroAssembler : public MacroAssemblerSpecific
template <typename T>
inline void branchTestInt32Impl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
template <typename T>
inline void branchTestDoubleImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
//}}} check_macroassembler_style
public:

View File

@ -838,6 +838,38 @@ MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, La
ma_b(label, c);
}
void
MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label)
{
branchTestDoubleImpl(cond, tag, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const Address& address, Label* label)
{
branchTestDoubleImpl(cond, address, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label* label)
{
branchTestDoubleImpl(cond, address, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label)
{
branchTestDoubleImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label)
{
Condition c = testDouble(cond, t);
ma_b(label, c);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -3448,7 +3448,7 @@ void
MacroAssemblerARMCompat::ensureDouble(const ValueOperand& source, FloatRegister dest, Label* failure)
{
Label isDouble, done;
branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble);
asMasm().branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble);
asMasm().branchTestInt32(Assembler::NotEqual, source.typeReg(), failure);
convertInt32ToDouble(source.payloadReg(), dest);

View File

@ -767,12 +767,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
Condition c = testBoolean(cond, t);
ma_b(label, c);
}
template<typename T>
void branchTestDouble(Condition cond, const T & t, Label* label) {
Condition c = testDouble(cond, t);
ma_b(label, c);
}
template<typename T>
void branchTestNull(Condition cond, const T & t, Label* label) {
Condition c = testNull(cond, t);

View File

@ -925,6 +925,38 @@ MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, La
B(label, c);
}
void
MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label)
{
branchTestDoubleImpl(cond, tag, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const Address& address, Label* label)
{
branchTestDoubleImpl(cond, address, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label* label)
{
branchTestDoubleImpl(cond, address, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label)
{
branchTestDoubleImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label)
{
Condition c = testDouble(cond, t);
B(label, c);
}
//}}} check_macroassembler_style
// ===============================================================
@ -1006,7 +1038,7 @@ MacroAssemblerCompat::ensureDouble(const ValueOperand& source, FloatRegister des
vixl::UseScratchRegisterScope temps(this);
temps.Exclude(ARMRegister(tag, 64));
branchTestDouble(Assembler::Equal, tag, &isDouble);
asMasm().branchTestDouble(Assembler::Equal, tag, &isDouble);
asMasm().branchTestInt32(Assembler::NotEqual, tag, failure);
}

View File

@ -1332,11 +1332,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
Condition c = testUndefined(cond, tag);
B(label, c);
}
void branchTestDouble(Condition cond, Register tag, Label* label) {
Condition c = testDouble(cond, tag);
B(label, c);
}
void branchTestBoolean(Condition cond, Register tag, Label* label) {
Condition c = testBoolean(cond, tag);
B(label, c);
@ -1366,10 +1361,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
Condition c = testUndefined(cond, address);
B(label, c);
}
void branchTestDouble(Condition cond, const Address& address, Label* label) {
Condition c = testDouble(cond, address);
B(label, c);
}
void branchTestBoolean(Condition cond, const Address& address, Label* label) {
Condition c = testDouble(cond, address);
B(label, c);
@ -1405,10 +1396,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
Condition c = testBoolean(cond, src);
B(label, c);
}
void branchTestDouble(Condition cond, const ValueOperand& src, Label* label) {
Condition c = testDouble(cond, src);
B(label, c);
}
void branchTestNull(Condition cond, const ValueOperand& src, Label* label) {
Condition c = testNull(cond, src);
B(label, c);
@ -1440,10 +1427,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
Condition c = testBoolean(cond, address);
B(label, c);
}
void branchTestDouble(Condition cond, const BaseIndex& address, Label* label) {
Condition c = testDouble(cond, address);
B(label, c);
}
void branchTestNull(Condition cond, const BaseIndex& address, Label* label) {
Condition c = testNull(cond, address);
B(label, c);

View File

@ -532,6 +532,22 @@ MacroAssembler::branchTestInt32(Condition cond, const BaseIndex& address, Label*
branchTestInt32(cond, scratch2, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const Address& address, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
extractTag(address, scratch2);
branchTestDouble(cond, scratch2, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
extractTag(address, scratch2);
branchTestDouble(cond, scratch2, label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -302,6 +302,20 @@ MacroAssembler::branchTestInt32Truthy(bool b, const ValueOperand& value, Label*
ma_b(scratch, scratch, label, b ? NonZero : Zero);
}
void
MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
Condition actual = (cond == Equal) ? Below : AboveOrEqual;
ma_b(tag, ImmTag(JSVAL_TAG_CLEAR), label, actual);
}
void
MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label)
{
branchTestDouble(cond, value.typeReg(), label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -1157,39 +1157,6 @@ MacroAssemblerMIPSCompat::branchTestBoolean(Condition cond, const BaseIndex& src
ma_b(SecondScratchReg, ImmType(JSVAL_TYPE_BOOLEAN), label, cond);
}
void
MacroAssemblerMIPSCompat::branchTestDouble(Condition cond, const ValueOperand& value, Label* label)
{
MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual);
Assembler::Condition actual = (cond == Equal) ? Below : AboveOrEqual;
ma_b(value.typeReg(), ImmTag(JSVAL_TAG_CLEAR), label, actual);
}
void
MacroAssemblerMIPSCompat::branchTestDouble(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Assembler::Equal || cond == NotEqual);
Condition actual = (cond == Equal) ? Below : AboveOrEqual;
ma_b(tag, ImmTag(JSVAL_TAG_CLEAR), label, actual);
}
void
MacroAssemblerMIPSCompat::branchTestDouble(Condition cond, const Address& address, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(address, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_CLEAR), label, cond);
}
void
MacroAssemblerMIPSCompat::branchTestDouble(Condition cond, const BaseIndex& src, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
Condition actual = (cond == Equal) ? Below : AboveOrEqual;
extractTag(src, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_CLEAR), label, actual);
}
void
MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const ValueOperand& value, Label* label)
{
@ -2014,7 +1981,7 @@ MacroAssemblerMIPSCompat::ensureDouble(const ValueOperand& source, FloatRegister
Label* failure)
{
Label isDouble, done;
branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble);
asMasm().branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble);
asMasm().branchTestInt32(Assembler::NotEqual, source.typeReg(), failure);
convertInt32ToDouble(source.payloadReg(), dest);

View File

@ -381,11 +381,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS
void branchTestBoolean(Condition cond, const BaseIndex& src, Label* label);
void branchTestDouble(Condition cond, const ValueOperand& value, Label* label);
void branchTestDouble(Condition cond, Register tag, Label* label);
void branchTestDouble(Condition cond, const Address& address, Label* label);
void branchTestDouble(Condition cond, const BaseIndex& src, Label* label);
void branchTestNull(Condition cond, const ValueOperand& value, Label* label);
void branchTestNull(Condition cond, Register tag, Label* label);
void branchTestNull(Condition cond, const BaseIndex& src, Label* label);

View File

@ -240,6 +240,22 @@ MacroAssembler::branchTestInt32Truthy(bool b, const ValueOperand& value, Label*
ma_b(scratch, scratch, label, b ? NonZero : Zero);
}
void
MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
Condition actual = (cond == Equal) ? BelowOrEqual : Above;
ma_b(tag, ImmTag(JSVAL_TAG_MAX_DOUBLE), label, actual);
}
void
MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
splitTag(value, scratch2);
branchTestDouble(cond, scratch2, label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -1286,38 +1286,6 @@ MacroAssemblerMIPS64Compat::branchTestBoolean(Condition cond, const BaseIndex& s
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_BOOLEAN), label, cond);
}
void
MacroAssemblerMIPS64Compat::branchTestDouble(Condition cond, const ValueOperand& value, Label* label)
{
MOZ_ASSERT(cond == Assembler::Equal || cond == NotEqual);
splitTag(value, SecondScratchReg);
branchTestDouble(cond, SecondScratchReg, label);
}
void
MacroAssemblerMIPS64Compat::branchTestDouble(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Assembler::Equal || cond == NotEqual);
Condition actual = (cond == Equal) ? BelowOrEqual : Above;
ma_b(tag, ImmTag(JSVAL_TAG_MAX_DOUBLE), label, actual);
}
void
MacroAssemblerMIPS64Compat::branchTestDouble(Condition cond, const Address& address, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(address, SecondScratchReg);
branchTestDouble(cond, SecondScratchReg, label);
}
void
MacroAssemblerMIPS64Compat::branchTestDouble(Condition cond, const BaseIndex& src, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(src, SecondScratchReg);
branchTestDouble(cond, SecondScratchReg, label);
}
void
MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const ValueOperand& value, Label* label)
{
@ -2174,7 +2142,7 @@ MacroAssemblerMIPS64Compat::ensureDouble(const ValueOperand& source, FloatRegist
{
Label isDouble, done;
Register tag = splitTagForTest(source);
branchTestDouble(Assembler::Equal, tag, &isDouble);
asMasm().branchTestDouble(Assembler::Equal, tag, &isDouble);
asMasm().branchTestInt32(Assembler::NotEqual, tag, failure);
unboxInt32(source, ScratchRegister);

View File

@ -422,11 +422,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64
void branchTestBoolean(Condition cond, const BaseIndex& src, Label* label);
void branchTestDouble(Condition cond, const ValueOperand& value, Label* label);
void branchTestDouble(Condition cond, Register tag, Label* label);
void branchTestDouble(Condition cond, const Address& address, Label* label);
void branchTestDouble(Condition cond, const BaseIndex& src, Label* label);
void branchTestNull(Condition cond, const ValueOperand& value, Label* label);
void branchTestNull(Condition cond, Register tag, Label* label);
void branchTestNull(Condition cond, const BaseIndex& src, Label* label);

View File

@ -347,7 +347,6 @@ class MacroAssemblerNone : public Assembler
template <typename T> void branchTestUndefined(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestBoolean(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestDouble(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestNull(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestString(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); }

View File

@ -459,7 +459,7 @@ MacroAssemblerX64::ensureDouble(const ValueOperand& source, FloatRegister dest,
{
Label isDouble, done;
Register tag = splitTagForTest(source);
branchTestDouble(Assembler::Equal, tag, &isDouble);
asMasm().branchTestDouble(Assembler::Equal, tag, &isDouble);
asMasm().branchTestInt32(Assembler::NotEqual, tag, failure);
ScratchRegisterScope scratch(asMasm());

View File

@ -690,10 +690,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
cond = testUndefined(cond, tag);
j(cond, label);
}
void branchTestDouble(Condition cond, Register tag, Label* label) {
cond = testDouble(cond, tag);
j(cond, label);
}
void branchTestBoolean(Condition cond, Register tag, Label* label) {
cond = testBoolean(cond, tag);
j(cond, label);
@ -731,16 +727,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
MOZ_ASSERT(cond == Equal || cond == NotEqual);
branchTestUndefined(cond, Operand(address), label);
}
void branchTestDouble(Condition cond, const Operand& operand, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ScratchRegisterScope scratch(asMasm());
splitTag(operand, scratch);
branchTestDouble(cond, scratch, label);
}
void branchTestDouble(Condition cond, const Address& address, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
branchTestDouble(cond, Operand(address), label);
}
void branchTestBoolean(Condition cond, const Operand& operand, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_BOOLEAN))));
@ -777,10 +763,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
splitTag(src, scratch);
branchTestBoolean(cond, scratch, label);
}
void branchTestDouble(Condition cond, const ValueOperand& src, Label* label) {
cond = testDouble(cond, src);
j(cond, label);
}
void branchTestNull(Condition cond, const ValueOperand& src, Label* label) {
cond = testNull(cond, src);
j(cond, label);
@ -813,10 +795,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
splitTag(address, scratch);
branchTestBoolean(cond, scratch, label);
}
void branchTestDouble(Condition cond, const BaseIndex& address, Label* label) {
cond = testDouble(cond, address);
j(cond, label);
}
void branchTestNull(Condition cond, const BaseIndex& address, Label* label) {
cond = testNull(cond, address);
j(cond, label);

View File

@ -467,6 +467,38 @@ MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, La
j(cond, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label)
{
branchTestDoubleImpl(cond, tag, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const Address& address, Label* label)
{
branchTestDoubleImpl(cond, address, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label* label)
{
branchTestDoubleImpl(cond, address, label);
}
void
MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label)
{
branchTestDoubleImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label)
{
cond = testDouble(cond, t);
j(cond, label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -476,7 +476,7 @@ void
MacroAssemblerX86::ensureDouble(const ValueOperand& source, FloatRegister dest, Label* failure)
{
Label isDouble, done;
branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble);
asMasm().branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble);
asMasm().branchTestInt32(Assembler::NotEqual, source.typeReg(), failure);
convertInt32ToDouble(source.payloadReg(), dest);

View File

@ -670,11 +670,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
j(cond, label);
}
template <typename T>
void branchTestDouble(Condition cond, const T& t, Label* label) {
cond = testDouble(cond, t);
j(cond, label);
}
template <typename T>
void branchTestNull(Condition cond, const T& t, Label* label) {
cond = testNull(cond, t);
j(cond, label);