Bug 1245112 - Part 29: Move MacroAssembler::branchTestNull into generic macro assembler. r=sstangl

This commit is contained in:
Tooru Fujisawa 2016-03-03 08:03:44 +09:00
parent 3a63fbd192
commit 0f89d7a32f
16 changed files with 144 additions and 119 deletions

View File

@ -931,6 +931,7 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestBoolean(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestBoolean(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
inline void branchTestString(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestString(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
inline void branchTestSymbol(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestSymbol(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
inline void branchTestNull(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
// Perform a type-test on a Value, addressed by Address or BaseIndex, or // Perform a type-test on a Value, addressed by Address or BaseIndex, or
// loaded into ValueOperand. // loaded into ValueOperand.
@ -965,6 +966,11 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) inline void branchTestSymbol(Condition cond, const ValueOperand& value, Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
inline void branchTestNull(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH;
inline void branchTestNull(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH;
inline void branchTestNull(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. // 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. // The type of the value should match the type of the method.
inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label)
@ -998,6 +1004,9 @@ class MacroAssembler : public MacroAssemblerSpecific
template <typename T> template <typename T>
inline void branchTestSymbolImpl(Condition cond, const T& t, Label* label) inline void branchTestSymbolImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared); DEFINED_ON(arm, arm64, x86_shared);
template <typename T>
inline void branchTestNullImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
//}}} check_macroassembler_style //}}} check_macroassembler_style
public: public:

View File

@ -1027,6 +1027,38 @@ MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label)
ma_b(label, c); ma_b(label, c);
} }
void
MacroAssembler::branchTestNull(Condition cond, Register tag, Label* label)
{
branchTestNullImpl(cond, tag, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const Address& address, Label* label)
{
branchTestNullImpl(cond, address, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* label)
{
branchTestNullImpl(cond, address, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* label)
{
branchTestNullImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label)
{
Condition c = testNull(cond, t);
ma_b(label, c);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

View File

@ -762,11 +762,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest);
void loadConstantFloat32(float f, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest);
template<typename T>
void branchTestNull(Condition cond, const T & t, Label* label) {
Condition c = testNull(cond, t);
ma_b(label, c);
}
template<typename T> template<typename T>
void branchTestObject(Condition cond, const T & t, Label* label) { void branchTestObject(Condition cond, const T & t, Label* label) {
Condition c = testObject(cond, t); Condition c = testObject(cond, t);

View File

@ -1126,6 +1126,38 @@ MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label)
B(label, c); B(label, c);
} }
void
MacroAssembler::branchTestNull(Condition cond, Register tag, Label* label)
{
branchTestNullImpl(cond, tag, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const Address& address, Label* label)
{
branchTestNullImpl(cond, address, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* label)
{
branchTestNullImpl(cond, address, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* label)
{
branchTestNullImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label)
{
Condition c = testNull(cond, t);
B(label, c);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

View File

@ -1328,19 +1328,11 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
return jumpWithPatch(label, Always, documentation); return jumpWithPatch(label, Always, documentation);
} }
void branchTestNull(Condition cond, Register tag, Label* label) {
Condition c = testNull(cond, tag);
B(label, c);
}
void branchTestObject(Condition cond, Register tag, Label* label) { void branchTestObject(Condition cond, Register tag, Label* label) {
Condition c = testObject(cond, tag); Condition c = testObject(cond, tag);
B(label, c); B(label, c);
} }
void branchTestNull(Condition cond, const Address& address, Label* label) {
Condition c = testNull(cond, address);
B(label, c);
}
void branchTestObject(Condition cond, const Address& address, Label* label) { void branchTestObject(Condition cond, const Address& address, Label* label) {
Condition c = testObject(cond, address); Condition c = testObject(cond, address);
B(label, c); B(label, c);
@ -1348,10 +1340,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
// Perform a type-test on a full Value loaded into a register. // Perform a type-test on a full Value loaded into a register.
// Clobbers the ScratchReg. // Clobbers the ScratchReg.
void branchTestNull(Condition cond, const ValueOperand& src, Label* label) {
Condition c = testNull(cond, src);
B(label, c);
}
void branchTestObject(Condition cond, const ValueOperand& src, Label* label) { void branchTestObject(Condition cond, const ValueOperand& src, Label* label) {
Condition c = testObject(cond, src); Condition c = testObject(cond, src);
B(label, c); B(label, c);
@ -1359,10 +1347,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
// Perform a type-test on a Value addressed by BaseIndex. // Perform a type-test on a Value addressed by BaseIndex.
// Clobbers the ScratchReg. // Clobbers the ScratchReg.
void branchTestNull(Condition cond, const BaseIndex& address, Label* label) {
Condition c = testNull(cond, address);
B(label, c);
}
void branchTestObject(Condition cond, const BaseIndex& address, Label* label) { void branchTestObject(Condition cond, const BaseIndex& address, Label* label) {
Condition c = testObject(cond, address); Condition c = testObject(cond, address);
B(label, c); B(label, c);

View File

@ -640,6 +640,29 @@ MacroAssembler::branchTestSymbol(Condition cond, const BaseIndex& address, Label
branchTestSymbol(cond, scratch2, label); branchTestSymbol(cond, scratch2, label);
} }
void
MacroAssembler::branchTestNull(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_TAG_NULL), label, cond);
}
void
MacroAssembler::branchTestNull(Condition cond, const Address& address, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
extractTag(address, scratch2);
branchTestNull(cond, scratch2, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
extractTag(address, scratch2);
branchTestNull(cond, scratch2, label);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

View File

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

View File

@ -1126,35 +1126,6 @@ MacroAssemblerMIPSCompat::branchTestPrimitive(Condition cond, Register tag, Labe
(cond == Equal) ? Below : AboveOrEqual); (cond == Equal) ? Below : AboveOrEqual);
} }
void
MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const ValueOperand& value, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(value.typeReg(), ImmType(JSVAL_TYPE_NULL), label, cond);
}
void
MacroAssemblerMIPSCompat::branchTestNull(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_TAG_NULL), label, cond);
}
void
MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const BaseIndex& src, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(src, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond);
}
void
MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const Address& address, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(address, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond);
}
void void
MacroAssemblerMIPSCompat::testNullSet(Condition cond, const ValueOperand& value, Register dest) MacroAssemblerMIPSCompat::testNullSet(Condition cond, const ValueOperand& value, Register dest)
{ {

View File

@ -375,10 +375,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS
void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest);
void loadConstantFloat32(float f, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest);
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);
void branchTestNull(Condition cond, const Address& address, Label* label);
void testNullSet(Condition cond, const ValueOperand& value, Register dest); void testNullSet(Condition cond, const ValueOperand& value, Register dest);
void branchTestObject(Condition cond, const ValueOperand& value, Label* label); void branchTestObject(Condition cond, const ValueOperand& value, Label* label);

View File

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

View File

@ -1254,36 +1254,6 @@ MacroAssemblerMIPS64Compat::branchTestPrimitive(Condition cond, Register tag, La
(cond == Equal) ? Below : AboveOrEqual); (cond == Equal) ? Below : AboveOrEqual);
} }
void
MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const ValueOperand& value, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
splitTag(value, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond);
}
void
MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_TAG_NULL), label, cond);
}
void
MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const BaseIndex& src, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(src, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond);
}
void
MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const Address& address, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(address, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond);
}
void void
MacroAssemblerMIPS64Compat::testNullSet(Condition cond, const ValueOperand& value, Register dest) MacroAssemblerMIPS64Compat::testNullSet(Condition cond, const ValueOperand& value, Register dest)
{ {

View File

@ -416,10 +416,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64
void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest);
void loadConstantFloat32(float f, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest);
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);
void branchTestNull(Condition cond, const Address& address, Label* label);
void testNullSet(Condition cond, const ValueOperand& value, Register dest); void testNullSet(Condition cond, const ValueOperand& value, Register dest);
void branchTestObject(Condition cond, const ValueOperand& value, Label* label); void branchTestObject(Condition cond, const ValueOperand& value, Label* label);

View File

@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler
Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } Register splitTagForTest(ValueOperand) { MOZ_CRASH(); }
template <typename T> void branchTestNull(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestObject(Condition, T, Label*) { MOZ_CRASH(); } template <typename T> void branchTestObject(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestGCThing(Condition, T, Label*) { MOZ_CRASH(); } template <typename T> void branchTestGCThing(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); } template <typename T> void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); }

View File

@ -346,9 +346,8 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
return testNumber(cond, scratch); return testNumber(cond, scratch);
} }
Condition testNull(Condition cond, const Address& src) { Condition testNull(Condition cond, const Address& src) {
ScratchRegisterScope scratch(asMasm()); cmp32(ToUpper32(src), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_NULL))));
splitTag(src, scratch); return cond;
return testNull(cond, scratch);
} }
Condition testString(Condition cond, const Address& src) { Condition testString(Condition cond, const Address& src) {
ScratchRegisterScope scratch(asMasm()); ScratchRegisterScope scratch(asMasm());
@ -684,10 +683,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
cmp32(reg, tag); cmp32(reg, tag);
} }
void branchTestNull(Condition cond, Register tag, Label* label) {
cond = testNull(cond, tag);
j(cond, label);
}
void branchTestObject(Condition cond, Register tag, Label* label) { void branchTestObject(Condition cond, Register tag, Label* label) {
cond = testObject(cond, tag); cond = testObject(cond, tag);
j(cond, label); j(cond, label);
@ -696,16 +691,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
// x64 can test for certain types directly from memory when the payload // x64 can test for certain types directly from memory when the payload
// of the type is limited to 32 bits. This avoids loading into a register, // of the type is limited to 32 bits. This avoids loading into a register,
// accesses half as much memory, and removes a right-shift. // accesses half as much memory, and removes a right-shift.
void branchTestNull(Condition cond, const Operand& operand, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_NULL))));
j(cond, label);
}
void branchTestNull(Condition cond, const Address& address, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
branchTestNull(cond, Operand(address), label);
}
// This one, though, clobbers the ScratchReg. // This one, though, clobbers the ScratchReg.
void branchTestObject(Condition cond, const Address& src, Label* label) { void branchTestObject(Condition cond, const Address& src, Label* label) {
cond = testObject(cond, src); cond = testObject(cond, src);
@ -714,10 +699,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
// Perform a type-test on a full Value loaded into a register. // Perform a type-test on a full Value loaded into a register.
// Clobbers the ScratchReg. // Clobbers the ScratchReg.
void branchTestNull(Condition cond, const ValueOperand& src, Label* label) {
cond = testNull(cond, src);
j(cond, label);
}
void branchTestObject(Condition cond, const ValueOperand& src, Label* label) { void branchTestObject(Condition cond, const ValueOperand& src, Label* label) {
cond = testObject(cond, src); cond = testObject(cond, src);
j(cond, label); j(cond, label);
@ -725,10 +706,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
// Perform a type-test on a Value addressed by BaseIndex. // Perform a type-test on a Value addressed by BaseIndex.
// Clobbers the ScratchReg. // Clobbers the ScratchReg.
void branchTestNull(Condition cond, const BaseIndex& address, Label* label) {
cond = testNull(cond, address);
j(cond, label);
}
void branchTestObject(Condition cond, const BaseIndex& address, Label* label) { void branchTestObject(Condition cond, const BaseIndex& address, Label* label) {
cond = testObject(cond, address); cond = testObject(cond, address);
j(cond, label); j(cond, label);

View File

@ -649,6 +649,38 @@ MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label)
j(cond, label); j(cond, label);
} }
void
MacroAssembler::branchTestNull(Condition cond, Register tag, Label* label)
{
branchTestNullImpl(cond, tag, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const Address& address, Label* label)
{
branchTestNullImpl(cond, address, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* label)
{
branchTestNullImpl(cond, address, label);
}
void
MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* label)
{
branchTestNullImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label)
{
cond = testNull(cond, t);
j(cond, label);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

View File

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