blob: 37927758c3559dda43f8eb6ef13fa61c88bf906d [file] [log] [blame]
Ben Murdoch3ef787d2012-04-12 10:51:47 +01001// Copyright 2012 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Blocka7e24c12009-10-30 11:49:00 +00004
5#ifndef V8_ARM_FRAMES_ARM_H_
6#define V8_ARM_FRAMES_ARM_H_
7
8namespace v8 {
9namespace internal {
10
11
12// The ARM ABI does not specify the usage of register r9, which may be reserved
13// as the static base or thread register on some platforms, in which case we
14// leave it alone. Adjust the value of kR9Available accordingly:
Ben Murdoch3ef787d2012-04-12 10:51:47 +010015const int kR9Available = 1; // 1 if available to us, 0 if reserved
Steve Blocka7e24c12009-10-30 11:49:00 +000016
17
18// Register list in load/store instructions
19// Note that the bit values must match those used in actual instruction encoding
Ben Murdoch3ef787d2012-04-12 10:51:47 +010020const int kNumRegs = 16;
Steve Blocka7e24c12009-10-30 11:49:00 +000021
22
23// Caller-saved/arguments registers
Ben Murdoch3ef787d2012-04-12 10:51:47 +010024const RegList kJSCallerSaved =
Steve Blocka7e24c12009-10-30 11:49:00 +000025 1 << 0 | // r0 a1
26 1 << 1 | // r1 a2
27 1 << 2 | // r2 a3
28 1 << 3; // r3 a4
29
Ben Murdoch3ef787d2012-04-12 10:51:47 +010030const int kNumJSCallerSaved = 4;
Steve Blocka7e24c12009-10-30 11:49:00 +000031
Steve Blocka7e24c12009-10-30 11:49:00 +000032// Return the code of the n-th caller-saved register available to JavaScript
33// e.g. JSCallerSavedReg(0) returns r0.code() == 0
34int JSCallerSavedCode(int n);
35
36
37// Callee-saved registers preserved when switching from C to JavaScript
Ben Murdoch3ef787d2012-04-12 10:51:47 +010038const RegList kCalleeSaved =
Steve Blocka7e24c12009-10-30 11:49:00 +000039 1 << 4 | // r4 v1
40 1 << 5 | // r5 v2
41 1 << 6 | // r6 v3
Ben Murdochb8a8cc12014-11-26 15:28:44 +000042 1 << 7 | // r7 v4 (cp in JavaScript code)
43 1 << 8 | // r8 v5 (pp in JavaScript code)
Steve Block1e0659c2011-05-24 12:43:12 +010044 kR9Available << 9 | // r9 v6
Steve Blocka7e24c12009-10-30 11:49:00 +000045 1 << 10 | // r10 v7
46 1 << 11; // r11 v8 (fp in JavaScript code)
47
Ben Murdoch3ef787d2012-04-12 10:51:47 +010048// When calling into C++ (only for C++ calls that can't cause a GC).
49// The call code will take care of lr, fp, etc.
50const RegList kCallerSaved =
51 1 << 0 | // r0
52 1 << 1 | // r1
53 1 << 2 | // r2
54 1 << 3 | // r3
55 1 << 9; // r9
56
57
58const int kNumCalleeSaved = 7 + kR9Available;
Steve Blocka7e24c12009-10-30 11:49:00 +000059
Ben Murdoch7d3e7fc2011-07-12 16:37:06 +010060// Double registers d8 to d15 are callee-saved.
Ben Murdoch3ef787d2012-04-12 10:51:47 +010061const int kNumDoubleCalleeSaved = 8;
Ben Murdoch7d3e7fc2011-07-12 16:37:06 +010062
Steve Blocka7e24c12009-10-30 11:49:00 +000063
Ben Murdochb0fe1622011-05-05 13:52:32 +010064// Number of registers for which space is reserved in safepoints. Must be a
65// multiple of 8.
66// TODO(regis): Only 8 registers may actually be sufficient. Revisit.
Ben Murdoch3ef787d2012-04-12 10:51:47 +010067const int kNumSafepointRegisters = 16;
Ben Murdochb0fe1622011-05-05 13:52:32 +010068
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000069// The embedded constant pool pointer (r8/pp) is not included in the safepoint
70// since it is not tagged. This register is preserved in the stack frame where
71// its value will be updated if GC code movement occurs. Including it in the
72// safepoint (where it will not be relocated) would cause a stale value to be
73// restored.
74const RegList kConstantPointerRegMask =
75 FLAG_enable_embedded_constant_pool ? (1 << 8) : 0;
76const int kNumConstantPoolPointerReg =
77 FLAG_enable_embedded_constant_pool ? 1 : 0;
78
Ben Murdochb0fe1622011-05-05 13:52:32 +010079// Define the list of registers actually saved at safepoints.
80// Note that the number of saved registers may be smaller than the reserved
81// space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000082const RegList kSafepointSavedRegisters =
83 kJSCallerSaved | (kCalleeSaved & ~kConstantPointerRegMask);
84const int kNumSafepointSavedRegisters =
85 kNumJSCallerSaved + kNumCalleeSaved - kNumConstantPoolPointerReg;
Ben Murdochb0fe1622011-05-05 13:52:32 +010086
Steve Blocka7e24c12009-10-30 11:49:00 +000087// ----------------------------------------------------
88
89
Steve Blocka7e24c12009-10-30 11:49:00 +000090class EntryFrameConstants : public AllStatic {
91 public:
Ben Murdochb8a8cc12014-11-26 15:28:44 +000092 static const int kCallerFPOffset =
93 -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
Steve Blocka7e24c12009-10-30 11:49:00 +000094};
95
Ben Murdochda12d292016-06-02 14:46:10 +010096class ExitFrameConstants : public TypedFrameConstants {
Steve Blocka7e24c12009-10-30 11:49:00 +000097 public:
Ben Murdochda12d292016-06-02 14:46:10 +010098 static const int kSPOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
99 static const int kCodeOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
100 DEFINE_TYPED_FRAME_SIZES(2);
Steve Blocka7e24c12009-10-30 11:49:00 +0000101
Steve Blocka7e24c12009-10-30 11:49:00 +0000102 // The caller fields are below the frame pointer on the stack.
Steve Block1e0659c2011-05-24 12:43:12 +0100103 static const int kCallerFPOffset = 0 * kPointerSize;
104 // The calling JS function is below FP.
105 static const int kCallerPCOffset = 1 * kPointerSize;
Steve Blocka7e24c12009-10-30 11:49:00 +0000106
107 // FP-relative displacement of the caller's SP. It points just
108 // below the saved PC.
Steve Block1e0659c2011-05-24 12:43:12 +0100109 static const int kCallerSPDisplacement = 2 * kPointerSize;
Steve Blocka7e24c12009-10-30 11:49:00 +0000110};
111
112
Steve Blocka7e24c12009-10-30 11:49:00 +0000113class JavaScriptFrameConstants : public AllStatic {
114 public:
115 // FP-relative.
116 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
Ben Murdoch8b112d22011-06-08 16:22:53 +0100117 static const int kLastParameterOffset = +2 * kPointerSize;
Ben Murdochda12d292016-06-02 14:46:10 +0100118 static const int kFunctionOffset = StandardFrameConstants::kFunctionOffset;
Steve Blocka7e24c12009-10-30 11:49:00 +0000119
120 // Caller SP-relative.
121 static const int kParam0Offset = -2 * kPointerSize;
122 static const int kReceiverOffset = -1 * kPointerSize;
123};
124
125
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000126} // namespace internal
127} // namespace v8
Steve Blocka7e24c12009-10-30 11:49:00 +0000128
129#endif // V8_ARM_FRAMES_ARM_H_