From b4f0be5e9537c6c202443b34f7bb3b99cb08be0f Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Tue, 12 May 2020 12:40:09 +0800 Subject: Bug 1271968 - IonMonkey: MIPS: Refactor PatchWrite_NearCall. Tag: #1542 --- js/src/jit/mips32/Assembler-mips32.cpp | 33 --------------------------------- js/src/jit/mips32/Assembler-mips32.h | 9 +++------ 2 files changed, 3 insertions(+), 39 deletions(-) (limited to 'js/src/jit/mips32') diff --git a/js/src/jit/mips32/Assembler-mips32.cpp b/js/src/jit/mips32/Assembler-mips32.cpp index 89c7a8c44..f1fb71609 100644 --- a/js/src/jit/mips32/Assembler-mips32.cpp +++ b/js/src/jit/mips32/Assembler-mips32.cpp @@ -296,31 +296,6 @@ Assembler::Bind(uint8_t* rawCode, CodeOffset* label, const void* address) } } -uint32_t -Assembler::PatchWrite_NearCallSize() -{ - return 4 * sizeof(uint32_t); -} - -void -Assembler::PatchWrite_NearCall(CodeLocationLabel start, CodeLocationLabel toCall) -{ - Instruction* inst = (Instruction*) start.raw(); - uint8_t* dest = toCall.raw(); - - // Overwrite whatever instruction used to be here with a call. - // Always use long jump for two reasons: - // - Jump has to be the same size because of PatchWrite_NearCallSize. - // - Return address has to be at the end of replaced block. - // Short jump wouldn't be more efficient. - Assembler::WriteLuiOriInstructions(inst, &inst[1], ScratchRegister, (uint32_t)dest); - inst[2] = InstReg(op_special, ScratchRegister, zero, ra, ff_jalr); - inst[3] = InstNOP(); - - // Ensure everyone sees the code that was just written into memory. - AutoFlushICache::flush(uintptr_t(inst), PatchWrite_NearCallSize()); -} - uint32_t Assembler::ExtractLuiOriValue(Instruction* inst0, Instruction* inst1) { @@ -334,14 +309,6 @@ Assembler::ExtractLuiOriValue(Instruction* inst0, Instruction* inst1) return value; } -void -Assembler::WriteLuiOriInstructions(Instruction* inst0, Instruction* inst1, - Register reg, uint32_t value) -{ - *inst0 = InstImm(op_lui, zero, reg, Imm16::Upper(Imm32(value))); - *inst1 = InstImm(op_ori, reg, reg, Imm16::Lower(Imm32(value))); -} - void Assembler::PatchDataWithValueCheck(CodeLocationLabel label, ImmPtr newValue, ImmPtr expectedValue) diff --git a/js/src/jit/mips32/Assembler-mips32.h b/js/src/jit/mips32/Assembler-mips32.h index 2bfb61e8e..6988d23a5 100644 --- a/js/src/jit/mips32/Assembler-mips32.h +++ b/js/src/jit/mips32/Assembler-mips32.h @@ -149,13 +149,10 @@ class Assembler : public AssemblerMIPSShared static void TraceJumpRelocations(JSTracer* trc, JitCode* code, CompactBufferReader& reader); static void TraceDataRelocations(JSTracer* trc, JitCode* code, CompactBufferReader& reader); - static uint32_t PatchWrite_NearCallSize(); - + static uint32_t InstructionImmediateSize() { + return 2 * sizeof(uint32_t); + } static uint32_t ExtractLuiOriValue(Instruction* inst0, Instruction* inst1); - static void WriteLuiOriInstructions(Instruction* inst, Instruction* inst1, - Register reg, uint32_t value); - - static void PatchWrite_NearCall(CodeLocationLabel start, CodeLocationLabel toCall); static void PatchDataWithValueCheck(CodeLocationLabel label, ImmPtr newValue, ImmPtr expectedValue); static void PatchDataWithValueCheck(CodeLocationLabel label, PatchedImmPtr newValue, -- cgit v1.2.3