bug 894251: NEVER use mov to move the address of a call target. The tracer has no clue how to deal with a single instruction move (r=jandem)

This commit is contained in:
Marty Rosenberg 2013-07-26 03:50:22 -04:00
parent d6c5183f6b
commit c28ceb9e6f
2 changed files with 38 additions and 8 deletions

View File

@ -389,11 +389,11 @@ MacroAssemblerARM::ma_mov(const ImmGCPtr &ptr, Register dest)
// before to recover the pointer, and not after. // before to recover the pointer, and not after.
writeDataRelocation(ptr); writeDataRelocation(ptr);
RelocStyle rs; RelocStyle rs;
if (hasMOVWT()) { if (hasMOVWT())
rs = L_MOVWT; rs = L_MOVWT;
} else { else
rs = L_LDR; rs = L_LDR;
}
ma_movPatchable(Imm32(ptr.value), dest, Always, rs); ma_movPatchable(Imm32(ptr.value), dest, Always, rs);
} }
@ -1527,7 +1527,13 @@ MacroAssemblerARMCompat::callWithExitFrame(IonCode *target)
Push(Imm32(descriptor)); // descriptor Push(Imm32(descriptor)); // descriptor
addPendingJump(m_buffer.nextOffset(), target->raw(), Relocation::IONCODE); addPendingJump(m_buffer.nextOffset(), target->raw(), Relocation::IONCODE);
ma_mov(Imm32((int) target->raw()), ScratchRegister); RelocStyle rs;
if (hasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ma_movPatchable(Imm32((int) target->raw()), ScratchRegister, Always, rs);
ma_callIonHalfPush(ScratchRegister); ma_callIonHalfPush(ScratchRegister);
} }
@ -1539,7 +1545,13 @@ MacroAssemblerARMCompat::callWithExitFrame(IonCode *target, Register dynStack)
Push(dynStack); // descriptor Push(dynStack); // descriptor
addPendingJump(m_buffer.nextOffset(), target->raw(), Relocation::IONCODE); addPendingJump(m_buffer.nextOffset(), target->raw(), Relocation::IONCODE);
ma_mov(Imm32((int) target->raw()), ScratchRegister); RelocStyle rs;
if (hasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ma_movPatchable(Imm32((int) target->raw()), ScratchRegister, Always, rs);
ma_callIonHalfPush(ScratchRegister); ma_callIonHalfPush(ScratchRegister);
} }
@ -2970,7 +2982,13 @@ MacroAssemblerARM::ma_callIonHalfPush(const Register r)
void void
MacroAssemblerARM::ma_call(void *dest) MacroAssemblerARM::ma_call(void *dest)
{ {
ma_mov(Imm32((uint32_t)dest), CallReg); RelocStyle rs;
if (hasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ma_movPatchable(Imm32((uint32_t) dest), CallReg, Always, rs);
as_blx(CallReg); as_blx(CallReg);
} }

View File

@ -516,13 +516,25 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
void call(IonCode *c) { void call(IonCode *c) {
BufferOffset bo = m_buffer.nextOffset(); BufferOffset bo = m_buffer.nextOffset();
addPendingJump(bo, c->raw(), Relocation::IONCODE); addPendingJump(bo, c->raw(), Relocation::IONCODE);
ma_mov(Imm32((uint32_t)c->raw()), ScratchRegister); RelocStyle rs;
if (hasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ma_movPatchable(Imm32((int) c->raw()), ScratchRegister, Always, rs);
ma_callIonHalfPush(ScratchRegister); ma_callIonHalfPush(ScratchRegister);
} }
void branch(IonCode *c) { void branch(IonCode *c) {
BufferOffset bo = m_buffer.nextOffset(); BufferOffset bo = m_buffer.nextOffset();
addPendingJump(bo, c->raw(), Relocation::IONCODE); addPendingJump(bo, c->raw(), Relocation::IONCODE);
ma_mov(Imm32((uint32_t)c->raw()), ScratchRegister); RelocStyle rs;
if (hasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ma_movPatchable(Imm32((int) c->raw()), ScratchRegister, Always, rs);
ma_bx(ScratchRegister); ma_bx(ScratchRegister);
} }
void branch(const Register reg) { void branch(const Register reg) {