1 // Copyright 2006-2008 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.
28 #ifndef V8_ARM_FRAMES_ARM_H_
29 #define V8_ARM_FRAMES_ARM_H_
37 // The ARM ABI does not specify the usage of register r9, which may be reserved
38 // as the static base or thread register on some platforms, in which case we
39 // leave it alone. Adjust the value of kR9Available accordingly:
40 static const int kR9Available = 1; // 1 if available to us, 0 if reserved
43 // Register list in load/store instructions
44 // Note that the bit values must match those used in actual instruction encoding
45 static const int kNumRegs = 16;
48 // Caller-saved/arguments registers
49 static const RegList kJSCallerSaved =
55 static const int kNumJSCallerSaved = 4;
57 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
59 // Return the code of the n-th caller-saved register available to JavaScript
60 // e.g. JSCallerSavedReg(0) returns r0.code() == 0
61 int JSCallerSavedCode(int n);
64 // Callee-saved registers preserved when switching from C to JavaScript
65 static const RegList kCalleeSaved =
70 1 << 8 | // r8 v5 (cp in JavaScript code)
71 kR9Available << 9 | // r9 v6
73 1 << 11; // r11 v8 (fp in JavaScript code)
75 static const int kNumCalleeSaved = 7 + kR9Available;
78 // Number of registers for which space is reserved in safepoints. Must be a
80 // TODO(regis): Only 8 registers may actually be sufficient. Revisit.
81 static const int kNumSafepointRegisters = 16;
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 static const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved;
87 static const int kNumSafepointSavedRegisters =
88 kNumJSCallerSaved + kNumCalleeSaved;
90 // ----------------------------------------------------
93 class StackHandlerConstants : public AllStatic {
95 static const int kNextOffset = 0 * kPointerSize;
96 static const int kStateOffset = 1 * kPointerSize;
97 static const int kFPOffset = 2 * kPointerSize;
98 static const int kPCOffset = 3 * kPointerSize;
100 static const int kSize = kPCOffset + kPointerSize;
104 class EntryFrameConstants : public AllStatic {
106 static const int kCallerFPOffset = -3 * kPointerSize;
110 class ExitFrameConstants : public AllStatic {
112 static const int kCodeOffset = -2 * kPointerSize;
113 static const int kSPOffset = -1 * kPointerSize;
115 // The caller fields are below the frame pointer on the stack.
116 static const int kCallerFPOffset = 0 * kPointerSize;
117 // The calling JS function is below FP.
118 static const int kCallerPCOffset = 1 * kPointerSize;
120 // FP-relative displacement of the caller's SP. It points just
121 // below the saved PC.
122 static const int kCallerSPDisplacement = 2 * kPointerSize;
126 class StandardFrameConstants : public AllStatic {
128 static const int kExpressionsOffset = -3 * kPointerSize;
129 static const int kMarkerOffset = -2 * kPointerSize;
130 static const int kContextOffset = -1 * kPointerSize;
131 static const int kCallerFPOffset = 0 * kPointerSize;
132 static const int kCallerPCOffset = 1 * kPointerSize;
133 static const int kCallerSPOffset = 2 * kPointerSize;
137 class JavaScriptFrameConstants : public AllStatic {
140 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
141 static const int kSavedRegistersOffset = +2 * kPointerSize;
142 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
144 // Caller SP-relative.
145 static const int kParam0Offset = -2 * kPointerSize;
146 static const int kReceiverOffset = -1 * kPointerSize;
150 class ArgumentsAdaptorFrameConstants : public AllStatic {
152 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
156 class InternalFrameConstants : public AllStatic {
158 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
162 inline Object* JavaScriptFrame::function_slot_object() const {
163 const int offset = JavaScriptFrameConstants::kFunctionOffset;
164 return Memory::Object_at(fp() + offset);
168 } } // namespace v8::internal
170 #endif // V8_ARM_FRAMES_ARM_H_