mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset cb37e43c52e7 (bug 1245112)
This commit is contained in:
parent
733588631f
commit
1c43930c52
@ -320,107 +320,6 @@ MacroAssembler::addPtr(ImmPtr imm, Register dest)
|
||||
//}}} check_macroassembler_style
|
||||
// ===============================================================
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchIfFalseBool(Register reg, L label)
|
||||
{
|
||||
// Note that C++ bool is only 1 byte, so ignore the higher-order bits.
|
||||
branchTest32(Assembler::Zero, reg, Imm32(0xFF), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchIfTrueBool(Register reg, Label* label)
|
||||
{
|
||||
// Note that C++ bool is only 1 byte, so ignore the higher-order bits.
|
||||
branchTest32(Assembler::NonZero, reg, Imm32(0xFF), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchIfRope(Register str, Label* label)
|
||||
{
|
||||
Address flags(str, JSString::offsetOfFlags());
|
||||
static_assert(JSString::ROPE_FLAGS == 0, "Rope type flags must be 0");
|
||||
branchTest32(Assembler::Zero, flags, Imm32(JSString::TYPE_FLAGS_MASK), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchLatin1String(Register string, Label* label)
|
||||
{
|
||||
branchTest32(Assembler::NonZero, Address(string, JSString::offsetOfFlags()),
|
||||
Imm32(JSString::LATIN1_CHARS_BIT), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTwoByteString(Register string, Label* label)
|
||||
{
|
||||
branchTest32(Assembler::Zero, Address(string, JSString::offsetOfFlags()),
|
||||
Imm32(JSString::LATIN1_CHARS_BIT), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchIfFunctionHasNoScript(Register fun, Label* label)
|
||||
{
|
||||
// 16-bit loads are slow and unaligned 32-bit loads may be too so
|
||||
// perform an aligned 32-bit load and adjust the bitmask accordingly.
|
||||
MOZ_ASSERT(JSFunction::offsetOfNargs() % sizeof(uint32_t) == 0);
|
||||
MOZ_ASSERT(JSFunction::offsetOfFlags() == JSFunction::offsetOfNargs() + 2);
|
||||
Address address(fun, JSFunction::offsetOfNargs());
|
||||
int32_t bit = IMM32_16ADJ(JSFunction::INTERPRETED);
|
||||
branchTest32(Assembler::Zero, address, Imm32(bit), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchIfInterpreted(Register fun, Label* label)
|
||||
{
|
||||
// 16-bit loads are slow and unaligned 32-bit loads may be too so
|
||||
// perform an aligned 32-bit load and adjust the bitmask accordingly.
|
||||
MOZ_ASSERT(JSFunction::offsetOfNargs() % sizeof(uint32_t) == 0);
|
||||
MOZ_ASSERT(JSFunction::offsetOfFlags() == JSFunction::offsetOfNargs() + 2);
|
||||
Address address(fun, JSFunction::offsetOfNargs());
|
||||
int32_t bit = IMM32_16ADJ(JSFunction::INTERPRETED);
|
||||
branchTest32(Assembler::NonZero, address, Imm32(bit), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTestNeedsIncrementalBarrier(Condition cond, Label* label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero);
|
||||
CompileZone* zone = GetJitContext()->compartment->zone();
|
||||
AbsoluteAddress needsBarrierAddr(zone->addressOfNeedsIncrementalBarrier());
|
||||
branchTest32(cond, needsBarrierAddr, Imm32(0x1), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTestObjectTruthy(bool truthy, Register objReg, Register scratch,
|
||||
Label* slowCheck, Label* checked)
|
||||
{
|
||||
// The branches to out-of-line code here implement a conservative version
|
||||
// of the JSObject::isWrapper test performed in EmulatesUndefined. If none
|
||||
// of the branches are taken, we can check class flags directly.
|
||||
loadObjClass(objReg, scratch);
|
||||
Address flags(scratch, Class::offsetOfFlags());
|
||||
|
||||
branchTestClassIsProxy(true, scratch, slowCheck);
|
||||
|
||||
Condition cond = truthy ? Assembler::Zero : Assembler::NonZero;
|
||||
branchTest32(cond, flags, Imm32(JSCLASS_EMULATES_UNDEFINED), checked);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTestClassIsProxy(bool proxy, Register clasp, Label* label)
|
||||
{
|
||||
branchTest32(proxy ? Assembler::NonZero : Assembler::Zero,
|
||||
Address(clasp, Class::offsetOfFlags()),
|
||||
Imm32(JSCLASS_IS_PROXY), label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTestObjectIsProxy(bool proxy, Register object, Register scratch, Label* label)
|
||||
{
|
||||
loadObjClass(object, scratch);
|
||||
branchTestClassIsProxy(proxy, scratch, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchFunctionKind(Condition cond, JSFunction::FunctionKind kind, Register fun,
|
||||
Register scratch, Label* label)
|
||||
|
@ -841,14 +841,6 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
// boxed inside a js::Value, with a raw pointer (rhs).
|
||||
inline void branchPrivatePtr(Condition cond, const Address& lhs, Register rhs, Label* label) PER_ARCH;
|
||||
|
||||
template <class L>
|
||||
inline void branchTest32(Condition cond, Register lhs, Register rhs, L label) PER_SHARED_ARCH;
|
||||
template <class L>
|
||||
inline void branchTest32(Condition cond, Register lhs, Imm32 rhs, L label) PER_SHARED_ARCH;
|
||||
inline void branchTest32(Condition cond, const Address& lhs, Imm32 rhh, Label* label) PER_SHARED_ARCH;
|
||||
inline void branchTest32(Condition cond, const AbsoluteAddress& lhs, Imm32 rhs, Label* label)
|
||||
DEFINED_ON(arm, arm64, mips_shared, x86, x64);
|
||||
|
||||
inline void branchTestPtr(Condition cond, Register lhs, Register rhs, Label* label) PER_SHARED_ARCH;
|
||||
inline void branchTestPtr(Condition cond, Register lhs, Imm32 rhs, Label* label) PER_SHARED_ARCH;
|
||||
inline void branchTestPtr(Condition cond, const Address& lhs, Imm32 rhs, Label* label) PER_SHARED_ARCH;
|
||||
@ -913,10 +905,16 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
|
||||
// Branches to |label| if |reg| is false. |reg| should be a C++ bool.
|
||||
template <class L>
|
||||
inline void branchIfFalseBool(Register reg, L label);
|
||||
void branchIfFalseBool(Register reg, L label) {
|
||||
// Note that C++ bool is only 1 byte, so ignore the higher-order bits.
|
||||
branchTest32(Assembler::Zero, reg, Imm32(0xFF), label);
|
||||
}
|
||||
|
||||
// Branches to |label| if |reg| is true. |reg| should be a C++ bool.
|
||||
inline void branchIfTrueBool(Register reg, Label* label);
|
||||
void branchIfTrueBool(Register reg, Label* label) {
|
||||
// Note that C++ bool is only 1 byte, so ignore the higher-order bits.
|
||||
branchTest32(Assembler::NonZero, reg, Imm32(0xFF), label);
|
||||
}
|
||||
|
||||
void loadObjPrivate(Register obj, uint32_t nfixed, Register dest) {
|
||||
loadPtr(Address(obj, NativeObject::getPrivateDataOffset(nfixed)), dest);
|
||||
@ -934,10 +932,20 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
void loadStringChars(Register str, Register dest);
|
||||
void loadStringChar(Register str, Register index, Register output);
|
||||
|
||||
inline void branchIfRope(Register str, Label* label);
|
||||
void branchIfRope(Register str, Label* label) {
|
||||
Address flags(str, JSString::offsetOfFlags());
|
||||
static_assert(JSString::ROPE_FLAGS == 0, "Rope type flags must be 0");
|
||||
branchTest32(Assembler::Zero, flags, Imm32(JSString::TYPE_FLAGS_MASK), label);
|
||||
}
|
||||
|
||||
inline void branchLatin1String(Register string, Label* label);
|
||||
inline void branchTwoByteString(Register string, Label* label);
|
||||
void branchLatin1String(Register string, Label* label) {
|
||||
branchTest32(Assembler::NonZero, Address(string, JSString::offsetOfFlags()),
|
||||
Imm32(JSString::LATIN1_CHARS_BIT), label);
|
||||
}
|
||||
void branchTwoByteString(Register string, Label* label) {
|
||||
branchTest32(Assembler::Zero, Address(string, JSString::offsetOfFlags()),
|
||||
Imm32(JSString::LATIN1_CHARS_BIT), label);
|
||||
}
|
||||
|
||||
void loadJSContext(Register dest) {
|
||||
loadPtr(AbsoluteAddress(GetJitContext()->runtime->addressOfJSContext()), dest);
|
||||
@ -1056,8 +1064,24 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
return extractObject(source, scratch);
|
||||
}
|
||||
|
||||
inline void branchIfFunctionHasNoScript(Register fun, Label* label);
|
||||
inline void branchIfInterpreted(Register fun, Label* label);
|
||||
void branchIfFunctionHasNoScript(Register fun, Label* label) {
|
||||
// 16-bit loads are slow and unaligned 32-bit loads may be too so
|
||||
// perform an aligned 32-bit load and adjust the bitmask accordingly.
|
||||
MOZ_ASSERT(JSFunction::offsetOfNargs() % sizeof(uint32_t) == 0);
|
||||
MOZ_ASSERT(JSFunction::offsetOfFlags() == JSFunction::offsetOfNargs() + 2);
|
||||
Address address(fun, JSFunction::offsetOfNargs());
|
||||
int32_t bit = IMM32_16ADJ(JSFunction::INTERPRETED);
|
||||
branchTest32(Assembler::Zero, address, Imm32(bit), label);
|
||||
}
|
||||
void branchIfInterpreted(Register fun, Label* label) {
|
||||
// 16-bit loads are slow and unaligned 32-bit loads may be too so
|
||||
// perform an aligned 32-bit load and adjust the bitmask accordingly.
|
||||
MOZ_ASSERT(JSFunction::offsetOfNargs() % sizeof(uint32_t) == 0);
|
||||
MOZ_ASSERT(JSFunction::offsetOfFlags() == JSFunction::offsetOfNargs() + 2);
|
||||
Address address(fun, JSFunction::offsetOfNargs());
|
||||
int32_t bit = IMM32_16ADJ(JSFunction::INTERPRETED);
|
||||
branchTest32(Assembler::NonZero, address, Imm32(bit), label);
|
||||
}
|
||||
|
||||
void branchIfNotInterpretedConstructor(Register fun, Register scratch, Label* label);
|
||||
|
||||
@ -1078,7 +1102,12 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
branch32(cond, length, Imm32(key.constant()), label);
|
||||
}
|
||||
|
||||
inline void branchTestNeedsIncrementalBarrier(Condition cond, Label* label);
|
||||
void branchTestNeedsIncrementalBarrier(Condition cond, Label* label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero);
|
||||
CompileZone* zone = GetJitContext()->compartment->zone();
|
||||
AbsoluteAddress needsBarrierAddr(zone->addressOfNeedsIncrementalBarrier());
|
||||
branchTest32(cond, needsBarrierAddr, Imm32(0x1), label);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void callPreBarrier(const T& address, MIRType type) {
|
||||
@ -1267,12 +1296,33 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
// Generates code used to complete a bailout.
|
||||
void generateBailoutTail(Register scratch, Register bailoutInfo);
|
||||
|
||||
inline void branchTestObjectTruthy(bool truthy, Register objReg, Register scratch,
|
||||
Label* slowCheck, Label* checked);
|
||||
void branchTestObjectTruthy(bool truthy, Register objReg, Register scratch,
|
||||
Label* slowCheck, Label* checked)
|
||||
{
|
||||
// The branches to out-of-line code here implement a conservative version
|
||||
// of the JSObject::isWrapper test performed in EmulatesUndefined. If none
|
||||
// of the branches are taken, we can check class flags directly.
|
||||
loadObjClass(objReg, scratch);
|
||||
Address flags(scratch, Class::offsetOfFlags());
|
||||
|
||||
inline void branchTestClassIsProxy(bool proxy, Register clasp, Label* label);
|
||||
branchTestClassIsProxy(true, scratch, slowCheck);
|
||||
|
||||
inline void branchTestObjectIsProxy(bool proxy, Register object, Register scratch, Label* label);
|
||||
Condition cond = truthy ? Assembler::Zero : Assembler::NonZero;
|
||||
branchTest32(cond, flags, Imm32(JSCLASS_EMULATES_UNDEFINED), checked);
|
||||
}
|
||||
|
||||
void branchTestClassIsProxy(bool proxy, Register clasp, Label* label)
|
||||
{
|
||||
branchTest32(proxy ? Assembler::NonZero : Assembler::Zero,
|
||||
Address(clasp, Class::offsetOfFlags()),
|
||||
Imm32(JSCLASS_IS_PROXY), label);
|
||||
}
|
||||
|
||||
void branchTestObjectIsProxy(bool proxy, Register object, Register scratch, Label* label)
|
||||
{
|
||||
loadObjClass(object, scratch);
|
||||
branchTestClassIsProxy(proxy, scratch, label);
|
||||
}
|
||||
|
||||
inline void branchFunctionKind(Condition cond, JSFunction::FunctionKind kind, Register fun,
|
||||
Register scratch, Label* label);
|
||||
|
@ -575,47 +575,6 @@ MacroAssembler::branchPrivatePtr(Condition cond, const Address& lhs, Register rh
|
||||
branchPtr(cond, lhs, rhs, label);
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
// x86 likes test foo, foo rather than cmp foo, #0.
|
||||
// Convert the former into the latter.
|
||||
if (lhs == rhs && (cond == Zero || cond == NonZero))
|
||||
ma_cmp(lhs, Imm32(0));
|
||||
else
|
||||
ma_tst(lhs, rhs);
|
||||
ma_b(label, cond);
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, Register lhs, Imm32 rhs, L label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
ma_tst(lhs, rhs);
|
||||
ma_b(label, cond);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const Address& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
// branchTest32 will use ScratchRegister.
|
||||
AutoRegisterScope scratch2(*this, secondScratchReg_);
|
||||
load32(lhs, scratch2);
|
||||
branchTest32(cond, scratch2, rhs, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const AbsoluteAddress& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
// branchTest32 will use ScratchRegister.
|
||||
AutoRegisterScope scratch2(*this, secondScratchReg_);
|
||||
load32(lhs, scratch2);
|
||||
branchTest32(cond, scratch2, rhs, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTestPtr(Condition cond, Register lhs, Register rhs, Label* label)
|
||||
{
|
||||
|
@ -836,6 +836,35 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
|
||||
Condition c = testStringTruthy(truthy, value);
|
||||
ma_b(label, c);
|
||||
}
|
||||
template <class L>
|
||||
void branchTest32(Condition cond, Register lhs, Register rhs, L label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
// x86 likes test foo, foo rather than cmp foo, #0.
|
||||
// Convert the former into the latter.
|
||||
if (lhs == rhs && (cond == Zero || cond == NonZero))
|
||||
ma_cmp(lhs, Imm32(0));
|
||||
else
|
||||
ma_tst(lhs, rhs);
|
||||
ma_b(label, cond);
|
||||
}
|
||||
template <class L>
|
||||
void branchTest32(Condition cond, Register lhs, Imm32 imm, L label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
ma_tst(lhs, imm);
|
||||
ma_b(label, cond);
|
||||
}
|
||||
void branchTest32(Condition cond, const Address& address, Imm32 imm, Label* label) {
|
||||
// branchTest32 will use ScratchRegister.
|
||||
AutoRegisterScope scratch2(asMasm(), secondScratchReg_);
|
||||
load32(address, scratch2);
|
||||
branchTest32(cond, scratch2, imm, label);
|
||||
}
|
||||
void branchTest32(Condition cond, AbsoluteAddress address, Imm32 imm, Label* label) {
|
||||
// branchTest32 will use ScratchRegister.
|
||||
AutoRegisterScope scratch2(asMasm(), secondScratchReg_);
|
||||
load32(address, scratch2);
|
||||
branchTest32(cond, scratch2, imm, label);
|
||||
}
|
||||
void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label) {
|
||||
ma_sub(imm, lhs, SetCC);
|
||||
as_b(label, cond);
|
||||
|
@ -652,48 +652,6 @@ MacroAssembler::branchPrivatePtr(Condition cond, const Address& lhs, Register rh
|
||||
branchPtr(cond, lhs, scratch, label);
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
// x86 prefers |test foo, foo| to |cmp foo, #0|.
|
||||
// Convert the former to the latter for ARM.
|
||||
if (lhs == rhs && (cond == Zero || cond == NonZero))
|
||||
cmp32(lhs, Imm32(0));
|
||||
else
|
||||
test32(lhs, rhs);
|
||||
B(label, cond);
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, Register lhs, Imm32 rhs, L label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(lhs, rhs);
|
||||
B(label, cond);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const Address& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
vixl::UseScratchRegisterScope temps(this);
|
||||
const Register scratch = temps.AcquireX().asUnsized();
|
||||
MOZ_ASSERT(scratch != lhs.base);
|
||||
load32(lhs, scratch);
|
||||
branchTest32(cond, scratch, rhs, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const AbsoluteAddress& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
vixl::UseScratchRegisterScope temps(this);
|
||||
const Register scratch = temps.AcquireX().asUnsized();
|
||||
load32(lhs, scratch);
|
||||
branchTest32(cond, scratch, rhs, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTestPtr(Condition cond, Register lhs, Register rhs, Label* label)
|
||||
{
|
||||
|
@ -1355,6 +1355,36 @@ class MacroAssemblerCompat : public vixl::MacroAssembler
|
||||
addPendingJump(loc, ImmPtr(target->raw()), Relocation::JITCODE);
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void branchTest32(Condition cond, Register lhs, Register rhs, L label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
// x86 prefers |test foo, foo| to |cmp foo, #0|.
|
||||
// Convert the former to the latter for ARM.
|
||||
if (lhs == rhs && (cond == Zero || cond == NonZero))
|
||||
cmp32(lhs, Imm32(0));
|
||||
else
|
||||
test32(lhs, rhs);
|
||||
B(label, cond);
|
||||
}
|
||||
template <class L>
|
||||
void branchTest32(Condition cond, Register lhs, Imm32 imm, L label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(lhs, imm);
|
||||
B(label, cond);
|
||||
}
|
||||
void branchTest32(Condition cond, const Address& address, Imm32 imm, Label* label) {
|
||||
vixl::UseScratchRegisterScope temps(this);
|
||||
const Register scratch = temps.AcquireX().asUnsized();
|
||||
MOZ_ASSERT(scratch != address.base);
|
||||
load32(address, scratch);
|
||||
branchTest32(cond, scratch, imm, label);
|
||||
}
|
||||
void branchTest32(Condition cond, AbsoluteAddress address, Imm32 imm, Label* label) {
|
||||
vixl::UseScratchRegisterScope temps(this);
|
||||
const Register scratch = temps.AcquireX().asUnsized();
|
||||
loadPtr(address, scratch);
|
||||
branchTest32(cond, scratch, imm, label);
|
||||
}
|
||||
CodeOffsetJump jumpWithPatch(RepatchLabel* label, Condition cond = Always,
|
||||
Label* documentation = nullptr)
|
||||
{
|
||||
|
@ -345,41 +345,6 @@ MacroAssembler::branchPtr(Condition cond, wasm::SymbolicAddress lhs, Register rh
|
||||
branchPtr(cond, SecondScratchReg, rhs, label);
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
if (lhs == rhs) {
|
||||
ma_b(lhs, rhs, label, cond);
|
||||
} else {
|
||||
as_and(ScratchRegister, lhs, rhs);
|
||||
ma_b(ScratchRegister, ScratchRegister, label, cond);
|
||||
}
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, Register lhs, Imm32 rhs, L label)
|
||||
{
|
||||
ma_li(ScratchRegister, rhs);
|
||||
branchTest32(cond, lhs, ScratchRegister, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const Address& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
load32(lhs, SecondScratchReg);
|
||||
branchTest32(cond, SecondScratchReg, rhs, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const AbsoluteAddress& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
load32(lhs, ScratchRegister);
|
||||
branchTest32(cond, ScratchRegister, rhs, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTestPtr(Condition cond, Register lhs, Register rhs, Label* label)
|
||||
{
|
||||
|
@ -437,6 +437,27 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS
|
||||
|
||||
void branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label);
|
||||
|
||||
void branchTest32(Condition cond, Register lhs, Register rhs, Label* label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
if (lhs == rhs) {
|
||||
ma_b(lhs, rhs, label, cond);
|
||||
} else {
|
||||
as_and(ScratchRegister, lhs, rhs);
|
||||
ma_b(ScratchRegister, ScratchRegister, label, cond);
|
||||
}
|
||||
}
|
||||
void branchTest32(Condition cond, Register lhs, Imm32 imm, Label* label) {
|
||||
ma_li(ScratchRegister, imm);
|
||||
branchTest32(cond, lhs, ScratchRegister, label);
|
||||
}
|
||||
void branchTest32(Condition cond, const Address& address, Imm32 imm, Label* label) {
|
||||
load32(address, SecondScratchReg);
|
||||
branchTest32(cond, SecondScratchReg, imm, label);
|
||||
}
|
||||
void branchTest32(Condition cond, AbsoluteAddress address, Imm32 imm, Label* label) {
|
||||
load32(address, ScratchRegister);
|
||||
branchTest32(cond, ScratchRegister, imm, label);
|
||||
}
|
||||
inline void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label);
|
||||
|
||||
// higher level tag testing code
|
||||
|
@ -478,6 +478,27 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64
|
||||
|
||||
void branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label);
|
||||
|
||||
void branchTest32(Condition cond, Register lhs, Register rhs, Label* label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
if (lhs == rhs) {
|
||||
ma_b(lhs, rhs, label, cond);
|
||||
} else {
|
||||
as_and(ScratchRegister, lhs, rhs);
|
||||
ma_b(ScratchRegister, ScratchRegister, label, cond);
|
||||
}
|
||||
}
|
||||
void branchTest32(Condition cond, Register lhs, Imm32 imm, Label* label) {
|
||||
ma_li(ScratchRegister, imm);
|
||||
branchTest32(cond, lhs, ScratchRegister, label);
|
||||
}
|
||||
void branchTest32(Condition cond, const Address& address, Imm32 imm, Label* label) {
|
||||
load32(address, SecondScratchReg);
|
||||
branchTest32(cond, SecondScratchReg, imm, label);
|
||||
}
|
||||
void branchTest32(Condition cond, AbsoluteAddress address, Imm32 imm, Label* label) {
|
||||
load32(address, ScratchRegister);
|
||||
branchTest32(cond, ScratchRegister, imm, label);
|
||||
}
|
||||
inline void decBranchPtr(Condition cond, Register lhs, Imm32 imm, Label* label);
|
||||
|
||||
// higher level tag testing code
|
||||
|
@ -244,6 +244,7 @@ class MacroAssemblerNone : public Assembler
|
||||
template <typename T, typename S> void cmpPtrSet(Condition, T, S, Register) { MOZ_CRASH(); }
|
||||
template <typename T, typename S> void cmp32Set(Condition, T, S, Register) { MOZ_CRASH(); }
|
||||
|
||||
template <typename T, typename S, typename L> void branchTest32(Condition, T, S, L) { MOZ_CRASH(); }
|
||||
template <typename T, typename S> void branchAdd32(Condition, T, S, Label*) { MOZ_CRASH(); }
|
||||
template <typename T, typename S> void branchSub32(Condition, T, S, Label*) { MOZ_CRASH(); }
|
||||
template <typename T, typename S> void branchDouble(DoubleCondition, T, S, Label*) { MOZ_CRASH(); }
|
||||
|
@ -298,19 +298,6 @@ MacroAssembler::branchPrivatePtr(Condition cond, const Address& lhs, Register rh
|
||||
branchPtr(cond, lhs, scratch, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const AbsoluteAddress& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
if (X86Encoding::IsAddressImmediate(lhs.addr)) {
|
||||
test32(Operand(lhs), rhs);
|
||||
} else {
|
||||
ScratchRegisterScope scratch(*this);
|
||||
mov(ImmPtr(lhs.addr), scratch);
|
||||
test32(Operand(scratch, 0), rhs);
|
||||
}
|
||||
j(cond, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Register temp,
|
||||
Label* label)
|
||||
|
@ -42,6 +42,7 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
|
||||
void bindOffsets(const MacroAssemblerX86Shared::UsesVector&);
|
||||
|
||||
public:
|
||||
using MacroAssemblerX86Shared::branchTest32;
|
||||
using MacroAssemblerX86Shared::load32;
|
||||
using MacroAssemblerX86Shared::store32;
|
||||
|
||||
@ -526,6 +527,17 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
|
||||
// Common interface.
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void branchTest32(Condition cond, AbsoluteAddress address, Imm32 imm, Label* label) {
|
||||
if (X86Encoding::IsAddressImmediate(address.addr)) {
|
||||
test32(Operand(address), imm);
|
||||
} else {
|
||||
ScratchRegisterScope scratch(asMasm());
|
||||
mov(ImmPtr(address.addr), scratch);
|
||||
test32(Operand(scratch, 0), imm);
|
||||
}
|
||||
j(cond, label);
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
inline void branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label);
|
||||
|
||||
|
@ -294,32 +294,6 @@ MacroAssembler::branchPtr(Condition cond, const Address& lhs, ImmWord rhs, Label
|
||||
branchPtrImpl(cond, lhs, rhs, label);
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, Register lhs, Register rhs, L label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(lhs, rhs);
|
||||
j(cond, label);
|
||||
}
|
||||
|
||||
template <class L>
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, Register lhs, Imm32 rhs, L label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(lhs, rhs);
|
||||
j(cond, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const Address& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(Operand(lhs), rhs);
|
||||
j(cond, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTestPtr(Condition cond, Register lhs, Register rhs, Label* label)
|
||||
{
|
||||
@ -344,19 +318,6 @@ MacroAssembler::branchTestPtr(Condition cond, const Address& lhs, Imm32 rhs, Lab
|
||||
//}}} check_macroassembler_style
|
||||
// ===============================================================
|
||||
|
||||
void
|
||||
MacroAssemblerX86Shared::clampIntToUint8(Register reg)
|
||||
{
|
||||
Label inRange;
|
||||
asMasm().branchTest32(Assembler::Zero, reg, Imm32(0xffffff00), &inRange);
|
||||
{
|
||||
sarl(Imm32(31), reg);
|
||||
notl(reg);
|
||||
andl(Imm32(255), reg);
|
||||
}
|
||||
bind(&inRange);
|
||||
}
|
||||
|
||||
} // namespace jit
|
||||
} // namespace js
|
||||
|
||||
|
@ -112,7 +112,7 @@ MacroAssemblerX86Shared::branchNegativeZero(FloatRegister reg,
|
||||
|
||||
// If reg is 1 or 3, input is negative zero.
|
||||
// If reg is 0 or 2, input is a normal zero.
|
||||
asMasm().branchTest32(NonZero, scratch, Imm32(1), label);
|
||||
branchTest32(NonZero, scratch, Imm32(1), label);
|
||||
|
||||
bind(&nonZero);
|
||||
#elif defined(JS_CODEGEN_X64)
|
||||
|
@ -572,6 +572,28 @@ class MacroAssemblerX86Shared : public Assembler
|
||||
testw(rhs, lhs);
|
||||
j(cond, label);
|
||||
}
|
||||
template <class L>
|
||||
void branchTest32(Condition cond, Register lhs, Register rhs, L label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(lhs, rhs);
|
||||
j(cond, label);
|
||||
}
|
||||
template <class L>
|
||||
void branchTest32(Condition cond, Register lhs, Imm32 imm, L label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(lhs, imm);
|
||||
j(cond, label);
|
||||
}
|
||||
void branchTest32(Condition cond, const Address& address, Imm32 imm, Label* label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(Operand(address), imm);
|
||||
j(cond, label);
|
||||
}
|
||||
void branchTest32(Condition cond, const Operand& lhs, Imm32 imm, Label* label) {
|
||||
MOZ_ASSERT(cond == Zero || cond == NonZero || cond == Signed || cond == NotSigned);
|
||||
test32(lhs, imm);
|
||||
j(cond, label);
|
||||
}
|
||||
|
||||
void jump(Label* label) {
|
||||
jmp(label);
|
||||
@ -1261,7 +1283,16 @@ class MacroAssemblerX86Shared : public Assembler
|
||||
j(Assembler::NotEqual, fail);
|
||||
}
|
||||
|
||||
inline void clampIntToUint8(Register reg);
|
||||
void clampIntToUint8(Register reg) {
|
||||
Label inRange;
|
||||
branchTest32(Assembler::Zero, reg, Imm32(0xffffff00), &inRange);
|
||||
{
|
||||
sarl(Imm32(31), reg);
|
||||
notl(reg);
|
||||
andl(Imm32(255), reg);
|
||||
}
|
||||
bind(&inRange);
|
||||
}
|
||||
|
||||
bool maybeInlineDouble(double d, FloatRegister dest) {
|
||||
uint64_t u = mozilla::BitwiseCast<uint64_t>(d);
|
||||
|
@ -304,13 +304,6 @@ MacroAssembler::branchPrivatePtr(Condition cond, const Address& lhs, Register rh
|
||||
branchPtr(cond, lhs, rhs, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest32(Condition cond, const AbsoluteAddress& lhs, Imm32 rhs, Label* label)
|
||||
{
|
||||
test32(Operand(lhs), rhs);
|
||||
j(cond, label);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Register temp,
|
||||
Label* label)
|
||||
|
@ -50,6 +50,7 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
|
||||
void setupABICall(uint32_t args);
|
||||
|
||||
public:
|
||||
using MacroAssemblerX86Shared::branchTest32;
|
||||
using MacroAssemblerX86Shared::load32;
|
||||
using MacroAssemblerX86Shared::store32;
|
||||
using MacroAssemblerX86Shared::call;
|
||||
@ -550,6 +551,11 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
|
||||
// Common interface.
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void branchTest32(Condition cond, AbsoluteAddress address, Imm32 imm, Label* label) {
|
||||
test32(Operand(address), imm);
|
||||
j(cond, label);
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
void branchPtr(Condition cond, T lhs, S ptr, RepatchLabel* label) {
|
||||
cmpPtr(Operand(lhs), ptr);
|
||||
|
Loading…
Reference in New Issue
Block a user