Bug 1230005: Factor out relocation style decision; r=jolesen

--HG--
extra : commitid : LVKXXdtWh52
extra : rebase_source : 03db54ccb02c5977ad31e50bfc58728c1e026b72
extra : histedit_source : 51187d41a6ff7db9b410ed506fa16d795da3a9ea
This commit is contained in:
Benjamin Bouvier 2015-12-23 23:06:15 +01:00
parent 0c72c57ef8
commit bcfe875382
5 changed files with 38 additions and 69 deletions

View File

@ -212,24 +212,24 @@ js::jit::maybeRD(Register r)
}
Register
js::jit::toRD(Instruction& i)
js::jit::toRD(Instruction i)
{
return Register::FromCode((i.encode() >> 12) & 0xf);
}
Register
js::jit::toR(Instruction& i)
js::jit::toR(Instruction i)
{
return Register::FromCode(i.encode() & 0xf);
}
Register
js::jit::toRM(Instruction& i)
js::jit::toRM(Instruction i)
{
return Register::FromCode((i.encode() >> 8) & 0xf);
}
Register
js::jit::toRN(Instruction& i)
js::jit::toRN(Instruction i)
{
return Register::FromCode((i.encode() >> 16) & 0xf);
}
@ -2996,7 +2996,6 @@ Assembler::RetargetFarBranch(Instruction* i, uint8_t** slot, uint8_t* dest, Cond
AutoFlushICache::flush(uintptr_t(i), 4);
}
*slot = dest;
}
struct PoolHeader : Instruction
@ -3092,12 +3091,13 @@ void
Assembler::PatchDataWithValueCheck(CodeLocationLabel label, PatchedImmPtr newValue,
PatchedImmPtr expectedValue)
{
Instruction* ptr = (Instruction*) label.raw();
Instruction* ptr = reinterpret_cast<Instruction*>(label.raw());
InstructionIterator iter(ptr);
Register dest;
Assembler::RelocStyle rs;
DebugOnly<const uint32_t*> val = GetPtr32Target(&iter, &dest, &rs);
MOZ_ASSERT((uint32_t)(const uint32_t*)val == uint32_t(expectedValue.value));
MOZ_ASSERT(uint32_t((const uint32_t*)val) == uint32_t(expectedValue.value));
MacroAssembler::ma_mov_patch(Imm32(int32_t(newValue.value)), dest, Always, rs, ptr);
@ -3111,7 +3111,9 @@ Assembler::PatchDataWithValueCheck(CodeLocationLabel label, PatchedImmPtr newVal
void
Assembler::PatchDataWithValueCheck(CodeLocationLabel label, ImmPtr newValue, ImmPtr expectedValue)
{
PatchDataWithValueCheck(label, PatchedImmPtr(newValue.value), PatchedImmPtr(expectedValue.value));
PatchDataWithValueCheck(label,
PatchedImmPtr(newValue.value),
PatchedImmPtr(expectedValue.value));
}
// This just stomps over memory with 32 bits of raw data. Its purpose is to

View File

@ -223,10 +223,10 @@ uint32_t maybeRD(Register r);
uint32_t maybeRT(Register r);
uint32_t maybeRN(Register r);
Register toRN (Instruction& i);
Register toRM (Instruction& i);
Register toRD (Instruction& i);
Register toR (Instruction& i);
Register toRN(Instruction i);
Register toRM(Instruction i);
Register toRD(Instruction i);
Register toR(Instruction i);
class VFPRegister;
uint32_t VD(VFPRegister vr);
@ -1238,7 +1238,7 @@ class Assembler : public AssemblerShared
uint8_t* inst, uint8_t* data, ARMBuffer::PoolEntry* pe = nullptr,
bool markAsBranch = false, bool loadToPC = false);
Instruction* editSrc (BufferOffset bo) {
Instruction* editSrc(BufferOffset bo) {
return m_buffer.getInst(bo);
}
@ -1933,11 +1933,15 @@ class Instruction
// This is not for defaulting to always, this is for instructions that
// cannot be made conditional, and have the usually invalid 4b1111 cond
// field.
Instruction (uint32_t data_, bool fake = false) : data(data_ | 0xf0000000) {
explicit Instruction(uint32_t data_, bool fake = false)
: data(data_ | 0xf0000000)
{
MOZ_ASSERT(fake || ((data_ & 0xf0000000) == 0));
}
// Standard constructor.
Instruction (uint32_t data_, Assembler::Condition c) : data(data_ | (uint32_t) c) {
Instruction(uint32_t data_, Assembler::Condition c)
: data(data_ | (uint32_t) c)
{
MOZ_ASSERT((data_ & 0xf0000000) == 0);
}
// You should never create an instruction directly. You should create a more
@ -1955,7 +1959,7 @@ class Instruction
template <class C>
C* as() const { return C::AsTHIS(*this); }
const Instruction & operator=(const Instruction& src) {
const Instruction& operator=(Instruction src) {
data = src.data;
return *this;
}
@ -2007,7 +2011,7 @@ class InstLDR : public InstDTR
{
public:
InstLDR(Index mode, Register rt, DTRAddr addr, Assembler::Condition c)
: InstDTR(IsLoad, IsWord, mode, rt, addr, c)
: InstDTR(IsLoad, IsWord, mode, rt, addr, c)
{ }
static bool IsTHIS(const Instruction& i);

View File

@ -424,26 +424,21 @@ MacroAssemblerARM::ma_nop()
}
void
MacroAssemblerARM::ma_movPatchable(Imm32 imm_, Register dest, Assembler::Condition c,
RelocStyle rs)
MacroAssemblerARM::ma_movPatchable(Imm32 imm_, Register dest, Assembler::Condition c)
{
int32_t imm = imm_.value;
switch(rs) {
case L_MOVWT:
if (HasMOVWT()) {
as_movw(dest, Imm16(imm & 0xffff), c);
as_movt(dest, Imm16(imm >> 16 & 0xffff), c);
break;
case L_LDR:
} else {
as_Imm32Pool(dest, imm, c);
break;
}
}
void
MacroAssemblerARM::ma_movPatchable(ImmPtr imm, Register dest, Assembler::Condition c,
RelocStyle rs)
MacroAssemblerARM::ma_movPatchable(ImmPtr imm, Register dest, Assembler::Condition c)
{
ma_movPatchable(Imm32(int32_t(imm.value)), dest, c, rs);
ma_movPatchable(Imm32(int32_t(imm.value)), dest, c);
}
/* static */ void
@ -503,13 +498,7 @@ MacroAssemblerARM::ma_mov(ImmGCPtr ptr, Register dest)
// As opposed to x86/x64 version, the data relocation has to be executed
// before to recover the pointer, and not after.
writeDataRelocation(ptr);
RelocStyle rs;
if (HasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ma_movPatchable(Imm32(uintptr_t(ptr.value)), dest, Always, rs);
ma_movPatchable(Imm32(uintptr_t(ptr.value)), dest, Always);
}
// Shifts (just a move with a shifting op2)
@ -1939,14 +1928,8 @@ MacroAssemblerARMCompat::movePtr(ImmPtr imm, Register dest)
void
MacroAssemblerARMCompat::movePtr(wasm::SymbolicAddress imm, Register dest)
{
RelocStyle rs;
if (HasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
append(AsmJSAbsoluteLink(CodeOffset(currentOffset()), imm));
ma_movPatchable(Imm32(-1), dest, Always, rs);
ma_movPatchable(Imm32(-1), dest, Always);
}
void
@ -3575,13 +3558,7 @@ MacroAssemblerARMCompat::storeTypeTag(ImmTag tag, const BaseIndex& dest)
void
MacroAssemblerARM::ma_call(ImmPtr dest)
{
RelocStyle rs;
if (HasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ma_movPatchable(dest, CallReg, Always, rs);
ma_movPatchable(dest, CallReg, Always);
as_blx(CallReg);
}
@ -3980,7 +3957,7 @@ MacroAssemblerARMCompat::toggledCall(JitCode* target, bool enabled)
BufferOffset bo = nextOffset();
addPendingJump(bo, ImmPtr(target->raw()), Relocation::JITCODE);
ScratchRegisterScope scratch(asMasm());
ma_movPatchable(ImmPtr(target->raw()), scratch, Always, HasMOVWT() ? L_MOVWT : L_LDR);
ma_movPatchable(ImmPtr(target->raw()), scratch, Always);
if (enabled)
ma_blx(scratch);
else
@ -4995,14 +4972,8 @@ MacroAssembler::call(JitCode* c)
{
BufferOffset bo = m_buffer.nextOffset();
addPendingJump(bo, ImmPtr(c->raw()), Relocation::JITCODE);
RelocStyle rs;
if (HasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ScratchRegisterScope scratch(*this);
ma_movPatchable(ImmPtr(c->raw()), scratch, Always, rs);
ma_movPatchable(ImmPtr(c->raw()), scratch, Always);
callJitNoProfiler(scratch);
}

View File

@ -115,10 +115,8 @@ class MacroAssemblerARM : public Assembler
SBit s = LeaveCC, Condition c = Always);
void ma_nop();
void ma_movPatchable(Imm32 imm, Register dest, Assembler::Condition c,
RelocStyle rs);
void ma_movPatchable(ImmPtr imm, Register dest, Assembler::Condition c,
RelocStyle rs);
void ma_movPatchable(Imm32 imm, Register dest, Assembler::Condition c);
void ma_movPatchable(ImmPtr imm, Register dest, Assembler::Condition c);
static void ma_mov_patch(Imm32 imm, Register dest, Assembler::Condition c,
RelocStyle rs, Instruction* i);
@ -519,14 +517,8 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
void branch(JitCode* c) {
BufferOffset bo = m_buffer.nextOffset();
addPendingJump(bo, ImmPtr(c->raw()), Relocation::JITCODE);
RelocStyle rs;
if (HasMOVWT())
rs = L_MOVWT;
else
rs = L_LDR;
ScratchRegisterScope scratch(asMasm());
ma_movPatchable(ImmPtr(c->raw()), scratch, Always, rs);
ma_movPatchable(ImmPtr(c->raw()), scratch, Always);
ma_bx(scratch);
}
void branch(const Register reg) {
@ -609,7 +601,7 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
CodeOffset movWithPatch(ImmWord imm, Register dest) {
CodeOffset label = CodeOffset(currentOffset());
ma_movPatchable(Imm32(imm.value), dest, Always, HasMOVWT() ? L_MOVWT : L_LDR);
ma_movPatchable(Imm32(imm.value), dest, Always);
return label;
}
CodeOffset movWithPatch(ImmPtr imm, Register dest) {

View File

@ -832,7 +832,7 @@ struct AssemblerBufferWithConstantPools : public AssemblerBuffer<SliceSize, Inst
uint8_t* inst, uint8_t* data, PoolEntry* pe = nullptr,
bool markAsBranch = false)
{
// The alloction of pool entries is not supported in a no-pool region,
// The allocation of pool entries is not supported in a no-pool region,
// check.
MOZ_ASSERT_IF(numPoolEntries, !canNotPlacePool_);