Bug 1364908 - Add MacroAssembler::branchToComputedAddress. r=jandem

This commit is contained in:
Nicolas B. Pierron 2017-07-18 12:08:22 +00:00
Родитель e1a4ed2946
Коммит d6ec64d163
6 изменённых файлов: 39 добавлений и 2 удалений

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

@ -1266,6 +1266,9 @@ class MacroAssembler : public MacroAssemblerSpecific
inline void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label)
DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
// Create an unconditional branch to the address given as argument.
inline void branchToComputedAddress(const BaseIndex& address) PER_ARCH;
private:
// Implementation for branch* methods.

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

@ -2057,6 +2057,21 @@ MacroAssembler::branchTestMagic(Condition cond, const Address& valaddr, JSWhyMag
branch32(cond, ToPayload(valaddr), Imm32(why), label);
}
void
MacroAssembler::branchToComputedAddress(const BaseIndex& addr)
{
MOZ_ASSERT(addr.base == pc, "Unsupported jump from any other addresses.");
MOZ_ASSERT(addr.offset == 0, "NYI: offsets from pc should be shifted by the number of instructions.");
Register base = addr.base;
uint32_t scale = Imm32::ShiftOf(addr.scale).value;
ma_ldr(DTRAddr(base, DtrRegImmShift(addr.index, LSL, scale)), pc);
// When loading from pc, the pc is shifted to the next instruction, we
// add one extra instruction to accomodate for this shifted offset.
breakpoint();
}
// ========================================================================
// Memory access primitives.
void

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

@ -1656,6 +1656,12 @@ MacroAssembler::branchTestMagic(Condition cond, const Address& valaddr, JSWhyMag
B(label, cond);
}
void
MacroAssembler::branchToComputedAddress(const BaseIndex& addr)
{
MOZ_CRASH("branchToComputedAddress");
}
// ========================================================================
// Memory access primitives.
void

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

@ -772,6 +772,13 @@ MacroAssembler::branchTestMagic(Condition cond, const Address& valaddr, JSWhyMag
cmpPtr(valaddr, ImmWord(magic));
j(cond, label);
}
void
MacroAssembler::branchToComputedAddress(const BaseIndex& address)
{
jmp(Operand(address));
}
// ========================================================================
// Truncate floating point.

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

@ -1871,10 +1871,10 @@ CodeGeneratorX86Shared::emitTableSwitchDispatch(MTableSwitch* mir, Register inde
// Compute the position where a pointer to the right case stands.
masm.mov(ool->jumpLabel()->patchAt(), base);
Operand pointer = Operand(base, index, ScalePointer);
BaseIndex pointer(base, index, ScalePointer);
// Jump to the right case
masm.jmp(pointer);
masm.branchToComputedAddress(pointer);
}
void

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

@ -922,6 +922,12 @@ MacroAssembler::branchTestMagic(Condition cond, const Address& valaddr, JSWhyMag
branch32(cond, ToPayload(valaddr), Imm32(why), label);
}
void
MacroAssembler::branchToComputedAddress(const BaseIndex& addr)
{
jmp(Operand(addr));
}
// ========================================================================
// Truncate floating point.