Bug 1245112 - Part 33: Move MacroAssembler::branchTestMagic into generic macro assembler. r=jandem

This commit is contained in:
Tooru Fujisawa 2016-03-03 08:03:45 +09:00
parent 63cc8e3c70
commit 087177007a
16 changed files with 148 additions and 111 deletions

View File

@ -934,6 +934,7 @@ class MacroAssembler : public MacroAssemblerSpecific
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;
inline void branchTestMagic(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.
@ -987,6 +988,12 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
inline void branchTestMagic(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH;
inline void branchTestMagic(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH;
template <class L>
inline void branchTestMagic(Condition cond, const ValueOperand& value, L 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)
@ -1032,6 +1039,9 @@ class MacroAssembler : public MacroAssemblerSpecific
template <typename T>
inline void branchTestPrimitiveImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
template <typename T, class L>
inline void branchTestMagicImpl(Condition cond, const T& t, L label)
DEFINED_ON(arm, arm64, x86_shared);
//}}} check_macroassembler_style
public:

View File

@ -1131,6 +1131,39 @@ MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label
ma_b(label, c);
}
void
MacroAssembler::branchTestMagic(Condition cond, Register tag, Label* label)
{
branchTestMagicImpl(cond, tag, label);
}
void
MacroAssembler::branchTestMagic(Condition cond, const Address& address, Label* label)
{
branchTestMagicImpl(cond, address, label);
}
void
MacroAssembler::branchTestMagic(Condition cond, const BaseIndex& address, Label* label)
{
branchTestMagicImpl(cond, address, label);
}
template <class L>
void
MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label)
{
branchTestMagicImpl(cond, value, label);
}
template <typename T, class L>
void
MacroAssembler::branchTestMagicImpl(Condition cond, const T& t, L label)
{
cond = testMagic(cond, t);
ma_b(label, cond);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -751,11 +751,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest);
void loadConstantFloat32(float f, FloatRegister dest);
template <typename T, class L>
void branchTestMagic(Condition cond, const T& t, L label) {
cond = testMagic(cond, t);
ma_b(label, cond);
}
void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why,
Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);

View File

@ -1230,6 +1230,39 @@ MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label
B(label, c);
}
void
MacroAssembler::branchTestMagic(Condition cond, Register tag, Label* label)
{
branchTestMagicImpl(cond, tag, label);
}
void
MacroAssembler::branchTestMagic(Condition cond, const Address& address, Label* label)
{
branchTestMagicImpl(cond, address, label);
}
void
MacroAssembler::branchTestMagic(Condition cond, const BaseIndex& address, Label* label)
{
branchTestMagicImpl(cond, address, label);
}
template <class L>
void
MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label)
{
branchTestMagicImpl(cond, value, label);
}
template <typename T, class L>
void
MacroAssembler::branchTestMagicImpl(Condition cond, const T& t, L label)
{
Condition c = testMagic(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, typename L>
void branchTestMagic(Condition cond, const T& t, L label) {
Condition c = testMagic(cond, t);
B(label, c);
}
void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
branchTestValue(cond, val, MagicValue(why), label);

View File

@ -713,6 +713,29 @@ MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label)
(cond == Equal) ? Below : AboveOrEqual);
}
void
MacroAssembler::branchTestMagic(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
void
MacroAssembler::branchTestMagic(Condition cond, const Address& address, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
extractTag(address, scratch2);
branchTestMagic(cond, scratch2, label);
}
void
MacroAssembler::branchTestMagic(Condition cond, const BaseIndex& address, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
extractTag(address, scratch2);
branchTestMagic(cond, scratch2, label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -380,6 +380,13 @@ MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, L
branchTestPrimitive(cond, value.typeReg(), label);
}
template <class L>
void
MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label)
{
ma_b(value.typeReg(), ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -1116,43 +1116,6 @@ MacroAssemblerMIPSCompat::testUndefinedSet(Condition cond, const ValueOperand& v
ma_cmp_set(dest, value.typeReg(), ImmType(JSVAL_TYPE_UNDEFINED), cond);
}
void
MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const ValueOperand& value, Label* label)
{
branchTestMagic(cond, value.typeReg(), label);
}
void
MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const ValueOperand& value,
wasm::JumpTarget target)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(value.typeReg(), ImmTag(JSVAL_TAG_MAGIC), target, cond);
}
void
MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
void
MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const Address& address, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(address, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
void
MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const BaseIndex& src, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(src, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
void
MacroAssemblerMIPSCompat::branchTestValue(Condition cond, const ValueOperand& value,
const Value& v, Label* label)

View File

@ -375,12 +375,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS
void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest);
void branchTestMagic(Condition cond, const ValueOperand& value, Label* label);
void branchTestMagic(Condition cond, const ValueOperand& value, wasm::JumpTarget target);
void branchTestMagic(Condition cond, Register tag, Label* label);
void branchTestMagic(Condition cond, const Address& address, Label* label);
void branchTestMagic(Condition cond, const BaseIndex& src, Label* label);
void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why,
Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);

View File

@ -337,6 +337,15 @@ MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, L
branchTestPrimitive(cond, scratch2, label);
}
template <class L>
void
MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label)
{
SecondScratchRegisterScope scratch2(*this);
splitTag(value, scratch2);
ma_b(scratch2, ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -1246,45 +1246,6 @@ MacroAssemblerMIPS64Compat::testUndefinedSet(Condition cond, const ValueOperand&
ma_cmp_set(dest, SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), cond);
}
void
MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const ValueOperand& value, Label* label)
{
splitTag(value, SecondScratchReg);
branchTestMagic(cond, SecondScratchReg, label);
}
void
MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const ValueOperand& value,
wasm::JumpTarget target)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
splitTag(value, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), target, cond);
}
void
MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
void
MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const Address& address, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(address, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
void
MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const BaseIndex& src, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
extractTag(src, SecondScratchReg);
ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), label, cond);
}
void
MacroAssemblerMIPS64Compat::branchTestValue(Condition cond, const ValueOperand& value,
const Value& v, Label* label)

View File

@ -416,12 +416,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64
void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest);
void branchTestMagic(Condition cond, const ValueOperand& value, Label* label);
void branchTestMagic(Condition cond, const ValueOperand& value, wasm::JumpTarget target);
void branchTestMagic(Condition cond, Register tag, Label* label);
void branchTestMagic(Condition cond, const Address& address, Label* label);
void branchTestMagic(Condition cond, const BaseIndex& src, Label* label);
void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why,
Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);

View File

@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler
Register splitTagForTest(ValueOperand) { 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(); }
void boxNonDouble(JSValueType, Register, ValueOperand) { MOZ_CRASH(); }

View File

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

View File

@ -753,6 +753,39 @@ MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label
j(cond, label);
}
void
MacroAssembler::branchTestMagic(Condition cond, Register tag, Label* label)
{
branchTestMagicImpl(cond, tag, label);
}
void
MacroAssembler::branchTestMagic(Condition cond, const Address& address, Label* label)
{
branchTestMagicImpl(cond, address, label);
}
void
MacroAssembler::branchTestMagic(Condition cond, const BaseIndex& address, Label* label)
{
branchTestMagicImpl(cond, address, label);
}
template <class L>
void
MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label)
{
branchTestMagicImpl(cond, value, label);
}
template <typename T, class L>
void
MacroAssembler::branchTestMagicImpl(Condition cond, const T& t, L label)
{
cond = testMagic(cond, t);
j(cond, label);
}
//}}} check_macroassembler_style
// ===============================================================

View File

@ -657,13 +657,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
movl(reg, Operand(esp, arg * sizeof(intptr_t)));
}
// Type testing instructions can take a tag in a register or a
// ValueOperand.
template <typename T, class L>
void branchTestMagic(Condition cond, const T& t, L label) {
cond = testMagic(cond, t);
j(cond, label);
}
void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why,
Label* label)
{