v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
frame-constants-arm64.h
Go to the documentation of this file.
1// Copyright 2013 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_ARM64_FRAME_CONSTANTS_ARM64_H_
6#define V8_EXECUTION_ARM64_FRAME_CONSTANTS_ARM64_H_
7
8#include "src/base/bits.h"
9#include "src/base/macros.h"
11#include "src/codegen/reglist.h"
12#include "src/common/globals.h"
14
15namespace v8 {
16namespace internal {
17
18// The layout of an EntryFrame is as follows:
19//
20// BOTTOM OF THE STACK HIGHEST ADDRESS
21// slot Entry frame
22// +---------------------+-----------------------
23// -19 | saved register d15 |
24// ... | ... |
25// -12 | saved register d8 |
26// |- - - - - - - - - - -|
27// -11 | saved register x28 |
28// ... | ... |
29// -2 | saved register x19 |
30// |- - - - - - - - - - -|
31// -1 | saved lr (x30) |
32// |- - - - - - - - - - -|
33// 0 | saved fp (x29) | <-- frame ptr
34// |- - - - - - - - - - -|
35// 1 | stack frame marker |
36// | (ENTRY) |
37// |- - - - - - - - - - -|
38// 2 | stack frame marker |
39// | (0) |
40// |- - - - - - - - - - -|
41// 3 | C entry FP |
42// |- - - - - - - - - - -|
43// 4 | JS entry frame |
44// | marker |
45// |- - - - - - - - - - -|
46// 5 | fast api call fp |
47// |- - - - - - - - - - -|
48// 6 | fast api call pc | <-- stack ptr
49// -----+---------------------+-----------------------
50// TOP OF THE STACK LOWEST ADDRESS
51//
52class EntryFrameConstants : public AllStatic {
53 public:
54 // This is the offset to where JSEntry pushes the current value of
55 // Isolate::c_entry_fp onto the stack.
56 static constexpr int kNextExitFrameFPOffset = -3 * kSystemPointerSize;
57 // The offsets for storing the FP and PC of fast API calls.
58 static constexpr int kNextFastCallFrameFPOffset = -5 * kSystemPointerSize;
59 static constexpr int kNextFastCallFramePCOffset = -6 * kSystemPointerSize;
60
61 static constexpr int kFixedFrameSize = 6 * kSystemPointerSize;
62
63 // The following constants are defined so we can static-assert their values
64 // near the relevant JSEntry assembly code, not because they're actually very
65 // useful.
69 static constexpr int kOffsetToCalleeSavedRegisters = 0;
70
71 // These offsets refer to the immediate caller (a native frame), not to the
72 // previous JS exit frame like kCallerFPOffset above.
73 static constexpr int kDirectCallerFPOffset =
76 static constexpr int kDirectCallerPCOffset =
78 static constexpr int kDirectCallerSPOffset =
81};
82
84 public:
85 // Number of gp parameters, without the instance.
86 static constexpr int kNumberOfSavedGpParamRegs = 6;
87 static constexpr int kNumberOfSavedFpParamRegs = 8;
88
89 // On arm, spilled registers are implicitly sorted backwards by number.
90 // We spill:
91 // x0, x2, x3, x4, x5, x6: param1, param2, ..., param6
92 // in the following FP-relative order: [x6, x5, x4, x3, x2, x0].
93 // The instance slot is in position '0', the first spill slot is at '1'.
94 static constexpr int kInstanceSpillOffset =
96
97 static constexpr int kParameterSpillsOffset[] = {
101
102 // SP-relative.
103 static constexpr int kWasmInstanceDataOffset = 2 * kSystemPointerSize;
104 static constexpr int kDeclaredFunctionIndexOffset = 1 * kSystemPointerSize;
105 static constexpr int kNativeModuleOffset = 0;
106};
107
108class WasmLiftoffFrameConstants : public TypedFrameConstants {
109 public:
110 static constexpr int kFeedbackVectorOffset = 3 * kSystemPointerSize;
111 static constexpr int kInstanceDataOffset = 2 * kSystemPointerSize;
112};
113
114// Frame constructed by the {WasmDebugBreak} builtin.
115// After pushing the frame type marker, the builtin pushes all Liftoff cache
116// registers (see liftoff-assembler-defs.h).
117class WasmDebugBreakFrameConstants : public TypedFrameConstants {
118 public:
119 // x16: ip0, x17: ip1, x18: platform register, x26: root, x28: base, x29: fp,
120 // x30: lr, x31: xzr.
121 static constexpr RegList kPushedGpRegs = {
122 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11,
123 x12, x13, x14, x15, x19, x20, x21, x22, x23, x24, x25, x27};
124
125 // We push FpRegs as 128-bit SIMD registers, so 16-byte frame alignment
126 // is guaranteed regardless of register count.
127 static constexpr DoubleRegList kPushedFpRegs = {
128 d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13,
129 d14, d16, d17, d18, d19, d20, d21, d22, d23, d24, d25, d26, d27};
130
131 static constexpr int kNumPushedGpRegisters = kPushedGpRegs.Count();
132 static_assert(kNumPushedGpRegisters % 2 == 0,
133 "stack frames need to be 16-byte aligned");
134
135 static constexpr int kNumPushedFpRegisters = kPushedFpRegs.Count();
136
137 static constexpr int kLastPushedGpRegisterOffset =
138 // Header is padded to 16 byte (see {MacroAssembler::EnterFrame}).
141 static constexpr int kLastPushedFpRegisterOffset =
143
144 // Offsets are fp-relative.
145 static int GetPushedGpRegisterOffset(int reg_code) {
146 DCHECK_NE(0, kPushedGpRegs.bits() & (1 << reg_code));
147 uint32_t lower_regs =
148 kPushedGpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
151 }
152
153 static int GetPushedFpRegisterOffset(int reg_code) {
154 DCHECK_NE(0, kPushedFpRegs.bits() & (1 << reg_code));
155 uint32_t lower_regs =
156 kPushedFpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
159 }
160};
161
162} // namespace internal
163} // namespace v8
164
165#endif // V8_EXECUTION_ARM64_FRAME_CONSTANTS_ARM64_H_
static constexpr int kNextFastCallFrameFPOffset
static constexpr int kOffsetToCalleeSavedRegisters
static constexpr int kNextExitFrameFPOffset
static constexpr int kCalleeSavedRegisterBytesPushedAfterFpLrPair
static constexpr int kCalleeSavedRegisterBytesPushedBeforeFpLrPair
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
RegListBase< DoubleRegister > DoubleRegList
Definition reglist-arm.h:15
constexpr int kSimd128Size
Definition globals.h:706
RegListBase< Register > RegList
Definition reglist-arm.h:14
constexpr int kSystemPointerSize
Definition globals.h:410
#define DCHECK_NE(v1, v2)
Definition logging.h:486
constexpr T RoundUp(T x, intptr_t m)
Definition macros.h:387