diff options
author | Jiaxun Yang <jiaxun.yang@flygoat.com> | 2020-05-12 12:40:09 +0800 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-05-20 14:01:38 +0000 |
commit | b4f0be5e9537c6c202443b34f7bb3b99cb08be0f (patch) | |
tree | fdb3814586b392b26494cf309d75f093674e33c5 /js/src/jit/mips-shared | |
parent | ac62e4cfdd03369d60e22f78b38b81f5f8daa5bd (diff) | |
download | UXP-b4f0be5e9537c6c202443b34f7bb3b99cb08be0f.tar UXP-b4f0be5e9537c6c202443b34f7bb3b99cb08be0f.tar.gz UXP-b4f0be5e9537c6c202443b34f7bb3b99cb08be0f.tar.lz UXP-b4f0be5e9537c6c202443b34f7bb3b99cb08be0f.tar.xz UXP-b4f0be5e9537c6c202443b34f7bb3b99cb08be0f.zip |
Bug 1271968 - IonMonkey: MIPS: Refactor PatchWrite_NearCall.
Tag: #1542
Diffstat (limited to 'js/src/jit/mips-shared')
-rw-r--r-- | js/src/jit/mips-shared/Assembler-mips-shared.cpp | 26 | ||||
-rw-r--r-- | js/src/jit/mips-shared/Assembler-mips-shared.h | 2 |
2 files changed, 25 insertions, 3 deletions
diff --git a/js/src/jit/mips-shared/Assembler-mips-shared.cpp b/js/src/jit/mips-shared/Assembler-mips-shared.cpp index 7b8ead20a..e78d33549 100644 --- a/js/src/jit/mips-shared/Assembler-mips-shared.cpp +++ b/js/src/jit/mips-shared/Assembler-mips-shared.cpp @@ -1748,6 +1748,25 @@ AssemblerMIPSShared::PatchWrite_Imm32(CodeLocationLabel label, Imm32 imm) *(raw - 1) = imm.value; } +uint32_t +AssemblerMIPSShared::PatchWrite_NearCallSize() +{ + return 2 * sizeof(uint32_t); +} + +void +AssemblerMIPSShared::PatchWrite_NearCall(CodeLocationLabel start, CodeLocationLabel toCall) +{ + Instruction* inst = (Instruction*) start.raw(); + + // Overwrite whatever instruction used to be here with a call. + inst[0] = InstJump(op_jal, JOffImm26(uintptr_t(toCall.raw()))); + inst[1] = InstNOP(); + + // Ensure everyone sees the code that was just written into memory. + AutoFlushICache::flush(uintptr_t(inst), PatchWrite_NearCallSize()); +} + uint8_t* AssemblerMIPSShared::NextInstruction(uint8_t* inst_, uint32_t* count) { @@ -1789,8 +1808,8 @@ AssemblerMIPSShared::PatchMixedJump(uint8_t* src, uint8_t* mid, uint8_t* target) offset = intptr_t(mid); if (insn->extractOpcode() != ((uint32_t)op_lui >> OpcodeShift)) { o = 1 * sizeof(uint32_t); - Assembler::PatchInstructionImmediate(mid + Assembler::PatchWrite_NearCallSize(), - PatchedImmPtr(&b[2])); + Assembler::PatchInstructionImmediate(mid + Assembler::InstructionImmediateSize() + + 2 * sizeof(uint32_t), PatchedImmPtr(&b[2])); } Assembler::PatchInstructionImmediate(mid + o, PatchedImmPtr(target)); } else { @@ -1823,7 +1842,8 @@ AssemblerMIPSShared::PatchMixedJumps(uint8_t* buffer) mid = buffer + mjp.mid.getOffset(); if (MixedJumpPatch::CONDITIONAL & mjp.kind) { InstImm* bc = (InstImm*)(buffer + mjp.mid.getOffset()); - bc[0] = invertBranch(b[0], BOffImm16(Assembler::PatchWrite_NearCallSize())); + BOffImm16 offset(Assembler::InstructionImmediateSize() + 2 * sizeof(uint32_t)); + bc[0] = invertBranch(b[0], offset); } } diff --git a/js/src/jit/mips-shared/Assembler-mips-shared.h b/js/src/jit/mips-shared/Assembler-mips-shared.h index 52e9051bb..3c01350e6 100644 --- a/js/src/jit/mips-shared/Assembler-mips-shared.h +++ b/js/src/jit/mips-shared/Assembler-mips-shared.h @@ -1282,8 +1282,10 @@ class AssemblerMIPSShared : public AssemblerShared } static uint32_t NopSize() { return 4; } + static uint32_t PatchWrite_NearCallSize(); static void PatchWrite_Imm32(CodeLocationLabel label, Imm32 imm); + static void PatchWrite_NearCall(CodeLocationLabel start, CodeLocationLabel toCall); static uint32_t AlignDoubleArg(uint32_t offset) { return (offset + 1U) &~ 1U; |