зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1319388 - Add add32ToPtrWithPatch and patchAdd32ToPtr to MacroAssembler. r=jandem
--HG-- extra : rebase_source : a50b733c713c75916e66d5635beda3e60bd1bc73
This commit is contained in:
Родитель
7fca5ff6dd
Коммит
1f34a22bc4
|
@ -779,6 +779,13 @@ class MacroAssembler : public MacroAssemblerSpecific
|
|||
|
||||
inline void addFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH;
|
||||
|
||||
// Compute dest=src+imm where `src` and `dest` are pointer registers; `src`
|
||||
// may be SP, and `src` may equal `dest`. `dest` should not normally be SP,
|
||||
// as stack probes are required for large negative immediates. The offset
|
||||
// returned from add32ToPtrWithPatch() must be passed to patchAdd32ToPtr().
|
||||
inline CodeOffset add32ToPtrWithPatch(Register src, Register dest) PER_ARCH;
|
||||
inline void patchAdd32ToPtr(CodeOffset offset, Imm32 imm) PER_ARCH;
|
||||
|
||||
inline void addDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH;
|
||||
inline void addConstantDouble(double d, FloatRegister dest) DEFINED_ON(x86);
|
||||
|
||||
|
|
|
@ -309,6 +309,24 @@ MacroAssembler::add64(Imm64 imm, Register64 dest)
|
|||
ma_adc(imm.hi(), dest.high, scratch, LeaveCC);
|
||||
}
|
||||
|
||||
CodeOffset
|
||||
MacroAssembler::add32ToPtrWithPatch(Register src, Register dest)
|
||||
{
|
||||
ScratchRegisterScope scratch(*this);
|
||||
CodeOffset offs = CodeOffset(currentOffset());
|
||||
ma_movPatchable(Imm32(0), scratch, Always);
|
||||
ma_add(src, scratch, dest);
|
||||
return offs;
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::patchAdd32ToPtr(CodeOffset offset, Imm32 imm)
|
||||
{
|
||||
ScratchRegisterScope scratch(*this);
|
||||
ma_mov_patch(imm, scratch, Always,
|
||||
HasMOVWT() ? L_MOVWT : L_LDR, offsetToInstruction(offset));
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::addDouble(FloatRegister src, FloatRegister dest)
|
||||
{
|
||||
|
|
|
@ -375,6 +375,12 @@ MacroAssemblerARM::ma_mov_patch(ImmPtr imm, Register dest, Assembler::Condition
|
|||
ma_mov_patch(Imm32(int32_t(imm.value)), dest, c, rs, i);
|
||||
}
|
||||
|
||||
Instruction*
|
||||
MacroAssemblerARM::offsetToInstruction(CodeOffset offs)
|
||||
{
|
||||
return editSrc(BufferOffset(offs.offset()));
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssemblerARM::ma_mov(Register src, Register dest, SBit s, Assembler::Condition c)
|
||||
{
|
||||
|
|
|
@ -130,6 +130,8 @@ class MacroAssemblerARM : public Assembler
|
|||
static void ma_mov_patch(ImmPtr imm, Register dest, Assembler::Condition c,
|
||||
RelocStyle rs, Instruction* i);
|
||||
|
||||
Instruction* offsetToInstruction(CodeOffset offs);
|
||||
|
||||
// ALU based ops
|
||||
// mov
|
||||
void ma_mov(Register src, Register dest, SBit s = LeaveCC, Condition c = Always);
|
||||
|
|
|
@ -312,6 +312,18 @@ MacroAssembler::add64(Imm64 imm, Register64 dest)
|
|||
Add(ARMRegister(dest.reg, 64), ARMRegister(dest.reg, 64), Operand(imm.value));
|
||||
}
|
||||
|
||||
CodeOffset
|
||||
MacroAssembler::add32ToPtrWithPatch(Register src, Register dest)
|
||||
{
|
||||
MOZ_CRASH("NYI - add32ToPtrWithPatch");
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::patchAdd32ToPtr(CodeOffset offset, Imm32 imm)
|
||||
{
|
||||
MOZ_CRASH("NYI - patchAdd32ToPtr");
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::addDouble(FloatRegister src, FloatRegister dest)
|
||||
{
|
||||
|
|
|
@ -163,6 +163,18 @@ MacroAssembler::add64(Imm64 imm, Register64 dest)
|
|||
ma_addu(dest.high, dest.high, imm.hi());
|
||||
}
|
||||
|
||||
CodeOffset
|
||||
MacroAssembler::add32ToPtrWithPatch(Register src, Register dest)
|
||||
{
|
||||
MOZ_CRASH("NYI - add32ToPtrWithPatch");
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::patchAdd32ToPtr(CodeOffset offset, Imm32 imm)
|
||||
{
|
||||
MOZ_CRASH("NYI - patchAdd32ToPtr");
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::subPtr(Register src, Register dest)
|
||||
{
|
||||
|
|
|
@ -200,6 +200,18 @@ MacroAssembler::add64(Imm64 imm, Register64 dest)
|
|||
ma_daddu(dest.reg, ScratchRegister);
|
||||
}
|
||||
|
||||
CodeOffset
|
||||
MacroAssembler::add32ToPtrWithPatch(Register src, Register dest)
|
||||
{
|
||||
MOZ_CRASH("NYI - add32ToPtrWithPatch");
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::patchAdd32ToPtr(CodeOffset offset, Imm32 imm)
|
||||
{
|
||||
MOZ_CRASH("NYI - patchAdd32ToPtr");
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::subPtr(Register src, Register dest)
|
||||
{
|
||||
|
|
|
@ -360,6 +360,11 @@ class Assembler : public AssemblerX86Shared
|
|||
return movWithPatch(ImmWord(uintptr_t(imm.value)), dest);
|
||||
}
|
||||
|
||||
// This is for patching during code generation, not after.
|
||||
void patchAddq(CodeOffset offset, int32_t n) {
|
||||
X86Encoding::SetInt32(masm.data() + offset.offset(), n);
|
||||
}
|
||||
|
||||
// Load an ImmWord value into a register. Note that this instruction will
|
||||
// attempt to optimize its immediate field size. When a full 64-bit
|
||||
// immediate is needed for a relocation, use movWithPatch.
|
||||
|
@ -554,6 +559,10 @@ class Assembler : public AssemblerX86Shared
|
|||
void addq(Imm32 imm, Register dest) {
|
||||
masm.addq_ir(imm.value, dest.encoding());
|
||||
}
|
||||
CodeOffset addqWithPatch(Imm32 imm, Register dest) {
|
||||
masm.addq_i32r(imm.value, dest.encoding());
|
||||
return CodeOffset(masm.currentOffset());
|
||||
}
|
||||
void addq(Imm32 imm, const Operand& dest) {
|
||||
switch (dest.kind()) {
|
||||
case Operand::REG:
|
||||
|
|
|
@ -53,6 +53,17 @@ class BaseAssemblerX64 : public BaseAssembler
|
|||
}
|
||||
}
|
||||
|
||||
void addq_i32r(int32_t imm, RegisterID dst)
|
||||
{
|
||||
// 32-bit immediate always, for patching.
|
||||
spew("addq $0x%04x, %s", imm, GPReg64Name(dst));
|
||||
if (dst == rax)
|
||||
m_formatter.oneByteOp64(OP_ADD_EAXIv);
|
||||
else
|
||||
m_formatter.oneByteOp64(OP_GROUP1_EvIz, dst, GROUP1_OP_ADD);
|
||||
m_formatter.immediate32(imm);
|
||||
}
|
||||
|
||||
void addq_im(int32_t imm, int32_t offset, RegisterID base)
|
||||
{
|
||||
spew("addq $%d, " MEM_ob, imm, ADDR_ob(offset, base));
|
||||
|
|
|
@ -207,6 +207,21 @@ MacroAssembler::add64(Imm64 imm, Register64 dest)
|
|||
addPtr(ImmWord(imm.value), dest.reg);
|
||||
}
|
||||
|
||||
CodeOffset
|
||||
MacroAssembler::add32ToPtrWithPatch(Register src, Register dest)
|
||||
{
|
||||
if (src != dest)
|
||||
movePtr(src, dest);
|
||||
addqWithPatch(Imm32(0), dest);
|
||||
return CodeOffset(currentOffset());
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::patchAdd32ToPtr(CodeOffset offset, Imm32 imm)
|
||||
{
|
||||
patchAddq(offset, imm.value);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::subPtr(Register src, Register dest)
|
||||
{
|
||||
|
|
|
@ -1075,6 +1075,11 @@ class AssemblerX86Shared : public AssemblerShared
|
|||
X86Encoding::SetRel32(code + farJumpOffset, code + targetOffset);
|
||||
}
|
||||
|
||||
// This is for patching during code generation, not after.
|
||||
void patchAddl(CodeOffset offset, int32_t n) {
|
||||
X86Encoding::SetInt32(masm.data() + offset.offset(), n);
|
||||
}
|
||||
|
||||
CodeOffset twoByteNop() {
|
||||
return CodeOffset(masm.twoByteNop().offset());
|
||||
}
|
||||
|
|
|
@ -191,6 +191,21 @@ MacroAssembler::addConstantDouble(double d, FloatRegister dest)
|
|||
propagateOOM(dbl->uses.append(CodeOffset(masm.size())));
|
||||
}
|
||||
|
||||
CodeOffset
|
||||
MacroAssembler::add32ToPtrWithPatch(Register src, Register dest)
|
||||
{
|
||||
if (src != dest)
|
||||
movePtr(src, dest);
|
||||
addlWithPatch(Imm32(0), dest);
|
||||
return CodeOffset(currentOffset());
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::patchAdd32ToPtr(CodeOffset offset, Imm32 imm)
|
||||
{
|
||||
patchAddl(offset, imm.value);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::subPtr(Register src, Register dest)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче