Bug 1245112 - Part 23: Move MacroAssembler::branchTestBoolean into generic macro assembler. r=sstangl

This commit is contained in:
Tooru Fujisawa 2016-03-03 08:03:42 +09:00
Родитель 7a23ca6f2e
Коммит c0652fed25
16 изменённых файлов: 145 добавлений и 128 удалений

Просмотреть файл

@ -927,6 +927,7 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestDouble(Condition cond, Register tag, Label* label) inline void branchTestDouble(Condition cond, Register tag, Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
inline void branchTestNumber(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestNumber(Condition cond, Register tag, Label* label) PER_SHARED_ARCH;
inline void branchTestBoolean(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.
@ -943,6 +944,11 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestNumber(Condition cond, const ValueOperand& value, Label* label) inline void branchTestNumber(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 branchTestBoolean(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH;
inline void branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH;
inline void branchTestBoolean(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)
@ -961,6 +967,9 @@ class MacroAssembler : public MacroAssemblerSpecific
template <typename T> template <typename T>
inline void branchTestNumberImpl(Condition cond, const T& t, Label* label) inline void branchTestNumberImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared); DEFINED_ON(arm, arm64, x86_shared);
template <typename T>
inline void branchTestBooleanImpl(Condition cond, const T& t, Label* label)
DEFINED_ON(arm, arm64, x86_shared);
//}}} check_macroassembler_style //}}} check_macroassembler_style
public: public:

Просмотреть файл

@ -897,6 +897,38 @@ MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label)
ma_b(label, cond); ma_b(label, cond);
} }
void
MacroAssembler::branchTestBoolean(Condition cond, Register tag, Label* label)
{
branchTestBooleanImpl(cond, tag, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const Address& address, Label* label)
{
branchTestBooleanImpl(cond, address, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Label* label)
{
branchTestBooleanImpl(cond, address, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label)
{
branchTestBooleanImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestBooleanImpl(Condition cond, const T& t, Label* label)
{
Condition c = testBoolean(cond, t);
ma_b(label, c);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

Просмотреть файл

@ -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 branchTestBoolean(Condition cond, const T & t, Label* label) {
Condition c = testBoolean(cond, t);
ma_b(label, c);
}
template<typename T> template<typename T>
void branchTestNull(Condition cond, const T & t, Label* label) { void branchTestNull(Condition cond, const T & t, Label* label) {
Condition c = testNull(cond, t); Condition c = testNull(cond, t);

Просмотреть файл

@ -996,6 +996,38 @@ MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label)
B(label, c); B(label, c);
} }
void
MacroAssembler::branchTestBoolean(Condition cond, Register tag, Label* label)
{
branchTestBooleanImpl(cond, tag, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const Address& address, Label* label)
{
branchTestBooleanImpl(cond, address, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Label* label)
{
branchTestBooleanImpl(cond, address, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label)
{
branchTestBooleanImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestBooleanImpl(Condition cond, const T& tag, Label* label)
{
Condition c = testBoolean(cond, tag);
B(label, c);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

Просмотреть файл

@ -1332,10 +1332,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
Condition c = testUndefined(cond, tag); Condition c = testUndefined(cond, tag);
B(label, c); B(label, c);
} }
void branchTestBoolean(Condition cond, Register tag, Label* label) {
Condition c = testBoolean(cond, tag);
B(label, c);
}
void branchTestNull(Condition cond, Register tag, Label* label) { void branchTestNull(Condition cond, Register tag, Label* label) {
Condition c = testNull(cond, tag); Condition c = testNull(cond, tag);
B(label, c); B(label, c);
@ -1357,10 +1353,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
Condition c = testUndefined(cond, address); Condition c = testUndefined(cond, address);
B(label, c); B(label, c);
} }
void branchTestBoolean(Condition cond, const Address& address, Label* label) {
Condition c = testDouble(cond, address);
B(label, c);
}
void branchTestNull(Condition cond, const Address& address, Label* label) { void branchTestNull(Condition cond, const Address& address, Label* label) {
Condition c = testNull(cond, address); Condition c = testNull(cond, address);
B(label, c); B(label, c);
@ -1384,10 +1376,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
Condition c = testUndefined(cond, src); Condition c = testUndefined(cond, src);
B(label, c); B(label, c);
} }
void branchTestBoolean(Condition cond, const ValueOperand& src, Label* label) {
Condition c = testBoolean(cond, src);
B(label, c);
}
void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { void branchTestNull(Condition cond, const ValueOperand& src, Label* label) {
Condition c = testNull(cond, src); Condition c = testNull(cond, src);
B(label, c); B(label, c);
@ -1411,10 +1399,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
Condition c = testUndefined(cond, address); Condition c = testUndefined(cond, address);
B(label, c); B(label, c);
} }
void branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) {
Condition c = testBoolean(cond, address);
B(label, c);
}
void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { void branchTestNull(Condition cond, const BaseIndex& address, Label* label) {
Condition c = testNull(cond, address); Condition c = testNull(cond, address);
B(label, c); B(label, c);

Просмотреть файл

@ -564,6 +564,29 @@ MacroAssembler::branchTestNumber(Condition cond, Register tag, Label* label)
ma_b(tag, ImmTag(JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET), label, actual); ma_b(tag, ImmTag(JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET), label, actual);
} }
void
MacroAssembler::branchTestBoolean(Condition cond, Register tag, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(tag, ImmTag(JSVAL_TAG_BOOLEAN), label, cond);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const Address& address, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
extractTag(address, scratch2);
branchTestBoolean(cond, scratch2, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Label* label)
{
SecondScratchRegisterScope scratch2(*this);
extractTag(address, scratch2);
branchTestBoolean(cond, scratch2, label);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

Просмотреть файл

@ -322,6 +322,13 @@ MacroAssembler::branchTestNumber(Condition cond, const ValueOperand& value, Labe
branchTestNumber(cond, value.typeReg(), label); branchTestNumber(cond, value.typeReg(), label);
} }
void
MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label)
{
MOZ_ASSERT(cond == Equal || cond == NotEqual);
ma_b(value.typeReg(), ImmType(JSVAL_TYPE_BOOLEAN), label, cond);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

Просмотреть файл

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

Просмотреть файл

@ -375,12 +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 branchTestBoolean(Condition cond, const ValueOperand& value, Label* label);
void branchTestBoolean(Condition cond, Register tag, Label* label);
void branchTestBoolean(Condition cond, const Address& address, Label* label);
void branchTestBoolean(Condition cond, const BaseIndex& src, Label* label);
void branchTestNull(Condition cond, const ValueOperand& value, Label* label); void branchTestNull(Condition cond, const ValueOperand& value, Label* label);
void branchTestNull(Condition cond, Register tag, Label* label); void branchTestNull(Condition cond, Register tag, Label* label);
void branchTestNull(Condition cond, const BaseIndex& src, Label* label); void branchTestNull(Condition cond, const BaseIndex& src, Label* label);

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -416,12 +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 branchTestBoolean(Condition cond, const ValueOperand& value, Label* label);
void branchTestBoolean(Condition cond, Register tag, Label* label);
void branchTestBoolean(Condition cond, const Address& address, Label* label);
void branchTestBoolean(Condition cond, const BaseIndex& src, Label* label);
void branchTestNull(Condition cond, const ValueOperand& value, Label* label); void branchTestNull(Condition cond, const ValueOperand& value, Label* label);
void branchTestNull(Condition cond, Register tag, Label* label); void branchTestNull(Condition cond, Register tag, Label* label);
void branchTestNull(Condition cond, const BaseIndex& src, Label* label); void branchTestNull(Condition cond, const BaseIndex& src, Label* label);

Просмотреть файл

@ -346,7 +346,6 @@ class MacroAssemblerNone : public Assembler
Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } Register splitTagForTest(ValueOperand) { MOZ_CRASH(); }
template <typename T> void branchTestUndefined(Condition, T, Label*) { MOZ_CRASH(); } template <typename T> void branchTestUndefined(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestBoolean(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestNull(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 branchTestString(Condition, T, Label*) { MOZ_CRASH(); }
template <typename T> void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); } template <typename T> void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); }

Просмотреть файл

@ -333,9 +333,8 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
return cond; return cond;
} }
Condition testBoolean(Condition cond, const Address& src) { Condition testBoolean(Condition cond, const Address& src) {
ScratchRegisterScope scratch(asMasm()); cmp32(ToUpper32(src), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_BOOLEAN))));
splitTag(src, scratch); return cond;
return testBoolean(cond, scratch);
} }
Condition testDouble(Condition cond, const Address& src) { Condition testDouble(Condition cond, const Address& src) {
ScratchRegisterScope scratch(asMasm()); ScratchRegisterScope scratch(asMasm());
@ -690,10 +689,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
cond = testUndefined(cond, tag); cond = testUndefined(cond, tag);
j(cond, label); j(cond, label);
} }
void branchTestBoolean(Condition cond, Register tag, Label* label) {
cond = testBoolean(cond, tag);
j(cond, label);
}
void branchTestNull(Condition cond, Register tag, Label* label) { void branchTestNull(Condition cond, Register tag, Label* label) {
cond = testNull(cond, tag); cond = testNull(cond, tag);
j(cond, label); j(cond, label);
@ -723,15 +718,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
MOZ_ASSERT(cond == Equal || cond == NotEqual); MOZ_ASSERT(cond == Equal || cond == NotEqual);
branchTestUndefined(cond, Operand(address), label); branchTestUndefined(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))));
j(cond, label);
}
void branchTestBoolean(Condition cond, const Address& address, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual);
branchTestBoolean(cond, Operand(address), label);
}
void branchTestNull(Condition cond, const Operand& operand, Label* label) { void branchTestNull(Condition cond, const Operand& operand, Label* label) {
MOZ_ASSERT(cond == Equal || cond == NotEqual); MOZ_ASSERT(cond == Equal || cond == NotEqual);
cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_NULL)))); cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_NULL))));
@ -754,11 +740,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
cond = testUndefined(cond, src); cond = testUndefined(cond, src);
j(cond, label); j(cond, label);
} }
void branchTestBoolean(Condition cond, const ValueOperand& src, Label* label) {
ScratchRegisterScope scratch(asMasm());
splitTag(src, scratch);
branchTestBoolean(cond, scratch, label);
}
void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { void branchTestNull(Condition cond, const ValueOperand& src, Label* label) {
cond = testNull(cond, src); cond = testNull(cond, src);
j(cond, label); j(cond, label);
@ -782,11 +763,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
cond = testUndefined(cond, address); cond = testUndefined(cond, address);
j(cond, label); j(cond, label);
} }
void branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) {
ScratchRegisterScope scratch(asMasm());
splitTag(address, scratch);
branchTestBoolean(cond, scratch, label);
}
void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { void branchTestNull(Condition cond, const BaseIndex& address, Label* label) {
cond = testNull(cond, address); cond = testNull(cond, address);
j(cond, label); j(cond, label);

Просмотреть файл

@ -526,6 +526,38 @@ MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label)
j(cond, label); j(cond, label);
} }
void
MacroAssembler::branchTestBoolean(Condition cond, Register tag, Label* label)
{
branchTestBooleanImpl(cond, tag, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const Address& address, Label* label)
{
branchTestBooleanImpl(cond, address, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Label* label)
{
branchTestBooleanImpl(cond, address, label);
}
void
MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label)
{
branchTestBooleanImpl(cond, value, label);
}
template <typename T>
void
MacroAssembler::branchTestBooleanImpl(Condition cond, const T& t, Label* label)
{
cond = testBoolean(cond, t);
j(cond, label);
}
//}}} check_macroassembler_style //}}} check_macroassembler_style
// =============================================================== // ===============================================================

Просмотреть файл

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