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.
5 #ifndef V8_ARM_FRAMES_ARM_H_
6 #define V8_ARM_FRAMES_ARM_H_
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:
15 const int kR9Available = 1; // 1 if available to us, 0 if reserved
18 // Register list in load/store instructions
19 // Note that the bit values must match those used in actual instruction encoding
20 const int kNumRegs = 16;
23 // Caller-saved/arguments registers
24 const RegList kJSCallerSaved =
30 const int kNumJSCallerSaved = 4;
32 // Return the code of the n-th caller-saved register available to JavaScript
33 // e.g. JSCallerSavedReg(0) returns r0.code() == 0
34 int JSCallerSavedCode(int n);
37 // Callee-saved registers preserved when switching from C to JavaScript
38 const RegList kCalleeSaved =
42 1 << 7 | // r7 v4 (cp in JavaScript code)
43 1 << 8 | // r8 v5 (pp in JavaScript code)
44 kR9Available << 9 | // r9 v6
46 1 << 11; // r11 v8 (fp in JavaScript code)
48 // 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.
50 const RegList kCallerSaved =
58 const int kNumCalleeSaved = 7 + kR9Available;
60 // Double registers d8 to d15 are callee-saved.
61 const int kNumDoubleCalleeSaved = 8;
64 // Number of registers for which space is reserved in safepoints. Must be a
66 // TODO(regis): Only 8 registers may actually be sufficient. Revisit.
67 const int kNumSafepointRegisters = 16;
69 // 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
74 const RegList kConstantPointerRegMask =
75 FLAG_enable_embedded_constant_pool ? (1 << 8) : 0;
76 const int kNumConstantPoolPointerReg =
77 FLAG_enable_embedded_constant_pool ? 1 : 0;
79 // 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.
82 const RegList kSafepointSavedRegisters =
83 kJSCallerSaved | (kCalleeSaved & ~kConstantPointerRegMask);
84 const int kNumSafepointSavedRegisters =
85 kNumJSCallerSaved + kNumCalleeSaved - kNumConstantPoolPointerReg;
87 // ----------------------------------------------------
90 class EntryFrameConstants : public AllStatic {
92 static const int kCallerFPOffset =
93 -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
97 class ExitFrameConstants : public AllStatic {
99 static const int kFrameSize =
100 FLAG_enable_embedded_constant_pool ? 3 * kPointerSize : 2 * kPointerSize;
102 static const int kConstantPoolOffset =
103 FLAG_enable_embedded_constant_pool ? -3 * kPointerSize : 0;
104 static const int kCodeOffset = -2 * kPointerSize;
105 static const int kSPOffset = -1 * kPointerSize;
107 // The caller fields are below the frame pointer on the stack.
108 static const int kCallerFPOffset = 0 * kPointerSize;
109 // The calling JS function is below FP.
110 static const int kCallerPCOffset = 1 * kPointerSize;
112 // FP-relative displacement of the caller's SP. It points just
113 // below the saved PC.
114 static const int kCallerSPDisplacement = 2 * kPointerSize;
118 class JavaScriptFrameConstants : public AllStatic {
121 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
122 static const int kLastParameterOffset = +2 * kPointerSize;
123 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
125 // Caller SP-relative.
126 static const int kParam0Offset = -2 * kPointerSize;
127 static const int kReceiverOffset = -1 * kPointerSize;
131 class ArgumentsAdaptorFrameConstants : public AllStatic {
134 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
136 static const int kFrameSize =
137 StandardFrameConstants::kFixedFrameSize + kPointerSize;
141 class ConstructFrameConstants : public AllStatic {
144 static const int kImplicitReceiverOffset = -5 * kPointerSize;
145 static const int kLengthOffset = -4 * kPointerSize;
146 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
148 static const int kFrameSize =
149 StandardFrameConstants::kFixedFrameSize + 3 * kPointerSize;
153 class InternalFrameConstants : public AllStatic {
156 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
160 inline Object* JavaScriptFrame::function_slot_object() const {
161 const int offset = JavaScriptFrameConstants::kFunctionOffset;
162 return Memory::Object_at(fp() + offset);
166 } } // namespace v8::internal
168 #endif // V8_ARM_FRAMES_ARM_H_