Bug 1271968 - IonMonkey: MIPS: Refactor addMixedJump.

Tag: #1542
This commit is contained in:
Jiaxun Yang 2020-05-12 12:40:10 +08:00 committed by Roy Tam
commit ce88df74e8
5 changed files with 17 additions and 17 deletions

View file

@ -104,7 +104,7 @@ AssemblerMIPSShared::asmMergeWith(const AssemblerMIPSShared& other)
for (size_t i = 0; i < other.numMixedJumps(); i++) {
const MixedJumpPatch& mjp = other.mixedJumps_[i];
addMixedJump(BufferOffset(size() + mjp.src.getOffset()),
ImmPtr(size() + mjp.target), mjp.kind);
size() + mjp.target, mjp.kind);
}
return m_buffer.appendBuffer(other.m_buffer);
}
@ -1608,7 +1608,7 @@ AssemblerMIPSShared::bind(InstImm* inst, uintptr_t branch, uintptr_t target)
// Generate the patchable mixed jump for call.
if (inst->extractOpcode() == ((uint32_t)op_jal >> OpcodeShift)) {
addMixedJump(BufferOffset(branch), ImmPtr((void*)target));
addMixedJump(BufferOffset(branch), target);
return;
}
@ -1631,7 +1631,7 @@ AssemblerMIPSShared::bind(InstImm* inst, uintptr_t branch, uintptr_t target)
if (inst[0].encode() != inst_beq.encode())
kind = MixedJumpPatch::CONDITIONAL;
addMixedJump(BufferOffset(branch), ImmPtr((const void*)target), kind);
addMixedJump(BufferOffset(branch), target, kind);
}
void
@ -1650,7 +1650,7 @@ AssemblerMIPSShared::bind(RepatchLabel* label)
// If second instruction is lui, then this is a loop backedge.
if (inst[0].extractOpcode() == (uint32_t(op_j) >> OpcodeShift)) {
// For unconditional mixed branches generated by jumpWithPatch
addMixedJump(b, ImmPtr((void*)dest.getOffset()), MixedJumpPatch::PATCHABLE);
addMixedJump(b, dest.getOffset(), MixedJumpPatch::PATCHABLE);
} else if (inst[1].extractOpcode() == (uint32_t(op_lui) >> OpcodeShift) ||
BOffImm16::IsInRange(offset))
{
@ -1668,7 +1668,7 @@ AssemblerMIPSShared::bind(RepatchLabel* label)
// We need to add it to mixed jumps array here.
// See MacroAssemblerMIPS::branchWithCode().
MOZ_ASSERT(inst[1].encode() == NopInst);
addMixedJump(b, ImmPtr((void*)dest.getOffset()), MixedJumpPatch::PATCHABLE);
addMixedJump(b, dest.getOffset(), MixedJumpPatch::PATCHABLE);
inst[0] = InstJump(op_j, JOffImm26(0)).encode();
} else {
// Handle open mixed conditional jumps created by
@ -1680,7 +1680,7 @@ AssemblerMIPSShared::bind(RepatchLabel* label)
MOZ_ASSERT(inst[1].encode() == NopInst);
MOZ_ASSERT(inst[2].encode() == NopInst);
MOZ_ASSERT(inst[3].encode() == NopInst);
addMixedJump(b, ImmPtr((void*)dest.getOffset()), MixedJumpPatch::PATCHABLE);
addMixedJump(b, dest.getOffset(), MixedJumpPatch::PATCHABLE);
inst[2] = InstJump(op_j, JOffImm26(0)).encode();
}
}
@ -1840,7 +1840,7 @@ AssemblerMIPSShared::PatchMixedJumps(uint8_t* buffer)
MixedJumpPatch& mjp = mixedJump(i);
uint8_t* src = buffer + mjp.src.getOffset();
uint8_t* mid = nullptr;
uint8_t* target = buffer + uintptr_t(mjp.target);
uint8_t* target = buffer + mjp.target;
InstImm* b = (InstImm*)src;
if (mjp.mid.assigned()) {

View file

@ -842,10 +842,10 @@ class AssemblerMIPSShared : public AssemblerShared
BufferOffset src;
BufferOffset mid;
void* target;
uintptr_t target;
Kind kind;
MixedJumpPatch(BufferOffset src, void* target, Kind kind)
MixedJumpPatch(BufferOffset src, uintptr_t target, Kind kind)
: src(src),
mid(BufferOffset()),
target(target),
@ -1256,10 +1256,10 @@ class AssemblerMIPSShared : public AssemblerShared
writeRelocation(src);
}
void addMixedJump(BufferOffset src, ImmPtr target,
void addMixedJump(BufferOffset src, uintptr_t target,
MixedJumpPatch::Kind kind = MixedJumpPatch::NONE)
{
enoughMemory_ &= mixedJumps_.append(MixedJumpPatch(src, target.value, kind));
enoughMemory_ &= mixedJumps_.append(MixedJumpPatch(src, target, kind));
}
virtual void GenerateMixedJumps() = 0;

View file

@ -665,14 +665,14 @@ MacroAssemblerMIPSShared::branchWithCode(InstImm code, Label* label, JumpKind ju
InstImm inst_beq = InstImm(op_beq, zero, zero, BOffImm16(0));
if (code.encode() == inst_beq.encode()) {
// Handle mixed jump
addMixedJump(nextOffset(), ImmPtr((void*)label->offset()));
addMixedJump(nextOffset(), label->offset());
as_j(JOffImm26(0));
as_nop();
return;
}
// Handle long conditional branch
addMixedJump(nextOffset(), ImmPtr((void*)label->offset()), MixedJumpPatch::CONDITIONAL);
addMixedJump(nextOffset(), label->offset(), MixedJumpPatch::CONDITIONAL);
writeInst(code.encode());
as_nop();
return;
@ -785,7 +785,7 @@ MacroAssemblerMIPSShared::ma_jal(Label* label)
{
if (label->bound()) {
// Generate the mixed jump.
addMixedJump(nextOffset(), ImmPtr((void*)label->offset()));
addMixedJump(nextOffset(), label->offset());
as_jal(JOffImm26(0));
as_nop();
return;
@ -1041,7 +1041,7 @@ MacroAssemblerMIPSShared::GenerateMixedJumps()
// Generate all mixed jumps.
for (size_t i = 0; i < numMixedJumps(); i++) {
MixedJumpPatch& mjp = mixedJump(i);
if (MixedJumpPatch::NONE == mjp.kind && uintptr_t(mjp.target) <= size())
if (MixedJumpPatch::NONE == mjp.kind && mjp.target <= size())
continue;
BufferOffset bo = m_buffer.nextOffset();
if (MixedJumpPatch::CONDITIONAL & mjp.kind) {

View file

@ -1498,7 +1498,7 @@ MacroAssemblerMIPSCompat::jumpWithPatch(RepatchLabel* label, Label* documentatio
BufferOffset bo = nextOffset();
label->use(bo.getOffset());
if (label->bound())
addMixedJump(bo, ImmPtr((void*)label->offset()), MixedJumpPatch::PATCHABLE);
addMixedJump(bo, label->offset(), MixedJumpPatch::PATCHABLE);
as_j(JOffImm26(0));
as_nop();
return CodeOffsetJump(bo.getOffset());

View file

@ -1738,7 +1738,7 @@ MacroAssemblerMIPS64Compat::jumpWithPatch(RepatchLabel* label, Label* documentat
BufferOffset bo = nextOffset();
label->use(bo.getOffset());
if (label->bound())
addMixedJump(bo, ImmPtr((void*)label->offset()), MixedJumpPatch::PATCHABLE);
addMixedJump(bo, label->offset(), MixedJumpPatch::PATCHABLE);
as_j(JOffImm26(0));
as_nop();
return CodeOffsetJump(bo.getOffset());