Debian Codegraph @

js/src/jit/arm64/SharedICHelpers-arm64-inl.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_arm64_SharedICHelpers_arm64_inl_h
8 #define jit_arm64_SharedICHelpers_arm64_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 that R0 has been pushed, and R2 is unused.
22 static_assert(R2 == ValueOperand(r0));
23
24 // Store frame size without VMFunction arguments for debug assertions.
25 masm.Sub(x0, FramePointer64, masm.GetStackPointer64());
26 masm.Sub(w0, w0, Operand(argSize));
27 Address frameSizeAddr(FramePointer,
28 BaselineFrame::reverseOffsetOfDebugFrameSize());
29 masm.store32(w0.asUnsized(), frameSizeAddr);
30 #endif
31
32 // Push frame descriptor (minus the return address) and perform the tail call.
33 static_assert(ICTailCallReg == lr);
34 masm.pushFrameDescriptor(FrameType::BaselineJS);
35
36 // The return address will be pushed by the VM wrapper, for compatibility
37 // with direct calls. Refer to the top of generateVMWrapper().
38 // ICTailCallReg (lr) already contains the return address (as we keep
39 // it there through the stub calls).
40
41 masm.jump(target);
42 }
43
44 inline void EmitBaselineCallVM(TrampolinePtr target, MacroAssembler& masm) {
45 masm.pushFrameDescriptor(FrameType::BaselineStub);
46 masm.call(target);
47 }
48
49 inline void EmitBaselineEnterStubFrame(MacroAssembler& masm, Register scratch) {
50 MOZ_ASSERT(scratch != ICTailCallReg);
51
52 #ifdef DEBUG
53 // Compute frame size.
54 masm.Sub(ARMRegister(scratch, 64), FramePointer64, masm.GetStackPointer64());
55
56 Address frameSizeAddr(FramePointer,
57 BaselineFrame::reverseOffsetOfDebugFrameSize());
58 masm.store32(scratch, frameSizeAddr);
59 #endif
60
61 // Push frame descriptor and return address.
62 // Save old frame pointer, stack pointer, and stub reg.
63 masm.PushFrameDescriptor(FrameType::BaselineJS);
64 masm.Push(ICTailCallReg);
65 masm.Push(FramePointer);
66
67 // Update the frame register.
68 masm.Mov(FramePointer64, masm.GetStackPointer64());
69
70 masm.Push(ICStubReg);
71
72 // Stack should remain 16-byte aligned.
73 masm.checkStackAlignment();
74 }
75
76 } // namespace jit
77 } // namespace js
78
79 #endif // jit_arm64_SharedICHelpers_arm64_inl_h