Debian Codegraph @

js/src/jit/arm/SharedICHelpers-arm.h

raw
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_h
8 #define jit_arm_SharedICHelpers_arm_h
9
10 #include "jit/BaselineIC.h"
11 #include "jit/JitFrames.h"
12 #include "jit/MacroAssembler.h"
13 #include "jit/SharedICRegisters.h"
14
15 namespace js {
16 namespace jit {
17
18 // Distance from sp to the top Value inside an IC stub (no return address on the
19 // stack on ARM).
20 static const size_t ICStackValueOffset = 0;
21
22 inline void EmitRestoreTailCallReg(MacroAssembler& masm) {
23 // No-op on ARM because link register is always holding the return address.
24 }
25
26 inline void EmitRepushTailCallReg(MacroAssembler& masm) {
27 // No-op on ARM because link register is always holding the return address.
28 }
29
30 inline void EmitCallIC(MacroAssembler& masm, CodeOffset* callOffset) {
31 // The stub pointer must already be in ICStubReg.
32 // Load stubcode pointer from the ICStub.
33 // R2 won't be active when we call ICs, so we can use r0.
34 static_assert(R2 == ValueOperand(r1, r0));
35 masm.loadPtr(Address(ICStubReg, ICStub::offsetOfStubCode()), r0);
36
37 // Call the stubcode via a direct branch-and-link.
38 masm.ma_blx(r0);
39 *callOffset = CodeOffset(masm.currentOffset());
40 }
41
42 inline void EmitReturnFromIC(MacroAssembler& masm) { masm.ma_mov(lr, pc); }
43
44 inline void EmitBaselineLeaveStubFrame(MacroAssembler& masm) {
45 Address stubAddr(FramePointer, BaselineStubFrameLayout::ICStubOffsetFromFP);
46 masm.loadPtr(stubAddr, ICStubReg);
47
48 masm.mov(FramePointer, StackPointer);
49 masm.Pop(FramePointer);
50
51 // Load the return address.
52 masm.Pop(ICTailCallReg);
53
54 // Discard the frame descriptor.
55 ScratchRegisterScope scratch(masm);
56 masm.Pop(scratch);
57 }
58
59 template <typename AddrType>
60 inline void EmitPreBarrier(MacroAssembler& masm, const AddrType& addr,
61 MIRType type) {
62 // On ARM, lr is clobbered by guardedCallPreBarrier. Save it first.
63 masm.push(lr);
64 masm.guardedCallPreBarrier(addr, type);
65 masm.pop(lr);
66 }
67
68 inline void EmitStubGuardFailure(MacroAssembler& masm) {
69 // Load next stub into ICStubReg.
70 masm.loadPtr(Address(ICStubReg, ICCacheIRStub::offsetOfNext()), ICStubReg);
71
72 // Return address is already loaded, just jump to the next stubcode.
73 static_assert(ICTailCallReg == lr);
74 masm.jump(Address(ICStubReg, ICStub::offsetOfStubCode()));
75 }
76
77 } // namespace jit
78 } // namespace js
79
80 #endif /* jit_arm_SharedICHelpers_arm_h */