| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef jit_x86_SharedICHelpers_x86_inl_h |
| 8 |
#define jit_x86_SharedICHelpers_x86_inl_h |
| 9 |
|
| 10 |
#include "jit/BaselineFrame.h" |
| 11 |
#include "jit/SharedICHelpers.h" |
| 12 |
|
| 13 |
#include "jit/MacroAssembler-inl.h" |
| 14 |
|
| 15 |
namespace js { |
| 16 |
namespace jit { |
| 17 |
|
| 18 |
inline void EmitBaselineTailCallVM(TrampolinePtr target, MacroAssembler& masm, |
| 19 |
uint32_t argSize) { |
| 20 |
#ifdef DEBUG |
| 21 |
// We assume during this that R0 and R1 have been pushed. |
| 22 |
// Store frame size without VMFunction arguments for debug assertions. |
| 23 |
masm.movl(FramePointer, eax); |
| 24 |
masm.subl(StackPointer, eax); |
| 25 |
masm.subl(Imm32(argSize), eax); |
| 26 |
Address frameSizeAddr(FramePointer, |
| 27 |
BaselineFrame::reverseOffsetOfDebugFrameSize()); |
| 28 |
masm.store32(eax, frameSizeAddr); |
| 29 |
#endif |
| 30 |
|
| 31 |
// Push frame descriptor and perform the tail call. |
| 32 |
masm.pushFrameDescriptor(FrameType::BaselineJS); |
| 33 |
masm.push(ICTailCallReg); |
| 34 |
masm.jump(target); |
| 35 |
} |
| 36 |
|
| 37 |
inline void EmitBaselineCallVM(TrampolinePtr target, MacroAssembler& masm) { |
| 38 |
masm.pushFrameDescriptor(FrameType::BaselineStub); |
| 39 |
masm.call(target); |
| 40 |
} |
| 41 |
|
| 42 |
inline void EmitBaselineEnterStubFrame(MacroAssembler& masm, Register scratch) { |
| 43 |
#ifdef DEBUG |
| 44 |
// Compute frame size. Because the return address is still on the stack, |
| 45 |
// this is: |
| 46 |
// |
| 47 |
// FramePointer |
| 48 |
// - StackPointer |
| 49 |
// - sizeof(return address) |
| 50 |
|
| 51 |
masm.movl(FramePointer, scratch); |
| 52 |
masm.subl(StackPointer, scratch); |
| 53 |
masm.subl(Imm32(sizeof(void*)), scratch); // Return address. |
| 54 |
|
| 55 |
Address frameSizeAddr(FramePointer, |
| 56 |
BaselineFrame::reverseOffsetOfDebugFrameSize()); |
| 57 |
masm.store32(scratch, frameSizeAddr); |
| 58 |
#endif |
| 59 |
|
| 60 |
// Push the return address that's currently on top of the stack. |
| 61 |
masm.Push(Operand(StackPointer, 0)); |
| 62 |
|
| 63 |
// Replace the original return address with the frame descriptor. |
| 64 |
masm.storePtr(ImmWord(MakeFrameDescriptor(FrameType::BaselineJS)), |
| 65 |
Address(StackPointer, sizeof(uintptr_t))); |
| 66 |
|
| 67 |
// Save old frame pointer, stack pointer and stub reg. |
| 68 |
masm.Push(FramePointer); |
| 69 |
masm.mov(StackPointer, FramePointer); |
| 70 |
|
| 71 |
masm.Push(ICStubReg); |
| 72 |
} |
| 73 |
|
| 74 |
} // namespace jit |
| 75 |
} // namespace js |
| 76 |
|
| 77 |
#endif /* jit_x86_SharedICHelpers_x86_inl_h */ |