Debian Codegraph @

js/src/jit/x64/SharedICHelpers-x64-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_x64_SharedICHelpers_x64_inl_h
8 #define jit_x64_SharedICHelpers_x64_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 ScratchRegisterScope scratch(masm);
22
23 // We can assume during this that R0 and R1 have been pushed.
24 // Store frame size without VMFunction arguments for debug assertions.
25 masm.movq(FramePointer, scratch);
26 masm.subq(StackPointer, scratch);
27 masm.subq(Imm32(argSize), scratch);
28 Address frameSizeAddr(FramePointer,
29 BaselineFrame::reverseOffsetOfDebugFrameSize());
30 masm.store32(scratch, frameSizeAddr);
31 #endif
32
33 // Push frame descriptor and perform the tail call.
34 masm.pushFrameDescriptor(FrameType::BaselineJS);
35 masm.push(ICTailCallReg);
36 masm.jump(target);
37 }
38
39 inline void EmitBaselineCallVM(TrampolinePtr target, MacroAssembler& masm) {
40 masm.pushFrameDescriptor(FrameType::BaselineStub);
41 masm.call(target);
42 }
43
44 inline void EmitBaselineEnterStubFrame(MacroAssembler& masm, Register) {
45 #ifdef DEBUG
46 // Compute frame size. Because the return address is still on the stack,
47 // this is:
48 //
49 // FramePointer
50 // - StackPointer
51 // - sizeof(return address)
52
53 ScratchRegisterScope scratch(masm);
54 masm.movq(FramePointer, scratch);
55 masm.subq(StackPointer, scratch);
56 masm.subq(Imm32(sizeof(void*)), scratch); // Return address.
57
58 Address frameSizeAddr(FramePointer,
59 BaselineFrame::reverseOffsetOfDebugFrameSize());
60 masm.store32(scratch, frameSizeAddr);
61 #endif
62
63 // Push the return address that's currently on top of the stack.
64 masm.Push(Operand(StackPointer, 0));
65
66 // Replace the original return address with the frame descriptor.
67 masm.storePtr(ImmWord(MakeFrameDescriptor(FrameType::BaselineJS)),
68 Address(StackPointer, sizeof(uintptr_t)));
69
70 // Save old frame pointer, stack pointer and stub reg.
71 masm.Push(FramePointer);
72 masm.mov(StackPointer, FramePointer);
73
74 masm.Push(ICStubReg);
75 }
76
77 } // namespace jit
78 } // namespace js
79
80 #endif /* jit_x64_SharedICHelpers_x64_inl_h */