1 // Copyright 2011 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.
7 #ifndef V8_MIPS_FRAMES_MIPS_H_
8 #define V8_MIPS_FRAMES_MIPS_H_
14 // Note that the bit values must match those used in actual instruction
16 const int kNumRegs = 32;
18 const RegList kJSCallerSaved =
34 const int kNumJSCallerSaved = 14;
37 // Return the code of the n-th caller-saved register available to JavaScript
38 // e.g. JSCallerSavedReg(0) returns a0.code() == 4.
39 int JSCallerSavedCode(int n);
42 // Callee-saved registers preserved when switching from C to JavaScript.
43 const RegList kCalleeSaved =
50 1 << 22 | // s6 (roots in Javascript code)
51 1 << 23 | // s7 (cp in Javascript code)
54 const int kNumCalleeSaved = 9;
56 const RegList kCalleeSavedFPU =
64 const int kNumCalleeSavedFPU = 6;
66 const RegList kCallerSavedFPU =
79 // Number of registers for which space is reserved in safepoints. Must be a
81 const int kNumSafepointRegisters = 24;
83 // Define the list of registers actually saved at safepoints.
84 // Note that the number of saved registers may be smaller than the reserved
85 // space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters.
86 const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved;
87 const int kNumSafepointSavedRegisters =
88 kNumJSCallerSaved + kNumCalleeSaved;
90 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
92 const int kUndefIndex = -1;
93 // Map with indexes on stack that corresponds to codes of saved registers.
94 const int kSafepointRegisterStackIndexMap[kNumRegs] = {
95 kUndefIndex, // zero_reg
130 // ----------------------------------------------------
132 class EntryFrameConstants : public AllStatic {
134 static const int kCallerFPOffset =
135 -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
139 class ExitFrameConstants : public AllStatic {
141 static const int kFrameSize = 2 * kPointerSize;
143 static const int kCodeOffset = -2 * kPointerSize;
144 static const int kSPOffset = -1 * kPointerSize;
146 // The caller fields are below the frame pointer on the stack.
147 static const int kCallerFPOffset = +0 * kPointerSize;
148 // The calling JS function is between FP and PC.
149 static const int kCallerPCOffset = +1 * kPointerSize;
151 // MIPS-specific: a pointer to the old sp to avoid unnecessary calculations.
152 static const int kCallerSPOffset = +2 * kPointerSize;
154 // FP-relative displacement of the caller's SP.
155 static const int kCallerSPDisplacement = +2 * kPointerSize;
157 static const int kConstantPoolOffset = 0; // Not used.
161 class JavaScriptFrameConstants : public AllStatic {
164 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
165 static const int kLastParameterOffset = +2 * kPointerSize;
166 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
168 // Caller SP-relative.
169 static const int kParam0Offset = -2 * kPointerSize;
170 static const int kReceiverOffset = -1 * kPointerSize;
174 class ArgumentsAdaptorFrameConstants : public AllStatic {
177 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
179 static const int kFrameSize =
180 StandardFrameConstants::kFixedFrameSize + kPointerSize;
184 class ConstructFrameConstants : public AllStatic {
187 static const int kImplicitReceiverOffset = -6 * kPointerSize;
188 static const int kConstructorOffset = -5 * kPointerSize;
189 static const int kLengthOffset = -4 * kPointerSize;
190 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
192 static const int kFrameSize =
193 StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
197 class InternalFrameConstants : public AllStatic {
200 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
204 inline Object* JavaScriptFrame::function_slot_object() const {
205 const int offset = JavaScriptFrameConstants::kFunctionOffset;
206 return Memory::Object_at(fp() + offset);
210 inline void StackHandler::SetFp(Address slot, Address fp) {
211 Memory::Address_at(slot) = fp;
215 } } // namespace v8::internal