Bug 1245112 - Part 32: Move MacroAssembler::branchTestPrimitive into generic macro assembler. r=jandem

This commit is contained in:
Tooru Fujisawa 2016-03-03 08:03:44 +09:00
parent dc44c3b83c
commit 63cc8e3c70
16 changed files with 89 additions and 57 deletions

View File

@ -933,6 +933,7 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestSymbol(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
inline void branchTestNull(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
inline void branchTestObject(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
inline void branchTestPrimitive(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
// Perform a type-test on a Value, addressed by Address or BaseIndex, or
// loaded into ValueOperand.
@ -983,6 +984,9 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestGCThing(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH;
inline void branchTestGCThing(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH;
inline void branchTestPrimitive(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)
@ -1025,6 +1029,9 @@ class MacroAssembler : public MacroAssemblerSpecific
template <typename T>
inline void branchTestGCThingImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
template <typename T>
inline void branchTestPrimitiveImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
//}}} check_macroassembler_style
public:

View File

@ -1111,6 +1111,26 @@ MacroAssembler::branchTestGCThingImpl(Condition cond, const T& t, Label* label)
ma_b(label, c);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label)
{
branchTestPrimitiveImpl(cond, tag, label);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label)
{
branchTestPrimitiveImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label)
{
Condition c = testPrimitive(cond, t);
ma_b(label, c);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -684,12 +684,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
Condition testMagic(Condition cond, const BaseIndex& src);
Condition testGCThing(Condition cond, const BaseIndex& src);
template <typename T>
void branchTestPrimitive(Condition cond, const T& t, Label* label) {
Condition c = testPrimitive(cond, t);
ma_b(label, c);
}
void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label);
void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value,
Label* label);

View File

@ -1210,6 +1210,26 @@ MacroAssembler::branchTestGCThingImpl(Condition cond, const T& src, Label* label
B(label, c);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label)
{
branchTestPrimitiveImpl(cond, tag, label);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label)
{
branchTestPrimitiveImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label)
{
Condition c = testPrimitive(cond, t);
B(label, c);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -1328,11 +1328,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
return jumpWithPatch(label, Always, documentation);
}
template <typename T>
void branchTestPrimitive(Condition cond, const T& t, Label* label) {
Condition c = testPrimitive(cond, t);
B(label, c);
}
template <typename T, typename L>
void branchTestMagic(Condition cond, const T& t, L label) {
Condition c = testMagic(cond, t);

View File

@ -705,6 +705,14 @@ MacroAssembler::branchTestGCThing(Condition cond, const BaseIndex& address, Labe
(cond == Equal) ? AboveOrEqual : Below);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET), label,
(cond == Equal) ? Below : AboveOrEqual);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -374,6 +374,12 @@ MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Labe
branchTestObject(cond, value.typeReg(), label);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label)
{
branchTestPrimitive(cond, value.typeReg(), label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -1095,20 +1095,6 @@ MacroAssemblerMIPSCompat::ToType(Operand base)
return Operand(Register::FromCode(base.base()), base.disp() + TAG_OFFSET);
}
void
MacroAssemblerMIPSCompat::branchTestPrimitive(Condition cond, const ValueOperand& value,
Label* label)
{
branchTestPrimitive(cond, value.typeReg(), label);
}
void
MacroAssemblerMIPSCompat::branchTestPrimitive(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET), label,
(cond == Equal) ? Below : AboveOrEqual);
}
void
MacroAssemblerMIPSCompat::testNullSet(Condition cond, const ValueOperand& value, Register dest)
{

View File

@ -309,9 +309,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS
return value.typeReg();
}
void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label);
void branchTestPrimitive(Condition cond, Register tag, Label* label);
void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label);
void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value,
Label* label);

View File

@ -329,6 +329,14 @@ MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Labe
branchTestObject(cond, scratch2, label);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
splitTag(value, scratch2);
branchTestPrimitive(cond, scratch2, label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -1222,21 +1222,6 @@ MacroAssembler::clampDoubleToUint8(FloatRegister input, Register output)
bind(&done);
}
void
MacroAssemblerMIPS64Compat::branchTestPrimitive(Condition cond, const ValueOperand& value,
Label* label)
{
splitTag(value, SecondScratchReg);
branchTestPrimitive(cond, SecondScratchReg, label);
}
void
MacroAssemblerMIPS64Compat::branchTestPrimitive(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET), label,
(cond == Equal) ? Below : AboveOrEqual);
}
void
MacroAssemblerMIPS64Compat::testNullSet(Condition cond, const ValueOperand& value, Register dest)
{

View File

@ -337,9 +337,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64
return SecondScratchReg;
}
void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label);
void branchTestPrimitive(Condition cond, Register tag, Label* label);
void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label);
void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value,
Label* label);

View File

@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler
Register splitTagForTest(ValueOperand) { MOZ_CRASH(); }
template <typename T> void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T, typename L> void branchTestMagic(Condition, T, L) { MOZ_CRASH(); }
template <typename T> void branchTestMagicValue(Condition, T, JSWhyMagic, Label*) { MOZ_CRASH(); }
void boxDouble(FloatRegister, ValueOperand) { MOZ_CRASH(); }

View File

@ -683,11 +683,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
cmp32(reg, tag);
}
template <typename T>
void branchTestPrimitive(Condition cond, const T& t, Label* label) {
cond = testPrimitive(cond, t);
j(cond, label);
}
template <typename T, class L>
void branchTestMagic(Condition cond, const T& t, L label) {
cond = testMagic(cond, t);

View File

@ -733,6 +733,26 @@ MacroAssembler::branchTestGCThingImpl(Condition cond, const T& t, Label* label)
j(cond, label);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label)
{
branchTestPrimitiveImpl(cond, tag, label);
}
void
MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label)
{
branchTestPrimitiveImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label)
{
cond = testPrimitive(cond, t);
j(cond, label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -659,11 +659,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
// Type testing instructions can take a tag in a register or a
// ValueOperand.
template <typename T>
void branchTestPrimitive(Condition cond, const T& t, Label* label) {
cond = testPrimitive(cond, t);
j(cond, label);
}
template <typename T, class L>
void branchTestMagic(Condition cond, const T& t, L label) {
cond = testMagic(cond, t);