OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // |
| 3 // Copyright IBM Corp. 2012, 2013. All rights reserved. |
| 4 // |
| 5 // Use of this source code is governed by a BSD-style license that can be |
| 6 // found in the LICENSE file. |
| 7 |
| 8 #ifndef V8_PPC_FRAMES_PPC_H_ |
| 9 #define V8_PPC_FRAMES_PPC_H_ |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 |
| 14 |
| 15 // Register list in load/store instructions |
| 16 // Note that the bit values must match those used in actual instruction encoding |
| 17 const int kNumRegs = 32; |
| 18 |
| 19 |
| 20 // Caller-saved/arguments registers |
| 21 const RegList kJSCallerSaved = 1 << 3 | // r3 a1 |
| 22 1 << 4 | // r4 a2 |
| 23 1 << 5 | // r5 a3 |
| 24 1 << 6 | // r6 a4 |
| 25 1 << 7 | // r7 a5 |
| 26 1 << 8 | // r8 a6 |
| 27 1 << 9 | // r9 a7 |
| 28 1 << 10 | // r10 a8 |
| 29 1 << 11; |
| 30 |
| 31 const int kNumJSCallerSaved = 9; |
| 32 |
| 33 // Return the code of the n-th caller-saved register available to JavaScript |
| 34 // e.g. JSCallerSavedReg(0) returns r0.code() == 0 |
| 35 int JSCallerSavedCode(int n); |
| 36 |
| 37 |
| 38 // Callee-saved registers preserved when switching from C to JavaScript |
| 39 const RegList kCalleeSaved = 1 << 14 | // r14 |
| 40 1 << 15 | // r15 |
| 41 1 << 16 | // r16 |
| 42 1 << 17 | // r17 |
| 43 1 << 18 | // r18 |
| 44 1 << 19 | // r19 |
| 45 1 << 20 | // r20 |
| 46 1 << 21 | // r21 |
| 47 1 << 22 | // r22 |
| 48 1 << 23 | // r23 |
| 49 1 << 24 | // r24 |
| 50 1 << 25 | // r25 |
| 51 1 << 26 | // r26 |
| 52 1 << 27 | // r27 |
| 53 1 << 28 | // r28 |
| 54 1 << 29 | // r29 |
| 55 1 << 30 | // r20 |
| 56 1 << 31; // r31 |
| 57 |
| 58 |
| 59 const int kNumCalleeSaved = 18; |
| 60 |
| 61 // Number of registers for which space is reserved in safepoints. Must be a |
| 62 // multiple of 8. |
| 63 // TODO(regis): Only 8 registers may actually be sufficient. Revisit. |
| 64 const int kNumSafepointRegisters = 32; |
| 65 |
| 66 // Define the list of registers actually saved at safepoints. |
| 67 // Note that the number of saved registers may be smaller than the reserved |
| 68 // space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters. |
| 69 const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved; |
| 70 const int kNumSafepointSavedRegisters = kNumJSCallerSaved + kNumCalleeSaved; |
| 71 |
| 72 // The following constants describe the stack frame linkage area as |
| 73 // defined by the ABI. Note that kNumRequiredStackFrameSlots must |
| 74 // satisfy alignment requirements (rounding up if required). |
| 75 #if V8_TARGET_ARCH_PPC64 && V8_TARGET_LITTLE_ENDIAN |
| 76 // [0] back chain |
| 77 // [1] condition register save area |
| 78 // [2] link register save area |
| 79 // [3] TOC save area |
| 80 // [4] Parameter1 save area |
| 81 // ... |
| 82 // [11] Parameter8 save area |
| 83 // [12] Parameter9 slot (if necessary) |
| 84 // ... |
| 85 const int kNumRequiredStackFrameSlots = 12; |
| 86 const int kStackFrameLRSlot = 2; |
| 87 const int kStackFrameExtraParamSlot = 12; |
| 88 #elif V8_OS_AIX || V8_TARGET_ARCH_PPC64 |
| 89 // [0] back chain |
| 90 // [1] condition register save area |
| 91 // [2] link register save area |
| 92 // [3] reserved for compiler |
| 93 // [4] reserved by binder |
| 94 // [5] TOC save area |
| 95 // [6] Parameter1 save area |
| 96 // ... |
| 97 // [13] Parameter8 save area |
| 98 // [14] Parameter9 slot (if necessary) |
| 99 // ... |
| 100 #if V8_TARGET_ARCH_PPC64 |
| 101 const int kNumRequiredStackFrameSlots = 14; |
| 102 #else |
| 103 const int kNumRequiredStackFrameSlots = 16; |
| 104 #endif |
| 105 const int kStackFrameLRSlot = 2; |
| 106 const int kStackFrameExtraParamSlot = 14; |
| 107 #else |
| 108 // [0] back chain |
| 109 // [1] link register save area |
| 110 // [2] Parameter9 slot (if necessary) |
| 111 // ... |
| 112 const int kNumRequiredStackFrameSlots = 4; |
| 113 const int kStackFrameLRSlot = 1; |
| 114 const int kStackFrameExtraParamSlot = 2; |
| 115 #endif |
| 116 |
| 117 // ---------------------------------------------------- |
| 118 |
| 119 |
| 120 class EntryFrameConstants : public AllStatic { |
| 121 public: |
| 122 static const int kCallerFPOffset = |
| 123 -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); |
| 124 }; |
| 125 |
| 126 |
| 127 class ExitFrameConstants : public AllStatic { |
| 128 public: |
| 129 #if V8_OOL_CONSTANT_POOL |
| 130 static const int kFrameSize = 3 * kPointerSize; |
| 131 static const int kConstantPoolOffset = -3 * kPointerSize; |
| 132 #else |
| 133 static const int kFrameSize = 2 * kPointerSize; |
| 134 static const int kConstantPoolOffset = 0; // Not used. |
| 135 #endif |
| 136 static const int kCodeOffset = -2 * kPointerSize; |
| 137 static const int kSPOffset = -1 * kPointerSize; |
| 138 |
| 139 // The caller fields are below the frame pointer on the stack. |
| 140 static const int kCallerFPOffset = 0 * kPointerSize; |
| 141 // The calling JS function is below FP. |
| 142 static const int kCallerPCOffset = 1 * kPointerSize; |
| 143 |
| 144 // FP-relative displacement of the caller's SP. It points just |
| 145 // below the saved PC. |
| 146 static const int kCallerSPDisplacement = 2 * kPointerSize; |
| 147 }; |
| 148 |
| 149 |
| 150 class JavaScriptFrameConstants : public AllStatic { |
| 151 public: |
| 152 // FP-relative. |
| 153 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; |
| 154 static const int kLastParameterOffset = +2 * kPointerSize; |
| 155 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; |
| 156 |
| 157 // Caller SP-relative. |
| 158 static const int kParam0Offset = -2 * kPointerSize; |
| 159 static const int kReceiverOffset = -1 * kPointerSize; |
| 160 }; |
| 161 |
| 162 |
| 163 class ArgumentsAdaptorFrameConstants : public AllStatic { |
| 164 public: |
| 165 // FP-relative. |
| 166 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; |
| 167 |
| 168 static const int kFrameSize = |
| 169 StandardFrameConstants::kFixedFrameSize + kPointerSize; |
| 170 }; |
| 171 |
| 172 |
| 173 class ConstructFrameConstants : public AllStatic { |
| 174 public: |
| 175 // FP-relative. |
| 176 static const int kImplicitReceiverOffset = -6 * kPointerSize; |
| 177 static const int kConstructorOffset = -5 * kPointerSize; |
| 178 static const int kLengthOffset = -4 * kPointerSize; |
| 179 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; |
| 180 |
| 181 static const int kFrameSize = |
| 182 StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize; |
| 183 }; |
| 184 |
| 185 |
| 186 class InternalFrameConstants : public AllStatic { |
| 187 public: |
| 188 // FP-relative. |
| 189 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; |
| 190 }; |
| 191 |
| 192 |
| 193 inline Object* JavaScriptFrame::function_slot_object() const { |
| 194 const int offset = JavaScriptFrameConstants::kFunctionOffset; |
| 195 return Memory::Object_at(fp() + offset); |
| 196 } |
| 197 |
| 198 |
| 199 inline void StackHandler::SetFp(Address slot, Address fp) { |
| 200 Memory::Address_at(slot) = fp; |
| 201 } |
| 202 } |
| 203 } // namespace v8::internal |
| 204 |
| 205 #endif // V8_PPC_FRAMES_PPC_H_ |
OLD | NEW |