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 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
34 // Return the code of the n-th caller-saved register available to JavaScript
35 // e.g. JSCallerSavedReg(0) returns r0.code() == 0
36 int JSCallerSavedCode(int n);
39 // Callee-saved registers preserved when switching from C to JavaScript
40 const RegList kCalleeSaved =
44 1 << 7 | // r7 v4 (cp in JavaScript code)
45 1 << 8 | // r8 v5 (pp in JavaScript code)
46 kR9Available << 9 | // r9 v6
48 1 << 11; // r11 v8 (fp in JavaScript code)
50 // When calling into C++ (only for C++ calls that can't cause a GC).
51 // The call code will take care of lr, fp, etc.
52 const RegList kCallerSaved =
60 const int kNumCalleeSaved = 7 + kR9Available;
62 // Double registers d8 to d15 are callee-saved.
63 const int kNumDoubleCalleeSaved = 8;
66 // Number of registers for which space is reserved in safepoints. Must be a
68 // TODO(regis): Only 8 registers may actually be sufficient. Revisit.
69 const int kNumSafepointRegisters = 16;
71 // Define the list of registers actually saved at safepoints.
72 // Note that the number of saved registers may be smaller than the reserved
73 // space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters.
74 const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved;
75 const int kNumSafepointSavedRegisters = kNumJSCallerSaved + kNumCalleeSaved;
77 // ----------------------------------------------------
80 class EntryFrameConstants : public AllStatic {
82 static const int kCallerFPOffset =
83 -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
87 class ExitFrameConstants : public AllStatic {
89 static const int kFrameSize = FLAG_enable_ool_constant_pool ?
90 3 * kPointerSize : 2 * kPointerSize;
92 static const int kConstantPoolOffset = FLAG_enable_ool_constant_pool ?
93 -3 * kPointerSize : 0;
94 static const int kCodeOffset = -2 * kPointerSize;
95 static const int kSPOffset = -1 * kPointerSize;
97 // The caller fields are below the frame pointer on the stack.
98 static const int kCallerFPOffset = 0 * kPointerSize;
99 // The calling JS function is below FP.
100 static const int kCallerPCOffset = 1 * kPointerSize;
102 // FP-relative displacement of the caller's SP. It points just
103 // below the saved PC.
104 static const int kCallerSPDisplacement = 2 * kPointerSize;
108 class JavaScriptFrameConstants : public AllStatic {
111 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
112 static const int kLastParameterOffset = +2 * kPointerSize;
113 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
115 // Caller SP-relative.
116 static const int kParam0Offset = -2 * kPointerSize;
117 static const int kReceiverOffset = -1 * kPointerSize;
121 class ArgumentsAdaptorFrameConstants : public AllStatic {
124 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
126 static const int kFrameSize =
127 StandardFrameConstants::kFixedFrameSize + kPointerSize;
131 class ConstructFrameConstants : public AllStatic {
134 static const int kImplicitReceiverOffset = -6 * kPointerSize;
135 static const int kConstructorOffset = -5 * kPointerSize;
136 static const int kLengthOffset = -4 * kPointerSize;
137 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
139 static const int kFrameSize =
140 StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
144 class InternalFrameConstants : public AllStatic {
147 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
151 inline Object* JavaScriptFrame::function_slot_object() const {
152 const int offset = JavaScriptFrameConstants::kFunctionOffset;
153 return Memory::Object_at(fp() + offset);
157 inline void StackHandler::SetFp(Address slot, Address fp) {
158 Memory::Address_at(slot) = fp;
162 } } // namespace v8::internal
164 #endif // V8_ARM_FRAMES_ARM_H_