Bug 1169214: IonMonkey - Part 3: Add the x64 shared stub helpers, r=jandem
authorHannes Verschore <hv1989@gmail.com>
Fri, 21 Aug 2015 07:56:44 +0200
changeset 258813 590916330ceea9bcc144f80450814efeb7628486
parent 258812 39305ec41209417c931ae15af6086d50acda7c7e
child 258814 eaa9d14c60afa665387eaf33c2df44ebe23da996
push id29263
push userryanvm@gmail.com
push dateSun, 23 Aug 2015 21:18:49 +0000
treeherdermozilla-central@4ccdd06e51d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1169214
milestone43.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 1169214: IonMonkey - Part 3: Add the x64 shared stub helpers, r=jandem
js/src/jit/x64/SharedICHelpers-x64.h
--- a/js/src/jit/x64/SharedICHelpers-x64.h
+++ b/js/src/jit/x64/SharedICHelpers-x64.h
@@ -87,17 +87,25 @@ EmitBaselineTailCallVM(JitCode* target, 
     masm.push(ScratchReg);
     masm.push(ICTailCallReg);
     masm.jmp(target);
 }
 
 inline void
 EmitIonTailCallVM(JitCode* target, MacroAssembler& masm, uint32_t stackSize)
 {
-    MOZ_CRASH("Not implemented yet.");
+    masm.movq(Operand(esp, stackSize), ScratchReg);
+    masm.shrq(Imm32(FRAMESIZE_SHIFT), ScratchReg);
+    masm.addq(Imm32(stackSize + JitStubFrameLayout::Size() - sizeof(intptr_t)), ScratchReg);
+
+    // Push frame descriptor and perform the tail call.
+    masm.makeFrameDescriptor(ScratchReg, JitFrame_IonJS);
+    masm.push(ScratchReg);
+    masm.push(ICTailCallReg);
+    masm.jmp(target);
 }
 
 inline void
 EmitBaselineCreateStubFrameDescriptor(MacroAssembler& masm, Register reg)
 {
     // Compute stub frame size. We have to add two pointers: the stub reg and previous
     // frame pointer pushed by EmitEnterStubFrame.
     masm.movq(BaselineFrameReg, reg);
@@ -113,17 +121,26 @@ EmitBaselineCallVM(JitCode* target, Macr
     EmitBaselineCreateStubFrameDescriptor(masm, ScratchReg);
     masm.push(ScratchReg);
     masm.call(target);
 }
 
 inline void
 EmitIonCallVM(JitCode* target, size_t stackSlots, MacroAssembler& masm)
 {
-    MOZ_CRASH("Not implemented yet.");
+    uint32_t descriptor = MakeFrameDescriptor(masm.framePushed(), JitFrame_IonStub);
+    masm.Push(Imm32(descriptor));
+    masm.call(target);
+
+    // Remove rest of the frame left on the stack. We remove the return address
+    // which is implicitly poped when returning.
+    size_t framePop = sizeof(ExitFrameLayout) - sizeof(void*);
+
+    // Pop arguments from framePushed.
+    masm.implicitPop(stackSlots * sizeof(void*) + framePop);
 }
 
 // Size of vales pushed by EmitEnterStubFrame.
 static const uint32_t STUB_FRAME_SIZE = 4 * sizeof(void*);
 static const uint32_t STUB_FRAME_SAVED_STUB_OFFSET = sizeof(void*);
 
 inline void
 EmitBaselineEnterStubFrame(MacroAssembler& masm, Register)
@@ -147,19 +164,21 @@ EmitBaselineEnterStubFrame(MacroAssemble
 
     // Save old frame pointer, stack pointer and stub reg.
     masm.push(ICStubReg);
     masm.push(BaselineFrameReg);
     masm.mov(BaselineStackReg, BaselineFrameReg);
 }
 
 inline void
-EmitIonEnterStubFrame(MacroAssembler& masm, Register scratch)
+EmitIonEnterStubFrame(MacroAssembler& masm, Register)
 {
-    MOZ_CRASH("Not implemented yet.");
+    masm.pop(ICTailCallReg);
+    masm.push(ICTailCallReg);
+    masm.push(ICStubReg);
 }
 
 inline void
 EmitBaselineLeaveStubFrame(MacroAssembler& masm, bool calledIntoIon = false)
 {
     // Ion frames do not save and restore the frame pointer. If we called
     // into Ion, we have to restore the stack pointer from the frame descriptor.
     // If we performed a VM call, the descriptor has been popped already so
@@ -181,17 +200,18 @@ EmitBaselineLeaveStubFrame(MacroAssemble
     // Overwrite frame descriptor with return address, so that the stack matches
     // the state before entering the stub frame.
     masm.storePtr(ICTailCallReg, Address(BaselineStackReg, 0));
 }
 
 inline void
 EmitIonLeaveStubFrame(MacroAssembler& masm)
 {
-    MOZ_CRASH("Not implemented yet.");
+    masm.pop(ICStubReg);
+    masm.pop(ICTailCallReg);
 }
 
 inline void
 EmitStowICValues(MacroAssembler& masm, int values)
 {
     MOZ_ASSERT(values >= 0 && values <= 2);
     switch(values) {
       case 1: