| 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_arm_SharedICHelpers_arm_inl_h |
| 8 |
#define jit_arm_SharedICHelpers_arm_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, and that R2 is |
| 22 |
// unused. |
| 23 |
static_assert(R2 == ValueOperand(r1, r0)); |
| 24 |
|
| 25 |
// Store frame size without VMFunction arguments for debug assertions. |
| 26 |
masm.movePtr(FramePointer, r0); |
| 27 |
masm.ma_sub(StackPointer, r0); |
| 28 |
masm.sub32(Imm32(argSize), r0); |
| 29 |
Address frameSizeAddr(FramePointer, |
| 30 |
BaselineFrame::reverseOffsetOfDebugFrameSize()); |
| 31 |
masm.store32(r0, frameSizeAddr); |
| 32 |
#endif |
| 33 |
|
| 34 |
// Push frame descriptor and perform the tail call. |
| 35 |
masm.pushFrameDescriptor(FrameType::BaselineJS); |
| 36 |
|
| 37 |
static_assert(ICTailCallReg == lr); |
| 38 |
// The return address will be pushed by the VM wrapper, for compatibility |
| 39 |
// with direct calls. Refer to the top of generateVMWrapper(). |
| 40 |
// ICTailCallReg (lr) already contains the return address (as we keep |
| 41 |
// it there through the stub calls). |
| 42 |
|
| 43 |
masm.jump(target); |
| 44 |
} |
| 45 |
|
| 46 |
inline void EmitBaselineCallVM(TrampolinePtr target, MacroAssembler& masm) { |
| 47 |
masm.pushFrameDescriptor(FrameType::BaselineStub); |
| 48 |
masm.call(target); |
| 49 |
} |
| 50 |
|
| 51 |
inline void EmitBaselineEnterStubFrame(MacroAssembler& masm, Register scratch) { |
| 52 |
MOZ_ASSERT(scratch != ICTailCallReg); |
| 53 |
|
| 54 |
#ifdef DEBUG |
| 55 |
// Compute frame size. |
| 56 |
masm.mov(FramePointer, scratch); |
| 57 |
masm.ma_sub(StackPointer, scratch); |
| 58 |
|
| 59 |
Address frameSizeAddr(FramePointer, |
| 60 |
BaselineFrame::reverseOffsetOfDebugFrameSize()); |
| 61 |
masm.store32(scratch, frameSizeAddr); |
| 62 |
#endif |
| 63 |
|
| 64 |
// Push frame descriptor and return address. |
| 65 |
masm.PushFrameDescriptor(FrameType::BaselineJS); |
| 66 |
masm.Push(ICTailCallReg); |
| 67 |
|
| 68 |
// Save old frame pointer, stack pointer and stub reg. |
| 69 |
masm.Push(FramePointer); |
| 70 |
masm.mov(StackPointer, FramePointer); |
| 71 |
|
| 72 |
masm.Push(ICStubReg); |
| 73 |
|
| 74 |
// We pushed 4 words, so the stack is still aligned to 8 bytes. |
| 75 |
masm.checkStackAlignment(); |
| 76 |
} |
| 77 |
|
| 78 |
} // namespace jit |
| 79 |
} // namespace js |
| 80 |
|
| 81 |
#endif /* jit_arm_SharedICHelpers_arm_inl_h */ |