1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef V8_MIPS_FRAMES_MIPS_H_
31 #define V8_MIPS_FRAMES_MIPS_H_
37 // Note that the bit values must match those used in actual instruction
39 static const int kNumRegs = 32;
41 static const RegList kJSCallerSaved =
57 static const int kNumJSCallerSaved = 14;
60 // Return the code of the n-th caller-saved register available to JavaScript
61 // e.g. JSCallerSavedReg(0) returns a0.code() == 4.
62 int JSCallerSavedCode(int n);
65 // Callee-saved registers preserved when switching from C to JavaScript.
66 static const RegList kCalleeSaved =
73 1 << 22 | // s6 (roots in Javascript code)
74 1 << 23 | // s7 (cp in Javascript code)
77 static const int kNumCalleeSaved = 9;
79 static const RegList kCalleeSavedFPU =
87 static const int kNumCalleeSavedFPU = 6;
89 static const RegList kCallerSavedFPU =
102 // Number of registers for which space is reserved in safepoints. Must be a
104 static const int kNumSafepointRegisters = 24;
106 // Define the list of registers actually saved at safepoints.
107 // Note that the number of saved registers may be smaller than the reserved
108 // space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters.
109 static const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved;
110 static const int kNumSafepointSavedRegisters =
111 kNumJSCallerSaved + kNumCalleeSaved;
113 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
115 static const int kUndefIndex = -1;
116 // Map with indexes on stack that corresponds to codes of saved registers.
117 static const int kSafepointRegisterStackIndexMap[kNumRegs] = {
118 kUndefIndex, // zero_reg
153 // ----------------------------------------------------
155 class StackHandlerConstants : public AllStatic {
157 static const int kNextOffset = 0 * kPointerSize;
158 static const int kStateOffset = 1 * kPointerSize;
159 static const int kContextOffset = 2 * kPointerSize;
160 static const int kFPOffset = 3 * kPointerSize;
161 static const int kPCOffset = 4 * kPointerSize;
163 static const int kSize = kPCOffset + kPointerSize;
167 class EntryFrameConstants : public AllStatic {
169 static const int kCallerFPOffset = -3 * kPointerSize;
173 class ExitFrameConstants : public AllStatic {
175 // See some explanation in MacroAssembler::EnterExitFrame.
176 // This marks the top of the extra allocated stack space.
177 static const int kStackSpaceOffset = -3 * kPointerSize;
179 static const int kCodeOffset = -2 * kPointerSize;
181 static const int kSPOffset = -1 * kPointerSize;
183 // The caller fields are below the frame pointer on the stack.
184 static const int kCallerFPOffset = +0 * kPointerSize;
185 // The calling JS function is between FP and PC.
186 static const int kCallerPCOffset = +1 * kPointerSize;
188 // MIPS-specific: a pointer to the old sp to avoid unnecessary calculations.
189 static const int kCallerSPOffset = +2 * kPointerSize;
191 // FP-relative displacement of the caller's SP.
192 static const int kCallerSPDisplacement = +2 * kPointerSize;
196 class StandardFrameConstants : public AllStatic {
198 static const int kExpressionsOffset = -3 * kPointerSize;
199 static const int kMarkerOffset = -2 * kPointerSize;
200 static const int kContextOffset = -1 * kPointerSize;
201 static const int kCallerFPOffset = 0 * kPointerSize;
202 static const int kCallerPCOffset = +1 * kPointerSize;
203 static const int kCallerSPOffset = +2 * kPointerSize;
205 // Size of the MIPS 4 32-bit argument slots.
206 // This is just an alias with a shorter name. Use it from now on.
207 static const int kRArgsSlotsSize = 4 * kPointerSize;
208 static const int kRegularArgsSlotsSize = kRArgsSlotsSize;
210 // JS argument slots size.
211 static const int kJSArgsSlotsSize = 0 * kPointerSize;
212 // Assembly builtins argument slots size.
213 static const int kBArgsSlotsSize = 0 * kPointerSize;
217 class JavaScriptFrameConstants : public AllStatic {
220 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
221 static const int kLastParameterOffset = +2 * kPointerSize;
222 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
224 // Caller SP-relative.
225 static const int kParam0Offset = -2 * kPointerSize;
226 static const int kReceiverOffset = -1 * kPointerSize;
230 class ArgumentsAdaptorFrameConstants : public AllStatic {
232 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
236 class InternalFrameConstants : public AllStatic {
238 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
242 inline Object* JavaScriptFrame::function_slot_object() const {
243 const int offset = JavaScriptFrameConstants::kFunctionOffset;
244 return Memory::Object_at(fp() + offset);
248 } } // namespace v8::internal