Bug 1248859 - OdinMonkey: MIPS: Implement thunkWithPatch and re/patchThunk. r=luke
authorHeiher <r@hev.cc>
Thu, 18 Feb 2016 09:37:38 +0800
changeset 284648 54c1711710b13b48ddba1cd6602de339368961c0
parent 284647 320e4b7ceee40c1e1d2a226af5c381ccde947a36
child 284649 1911cab911de222bd1705fa752c845cfe2d02738
push id30008
push usercbook@mozilla.com
push dateThu, 18 Feb 2016 11:01:39 +0000
treeherdermozilla-central@1150ac4755c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1248859
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1248859 - OdinMonkey: MIPS: Implement thunkWithPatch and re/patchThunk. r=luke --- js/src/jit/mips-shared/Architecture-mips-shared.h | 3 +++ js/src/jit/mips-shared/MacroAssembler-mips-shared.cpp | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
js/src/jit/mips-shared/Architecture-mips-shared.h
js/src/jit/mips-shared/MacroAssembler-mips-shared.cpp
--- a/js/src/jit/mips-shared/Architecture-mips-shared.h
+++ b/js/src/jit/mips-shared/Architecture-mips-shared.h
@@ -26,16 +26,19 @@
 #define USES_N64_ABI
 #else
 #error "Unsupported ABI"
 #endif
 
 namespace js {
 namespace jit {
 
+// How far forward/back can a jump go? Provide a generous buffer for thunks.
+static const uint32_t JumpImmediateRange = UINT32_MAX;
+
 class Registers
 {
   public:
     enum RegisterID {
         r0 = 0,
         r1,
         r2,
         r3,
--- a/js/src/jit/mips-shared/MacroAssembler-mips-shared.cpp
+++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared.cpp
@@ -1179,29 +1179,35 @@ MacroAssembler::patchCall(uint32_t calle
     BufferOffset li(callerOffset - Assembler::PatchWrite_NearCallSize());
     Assembler::PatchInstructionImmediate((uint8_t*)editSrc(li),
                                          PatchedImmPtr((const void*)calleeOffset));
 }
 
 CodeOffset
 MacroAssembler::thunkWithPatch()
 {
-    MOZ_CRASH("NYI");
+    addLongJump(nextOffset());
+    ma_liPatchable(ScratchRegister, ImmWord(0));
+    as_jr(ScratchRegister);
+    as_nop();
+    return CodeOffset(currentOffset());
 }
 
 void
 MacroAssembler::patchThunk(uint32_t callerOffset, uint32_t calleeOffset)
 {
-    MOZ_CRASH("NYI");
+    BufferOffset li(callerOffset - Assembler::PatchWrite_NearCallSize());
+    Assembler::PatchInstructionImmediate((uint8_t*)editSrc(li),
+                                         PatchedImmPtr((const void*)calleeOffset));
 }
 
 void
 MacroAssembler::repatchThunk(uint8_t* code, uint32_t callerOffset, uint32_t calleeOffset)
 {
-    MOZ_CRASH("NYI");
+    Assembler::PatchInstructionImmediate(code, PatchedImmPtr((const void*)calleeOffset));
 }
 
 void
 MacroAssembler::call(wasm::SymbolicAddress target)
 {
     movePtr(target, CallReg);
     call(CallReg);
 }