v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
frame-constants-arm.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_ARM_FRAME_CONSTANTS_ARM_H_
6#define V8_EXECUTION_ARM_FRAME_CONSTANTS_ARM_H_
7
8#include "src/base/bits.h"
9#include "src/base/macros.h"
12
13namespace v8 {
14namespace internal {
15
16// The layout of an EntryFrame is as follows:
17// TOP OF THE STACK LOWEST ADDRESS
18// +---------------------+-----------------------
19// -6 | outermost marker |
20// |- - - - - - - - - - -|
21// -5 | fast api call pc |
22// |- - - - - - - - - - -|
23// -4 | fast api call fp |
24// |- - - - - - - - - - -|
25// -3 | centry fp |
26// |- - - - - - - - - - -|
27// -2 | stack frame marker |
28// |- - - - - - - - - - -|
29// -1 | stack frame marker |
30// |- - - - - - - - - - -|
31// 0 | saved fp (r11) | <-- frame ptr
32// |- - - - - - - - - - -|
33// 1 | saved lr (r14) |
34// |- - - - - - - - - - -|
35// 2..3 | saved register d8 |
36// ... | ... |
37// 16..17 | saved register d15 |
38// |- - - - - - - - - - -|
39// 18 | saved register r4 |
40// ... | ... |
41// 24 | saved register r10 |
42// -----+---------------------+-----------------------
43// BOTTOM OF THE STACK HIGHEST ADDRESS
44class EntryFrameConstants : public AllStatic {
45 public:
46 // This is the offset to where JSEntry pushes the current value of
47 // Isolate::c_entry_fp onto the stack.
48 static constexpr int kNextExitFrameFPOffset = -3 * kSystemPointerSize;
49
50 static constexpr int kNextFastCallFrameFPOffset =
52 static constexpr int kNextFastCallFramePCOffset =
54
55 // Stack offsets for arguments passed to JSEntry.
56 static constexpr int kArgcOffset = +0 * kSystemPointerSize;
57 static constexpr int kArgvOffset = +1 * kSystemPointerSize;
58
59 // These offsets refer to the immediate caller (i.e a native frame).
60 static constexpr int kDirectCallerFPOffset = 0;
61 static constexpr int kDirectCallerPCOffset =
65 /* saved caller PC */
67 /* d8...d15 */
69 static constexpr int kDirectCallerSPOffset =
71 /* r4...r10 (i.e. callee saved without fp) */
73};
74
76 public:
77 // Number of gp parameters, without the instance.
78 static constexpr int kNumberOfSavedGpParamRegs = 3;
79 static constexpr int kNumberOfSavedFpParamRegs = 8;
80
81 // On arm, spilled registers are implicitly sorted backwards by number.
82 // We spill:
83 // r3: param0 = instance
84 // r0, r2, r6: param1, param2, param3
85 // lr (== r14): internal usage of the caller
86 // in the following FP-relative order: [lr, r6, r3, r2, r0].
87 static constexpr int kInstanceSpillOffset =
89
93
94 // SP-relative.
95 static constexpr int kWasmInstanceDataOffset = 2 * kSystemPointerSize;
97 static constexpr int kNativeModuleOffset = 0;
98};
99
101 public:
102 static constexpr int kFeedbackVectorOffset = 3 * kSystemPointerSize;
103 static constexpr int kInstanceDataOffset = 2 * kSystemPointerSize;
104};
105
106// Frame constructed by the {WasmDebugBreak} builtin.
107// After pushing the frame type marker, the builtin pushes all Liftoff cache
108// registers (see liftoff-assembler-defs.h).
110 public:
111 // r10: root, r11: fp, r12: ip, r13: sp, r14: lr, r15: pc.
112 static constexpr RegList kPushedGpRegs = {r0, r1, r2, r3, r4,
113 r5, r6, r7, r8, r9};
114
115 // d13: zero, d14-d15: scratch
116 static constexpr DoubleRegList kPushedFpRegs = {d0, d1, d2, d3, d4, d5, d6,
117 d7, d8, d9, d10, d11, d12};
118
119 static constexpr int kNumPushedGpRegisters = kPushedGpRegs.Count();
120 static constexpr int kNumPushedFpRegisters = kPushedFpRegs.Count();
121
122 static constexpr int kLastPushedGpRegisterOffset =
125 static constexpr int kLastPushedFpRegisterOffset =
127
128 // Offsets are fp-relative.
129 static int GetPushedGpRegisterOffset(int reg_code) {
130 DCHECK_NE(0, kPushedGpRegs.bits() & (1 << reg_code));
131 uint32_t lower_regs =
132 kPushedGpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
135 }
136
137 static int GetPushedFpRegisterOffset(int reg_code) {
138 DCHECK_NE(0, kPushedFpRegs.bits() & (1 << reg_code));
139 uint32_t lower_regs =
140 kPushedFpRegs.bits() & ((uint32_t{1} << reg_code) - 1);
143 }
144};
145
146} // namespace internal
147} // namespace v8
148
149#endif // V8_EXECUTION_ARM_FRAME_CONSTANTS_ARM_H_
static constexpr int kNextFastCallFrameFPOffset
static constexpr int kNextExitFrameFPOffset
static constexpr int kDirectCallerGeneralRegistersOffset
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 kSystemPointerSize
Definition globals.h:410
constexpr int kDoubleSize
Definition globals.h:407
const int kNumCalleeSaved
Definition reglist-arm.h:48
const int kNumDoubleCalleeSaved
Definition reglist-arm.h:51
#define DCHECK_NE(v1, v2)
Definition logging.h:486