| OLD | NEW |
| (Empty) |
| 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 | |
| 4 // met: | |
| 5 // | |
| 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. | |
| 15 // | |
| 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. | |
| 27 | |
| 28 #ifndef V8_FRAMES_IA32_H_ | |
| 29 #define V8_FRAMES_IA32_H_ | |
| 30 | |
| 31 namespace v8 { namespace internal { | |
| 32 | |
| 33 | |
| 34 // Register lists | |
| 35 // Note that the bit values must match those used in actual instruction encoding | |
| 36 static const int kNumRegs = 8; | |
| 37 | |
| 38 | |
| 39 // Caller-saved registers | |
| 40 static const RegList kJSCallerSaved = | |
| 41 1 << 0 | // eax | |
| 42 1 << 1 | // ecx | |
| 43 1 << 2 | // edx | |
| 44 1 << 3 | // ebx - used as a caller-saved register in JavaScript code | |
| 45 1 << 7; // edi - callee function | |
| 46 | |
| 47 static const int kNumJSCallerSaved = 5; | |
| 48 | |
| 49 typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved]; | |
| 50 | |
| 51 // ---------------------------------------------------- | |
| 52 | |
| 53 | |
| 54 class StackHandlerConstants : public AllStatic { | |
| 55 public: | |
| 56 static const int kNextOffset = 0 * kPointerSize; | |
| 57 static const int kPPOffset = 1 * kPointerSize; | |
| 58 static const int kFPOffset = 2 * kPointerSize; | |
| 59 | |
| 60 // TODO(1233780): Get rid of the code slot in stack handlers. | |
| 61 static const int kCodeOffset = 3 * kPointerSize; | |
| 62 | |
| 63 static const int kStateOffset = 4 * kPointerSize; | |
| 64 static const int kPCOffset = 5 * kPointerSize; | |
| 65 | |
| 66 static const int kAddressDisplacement = -1 * kPointerSize; | |
| 67 static const int kSize = kPCOffset + kPointerSize; | |
| 68 }; | |
| 69 | |
| 70 | |
| 71 class EntryFrameConstants : public AllStatic { | |
| 72 public: | |
| 73 static const int kCallerFPOffset = -6 * kPointerSize; | |
| 74 | |
| 75 static const int kFunctionArgOffset = +3 * kPointerSize; | |
| 76 static const int kReceiverArgOffset = +4 * kPointerSize; | |
| 77 static const int kArgcOffset = +5 * kPointerSize; | |
| 78 static const int kArgvOffset = +6 * kPointerSize; | |
| 79 }; | |
| 80 | |
| 81 | |
| 82 class ExitFrameConstants : public AllStatic { | |
| 83 public: | |
| 84 static const int kDebugMarkOffset = -2 * kPointerSize; | |
| 85 static const int kSPOffset = -1 * kPointerSize; | |
| 86 | |
| 87 // Let the parameters pointer for exit frames point just below the | |
| 88 // frame structure on the stack (frame pointer and return address). | |
| 89 static const int kPPDisplacement = +2 * kPointerSize; | |
| 90 | |
| 91 static const int kCallerFPOffset = 0 * kPointerSize; | |
| 92 static const int kCallerPCOffset = +1 * kPointerSize; | |
| 93 }; | |
| 94 | |
| 95 | |
| 96 class StandardFrameConstants : public AllStatic { | |
| 97 public: | |
| 98 static const int kExpressionsOffset = -3 * kPointerSize; | |
| 99 static const int kMarkerOffset = -2 * kPointerSize; | |
| 100 static const int kContextOffset = -1 * kPointerSize; | |
| 101 static const int kCallerFPOffset = 0 * kPointerSize; | |
| 102 static const int kCallerPCOffset = +1 * kPointerSize; | |
| 103 static const int kCallerSPOffset = +2 * kPointerSize; | |
| 104 }; | |
| 105 | |
| 106 | |
| 107 class JavaScriptFrameConstants : public AllStatic { | |
| 108 public: | |
| 109 // FP-relative. | |
| 110 static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset; | |
| 111 static const int kSavedRegistersOffset = +2 * kPointerSize; | |
| 112 static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset; | |
| 113 | |
| 114 // CallerSP-relative (aka PP-relative) | |
| 115 static const int kParam0Offset = -2 * kPointerSize; | |
| 116 static const int kReceiverOffset = -1 * kPointerSize; | |
| 117 }; | |
| 118 | |
| 119 | |
| 120 class ArgumentsAdaptorFrameConstants : public AllStatic { | |
| 121 public: | |
| 122 static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset; | |
| 123 }; | |
| 124 | |
| 125 | |
| 126 class InternalFrameConstants : public AllStatic { | |
| 127 public: | |
| 128 static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset; | |
| 129 }; | |
| 130 | |
| 131 | |
| 132 inline Object* JavaScriptFrame::function_slot_object() const { | |
| 133 const int offset = JavaScriptFrameConstants::kFunctionOffset; | |
| 134 return Memory::Object_at(fp() + offset); | |
| 135 } | |
| 136 | |
| 137 | |
| 138 // ---------------------------------------------------- | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 // C Entry frames: | |
| 144 | |
| 145 // lower | Stack | | |
| 146 // addresses | ^ | | |
| 147 // | | | | |
| 148 // | | | |
| 149 // +-------------+ | |
| 150 // | entry_pc | | |
| 151 // +-------------+ <--+ entry_sp | |
| 152 // . | | |
| 153 // . | | |
| 154 // . | | |
| 155 // +-------------+ | | |
| 156 // -3 | entry_sp --+----+ | |
| 157 // e +-------------+ | |
| 158 // n -2 | C function | | |
| 159 // t +-------------+ | |
| 160 // r -1 | caller_pp | | |
| 161 // y +-------------+ <--- fp (frame pointer, ebp) | |
| 162 // 0 | caller_fp | | |
| 163 // f +-------------+ | |
| 164 // r 1 | caller_pc | | |
| 165 // a +-------------+ <--- caller_sp (stack pointer, esp) | |
| 166 // m 2 | | | |
| 167 // e | arguments | | |
| 168 // | | | |
| 169 // +- - - - - - -+ | |
| 170 // | argument0 | | |
| 171 // +=============+ | |
| 172 // | | | |
| 173 // | caller | | |
| 174 // higher | expressions | | |
| 175 // addresses | | | |
| 176 | |
| 177 | |
| 178 // Proper JS frames: | |
| 179 | |
| 180 // lower | Stack | | |
| 181 // addresses | ^ | | |
| 182 // | | | | |
| 183 // | | | |
| 184 // ----------- +=============+ <--- sp (stack pointer, esp) | |
| 185 // | function | | |
| 186 // +-------------+ | |
| 187 // | | | |
| 188 // | expressions | | |
| 189 // | | | |
| 190 // +-------------+ | |
| 191 // a | | | |
| 192 // c | locals | | |
| 193 // t | | | |
| 194 // i +- - - - - - -+ <--- | |
| 195 // v -4 | local0 | ^ | |
| 196 // a +-------------+ | | |
| 197 // t -3 | code | | | |
| 198 // i +-------------+ | | |
| 199 // o -2 | context | | kLocal0Offset | |
| 200 // n +-------------+ | | |
| 201 // -1 | caller_pp | v | |
| 202 // f +-------------+ <--- fp (frame pointer, ebp) | |
| 203 // r 0 | caller_fp | | |
| 204 // a +-------------+ | |
| 205 // m 1 | caller_pc | | |
| 206 // e +-------------+ <--- caller_sp (incl. parameters) | |
| 207 // 2 | | | |
| 208 // | parameters | | |
| 209 // | | | |
| 210 // +- - - - - - -+ <--- | |
| 211 // -2 | parameter0 | ^ | |
| 212 // +-------------+ | kParam0Offset | |
| 213 // -1 | receiver | v | |
| 214 // ----------- +=============+ <--- pp (parameter pointer, edi) | |
| 215 // 0 | function | | |
| 216 // +-------------+ | |
| 217 // | | | |
| 218 // | caller | | |
| 219 // higher | expressions | | |
| 220 // addresses | | | |
| 221 | |
| 222 | |
| 223 // JS entry frames: When calling from C to JS, we construct two extra | |
| 224 // frames: An entry frame (C) and a trampoline frame (JS). The | |
| 225 // following pictures shows the two frames: | |
| 226 | |
| 227 // lower | Stack | | |
| 228 // addresses | ^ | | |
| 229 // | | | | |
| 230 // | | | |
| 231 // ----------- +=============+ <--- sp (stack pointer, esp) | |
| 232 // | | | |
| 233 // | parameters | | |
| 234 // t | | | |
| 235 // r +- - - - - - -+ | |
| 236 // a | parameter0 | | |
| 237 // m +-------------+ | |
| 238 // p | receiver | | |
| 239 // o +-------------+ <--- | |
| 240 // l | function | ^ | |
| 241 // i +-------------+ | | |
| 242 // n -3 | code | | kLocal0Offset | |
| 243 // e +-------------+ | |
| 244 // -2 | NULL | context is always NULL | |
| 245 // +-------------+ | |
| 246 // f -1 | NULL | caller pp is always NULL for entry frames | |
| 247 // r +-------------+ <--- fp (frame pointer, ebp) | |
| 248 // a 0 | caller fp | | |
| 249 // m +-------------+ | |
| 250 // e 1 | caller pc | | |
| 251 // +-------------+ <--- caller_sp (incl. parameters) | |
| 252 // | 0 | | |
| 253 // ----------- +=============+ <--- pp (parameter pointer, edi) | |
| 254 // | 0 | | |
| 255 // +-------------+ <--- | |
| 256 // . ^ | |
| 257 // . | try-handler (HandlerOffsets::kSize) | |
| 258 // . v | |
| 259 // +-------------+ <--- | |
| 260 // -5 | next top pp | | |
| 261 // +-------------+ | |
| 262 // e -4 | next top fp | | |
| 263 // n +-------------+ <--- | |
| 264 // t -3 | ebx | ^ | |
| 265 // r +-------------+ | | |
| 266 // y -2 | esi | | callee-saved registers | |
| 267 // +-------------+ | | |
| 268 // -1 | edi | v | |
| 269 // f +-------------+ <--- fp | |
| 270 // r 0 | caller fp | | |
| 271 // a +-------------+ pp == NULL (parameter pointer) | |
| 272 // m 1 | caller pc | | |
| 273 // e +-------------+ <--- caller sp | |
| 274 // 2 | code entry | ^ | |
| 275 // +-------------+ | | |
| 276 // 3 | function | | | |
| 277 // +-------------+ | arguments passed from C code | |
| 278 // 4 | receiver | | | |
| 279 // +-------------+ | | |
| 280 // 5 | argc | | | |
| 281 // +-------------+ | | |
| 282 // 6 | argv | v | |
| 283 // +-------------+ <--- | |
| 284 // | | | |
| 285 // higher | | | |
| 286 // addresses | | | |
| 287 | |
| 288 | |
| 289 } } // namespace v8::internal | |
| 290 | |
| 291 #endif // V8_FRAMES_IA32_H_ | |
| OLD | NEW |