v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
frame-constants-x64.h
Go to the documentation of this file.
1// Copyright 2012 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_EXECUTION_X64_FRAME_CONSTANTS_X64_H_
6#define V8_EXECUTION_X64_FRAME_CONSTANTS_X64_H_
7
8#include "src/base/bits.h"
9#include "src/base/macros.h"
12
13namespace v8 {
14namespace internal {
15
17 public:
18 // The layout of an EntryFrame is as follows:
19 //
20 // BOTTOM OF THE STACK HIGHEST ADDRESS
21 // slot Entry frame
22 // +---------------------+-----------------------
23 // -1 | return address |
24 // |- - - - - - - - - - -|
25 // 0 | saved fp | <-- frame ptr
26 // |- - - - - - - - - - -|
27 // 1 | stack frame marker |
28 // | (ENTRY) |
29 // |- - - - - - - - - - -|
30 // 2 | context |
31 // |- - - - - - - - - - -|
32 // 3 | callee-saved regs * |
33 // ... | ... |
34 // |- - - - - - - - - - -|
35 // 3 | C entry FP |
36 // |- - - - - - - - - - -|
37 // 5 | fast api call fp |
38 // |- - - - - - - - - - -|
39 // 6 | fast api call pc |
40 // |- - - - - - - - - - -|
41 // 6 | outermost marker | <-- stack ptr
42 // -----+---------------------+-----------------------
43 // TOP OF THE STACK LOWEST ADDRESS
44 // * On Windows the callee-saved registers are (in push order):
45 // r12, r13, r14, r15, rdi, rsi, rbx, xmm6, xmm7, xmm8, xmm9, xmm10, xmm11,
46 // xmm12, xmm13, xmm14, xmm15
47 // xmm register pushes take 16 bytes on the stack.
48 // On other OS, the callee-saved registers are (in push order):
49 // r12, r13, r14, r15, rbx
50
51 static constexpr int kXMMRegisterSize = 16;
52#ifdef V8_TARGET_OS_WIN
53 static constexpr int kCalleeSaveXMMRegisters = 10;
54 static constexpr int kXMMRegistersBlockSize =
55 kXMMRegisterSize * kCalleeSaveXMMRegisters;
56
57 // This is the offset to where JSEntry pushes the current value of
58 // Isolate::c_entry_fp onto the stack.
59 // On x64, there are 7 pushq() and 3 Push() calls between setting up rbp and
60 // pushing the c_entry_fp, plus we manually allocate kXMMRegistersBlockSize
61 // bytes on the stack.
62 static constexpr int kNextExitFrameFPOffset = -3 * kSystemPointerSize +
64 kXMMRegistersBlockSize;
65
66 // Stack offsets for arguments passed to JSEntry.
67 static constexpr int kArgcOffset = 6 * kSystemPointerSize;
68 static constexpr int kArgvOffset = 7 * kSystemPointerSize;
69#else
70 // This is the offset to where JSEntry pushes the current value of
71 // Isolate::c_entry_fp onto the stack.
72 // On x64, there are 5 pushq() and 3 Push() calls between setting up rbp and
73 // pushing the c_entry_fp.
74 static constexpr int kNextExitFrameFPOffset =
76#endif
77 // This are the offsets to where JSEntry pushes the current values of
78 // IsolateData::fast_c_call_caller_fp and IsolateData::fast_c_call_caller_pc.
79 static constexpr int kNextFastCallFrameFPOffset =
81 static constexpr int kNextFastCallFramePCOffset =
83};
84
86 public:
87 // Number of gp parameters, without the instance.
88 static constexpr int kNumberOfSavedGpParamRegs = 5;
89 static constexpr int kNumberOfSavedFpParamRegs = 6;
90
91 // There's one spilled value (which doesn't need visiting) below the instance.
92 static constexpr int kInstanceSpillOffset =
94
95 static constexpr int kParameterSpillsOffset[] = {
99
100 // SP-relative.
101 static constexpr int kWasmInstanceDataOffset = 2 * kSystemPointerSize;
102 static constexpr int kDeclaredFunctionIndexOffset = 1 * kSystemPointerSize;
103 static constexpr int kNativeModuleOffset = 0;
104};
105
107 public:
108 static constexpr int kFeedbackVectorOffset = 3 * kSystemPointerSize;
109 static constexpr int kInstanceDataOffset = 2 * kSystemPointerSize;
110};
111
112// Frame constructed by the {WasmDebugBreak} builtin.
113// After pushing the frame type marker, the builtin pushes all Liftoff cache
114// registers (see liftoff-assembler-defs.h).
116 public:
117 static constexpr RegList kPushedGpRegs = {rax, rcx, rdx, rbx, rsi,
118 rdi, r8, r9, r12, r15};
119
120 static constexpr DoubleRegList kPushedFpRegs = {xmm0, xmm1, xmm2, xmm3,
121 xmm4, xmm5, xmm6, xmm7};
122
123 static constexpr int kNumPushedGpRegisters = kPushedGpRegs.Count();
124 static constexpr int kNumPushedFpRegisters = kPushedFpRegs.Count();
125
126 static constexpr int kLastPushedGpRegisterOffset =
128 static constexpr int kLastPushedFpRegisterOffset =
130
131 // Offsets are fp-relative.
132 static int GetPushedGpRegisterOffset(int reg_code) {
133 DCHECK_NE(0, kPushedGpRegs.bits() & (1 << reg_code));
134 uint32_t lower_regs =
135 kPushedGpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
138 }
139
140 static int GetPushedFpRegisterOffset(int reg_code) {
141 DCHECK_NE(0, kPushedFpRegs.bits() & (1 << reg_code));
142 uint32_t lower_regs =
143 kPushedFpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
146 }
147};
148
149} // namespace internal
150} // namespace v8
151
152#endif // V8_EXECUTION_X64_FRAME_CONSTANTS_X64_H_
static constexpr int kNextFastCallFrameFPOffset
static constexpr int kNextExitFrameFPOffset
static constexpr int kNextFastCallFramePCOffset
constexpr unsigned Count() const
constexpr storage_t bits() const
static constexpr int kFixedFrameSizeFromFp
static constexpr DoubleRegList kPushedFpRegs
#define TYPED_FRAME_PUSHED_VALUE_OFFSET(x)
constexpr unsigned CountPopulation(T value)
Definition bits.h:26
constexpr int kSimd128Size
Definition globals.h:706
constexpr int kSystemPointerSize
Definition globals.h:410
#define DCHECK_NE(v1, v2)
Definition logging.h:486