| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 SYNCED, | 51 SYNCED, |
| 52 NOT_SYNCED | 52 NOT_SYNCED |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // The default constructor creates an invalid frame element. | 55 // The default constructor creates an invalid frame element. |
| 56 FrameElement() { | 56 FrameElement() { |
| 57 type_ = TypeField::encode(INVALID) | SyncField::encode(NOT_SYNCED); | 57 type_ = TypeField::encode(INVALID) | SyncField::encode(NOT_SYNCED); |
| 58 data_.reg_ = no_reg; | 58 data_.reg_ = no_reg; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Factory function to construct an invalid frame element. |
| 62 static FrameElement InvalidElement() { |
| 63 FrameElement result; |
| 64 return result; |
| 65 } |
| 66 |
| 61 // Factory function to construct an in-memory frame element. | 67 // Factory function to construct an in-memory frame element. |
| 62 static FrameElement MemoryElement() { | 68 static FrameElement MemoryElement() { |
| 63 FrameElement result; | 69 FrameElement result; |
| 64 result.type_ = TypeField::encode(MEMORY) | SyncField::encode(SYNCED); | 70 result.type_ = TypeField::encode(MEMORY) | SyncField::encode(SYNCED); |
| 65 // In-memory elements have no useful data. | 71 // In-memory elements have no useful data. |
| 66 result.data_.reg_ = no_reg; | 72 result.data_.reg_ = no_reg; |
| 67 return result; | 73 return result; |
| 68 } | 74 } |
| 69 | 75 |
| 70 // Factory function to construct an in-register frame element. | 76 // Factory function to construct an in-register frame element. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 90 void set_sync() { | 96 void set_sync() { |
| 91 ASSERT(type() != MEMORY); | 97 ASSERT(type() != MEMORY); |
| 92 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(SYNCED); | 98 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(SYNCED); |
| 93 } | 99 } |
| 94 | 100 |
| 95 void clear_sync() { | 101 void clear_sync() { |
| 96 ASSERT(type() != MEMORY); | 102 ASSERT(type() != MEMORY); |
| 97 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(NOT_SYNCED); | 103 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(NOT_SYNCED); |
| 98 } | 104 } |
| 99 | 105 |
| 106 bool is_valid() const { return type() != INVALID; } |
| 100 bool is_memory() const { return type() == MEMORY; } | 107 bool is_memory() const { return type() == MEMORY; } |
| 101 bool is_register() const { return type() == REGISTER; } | 108 bool is_register() const { return type() == REGISTER; } |
| 102 bool is_constant() const { return type() == CONSTANT; } | 109 bool is_constant() const { return type() == CONSTANT; } |
| 103 | 110 |
| 104 Register reg() const { | 111 Register reg() const { |
| 105 ASSERT(type() == REGISTER); | 112 ASSERT(type() == REGISTER); |
| 106 return data_.reg_; | 113 return data_.reg_; |
| 107 } | 114 } |
| 108 | 115 |
| 109 Handle<Object> handle() const { | 116 Handle<Object> handle() const { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 void AllocateStackSlots(int count); | 242 void AllocateStackSlots(int count); |
| 236 | 243 |
| 237 // The current top of the expression stack as an assembly operand. | 244 // The current top of the expression stack as an assembly operand. |
| 238 Operand Top() const { return Operand(esp, 0); } | 245 Operand Top() const { return Operand(esp, 0); } |
| 239 | 246 |
| 240 // An element of the expression stack as an assembly operand. | 247 // An element of the expression stack as an assembly operand. |
| 241 Operand ElementAt(int index) const { | 248 Operand ElementAt(int index) const { |
| 242 return Operand(esp, index * kPointerSize); | 249 return Operand(esp, index * kPointerSize); |
| 243 } | 250 } |
| 244 | 251 |
| 252 // Random-access store to a frame-top relative frame element. The result |
| 253 // becomes owned by the frame and is invalidated. |
| 254 void SetElementAt(int index, Result* value); |
| 255 |
| 245 // A frame-allocated local as an assembly operand. | 256 // A frame-allocated local as an assembly operand. |
| 246 Operand LocalAt(int index) const { | 257 Operand LocalAt(int index) const { |
| 247 ASSERT(0 <= index); | 258 ASSERT(0 <= index); |
| 248 ASSERT(index < local_count_); | 259 ASSERT(index < local_count_); |
| 249 return Operand(ebp, kLocal0Offset - index * kPointerSize); | 260 return Operand(ebp, kLocal0Offset - index * kPointerSize); |
| 250 } | 261 } |
| 251 | 262 |
| 252 // Push a copy of the value of a local frame slot on top of the frame. | 263 // Push a copy of the value of a local frame slot on top of the frame. |
| 253 void LoadLocalAt(int index) { | 264 void LoadLocalAt(int index) { |
| 254 LoadFrameSlotAt(local0_index() + index); | 265 LoadFrameSlotAt(local0_index() + index); |
| 255 } | 266 } |
| 256 | 267 |
| 268 // Push the value of a local frame slot on top of the frame and invalidate |
| 269 // the local slot. The slot should be written to before trying to read |
| 270 // from it again. |
| 271 void TakeLocalAt(int index) { |
| 272 TakeFrameSlotAt(local0_index() + index); |
| 273 } |
| 274 |
| 257 // Store the top value on the virtual frame into a local frame slot. The | 275 // Store the top value on the virtual frame into a local frame slot. The |
| 258 // value is left in place on top of the frame. | 276 // value is left in place on top of the frame. |
| 259 void StoreToLocalAt(int index) { | 277 void StoreToLocalAt(int index) { |
| 260 StoreToFrameSlotAt(local0_index() + index); | 278 StoreToFrameSlotAt(local0_index() + index); |
| 261 } | 279 } |
| 262 | 280 |
| 263 // The function frame slot. | 281 // The function frame slot. |
| 264 Operand Function() const { return Operand(ebp, kFunctionOffset); } | 282 Operand Function() const { return Operand(ebp, kFunctionOffset); } |
| 265 | 283 |
| 266 // The context frame slot. | 284 // The context frame slot. |
| 267 Operand Context() const { return Operand(ebp, kContextOffset); } | 285 Operand Context() const { return Operand(ebp, kContextOffset); } |
| 268 | 286 |
| 269 // A parameter as an assembly operand. | 287 // A parameter as an assembly operand. |
| 270 Operand ParameterAt(int index) const { | 288 Operand ParameterAt(int index) const { |
| 271 ASSERT(-1 <= index); // -1 is the receiver. | 289 ASSERT(-1 <= index); // -1 is the receiver. |
| 272 ASSERT(index < parameter_count_); | 290 ASSERT(index < parameter_count_); |
| 273 return Operand(ebp, (1 + parameter_count_ - index) * kPointerSize); | 291 return Operand(ebp, (1 + parameter_count_ - index) * kPointerSize); |
| 274 } | 292 } |
| 275 | 293 |
| 276 // Push a copy of the value of a parameter frame slot on top of the frame. | 294 // Push a copy of the value of a parameter frame slot on top of the frame. |
| 277 void LoadParameterAt(int index) { | 295 void LoadParameterAt(int index) { |
| 278 LoadFrameSlotAt(param0_index() + index); | 296 LoadFrameSlotAt(param0_index() + index); |
| 279 } | 297 } |
| 280 | 298 |
| 299 // Push the value of a paramter frame slot on top of the frame and |
| 300 // invalidate the parameter slot. The slot should be written to before |
| 301 // trying to read from it again. |
| 302 void TakeParameterAt(int index) { |
| 303 TakeFrameSlotAt(param0_index() + index); |
| 304 } |
| 305 |
| 281 // Store the top value on the virtual frame into a parameter frame slot. | 306 // Store the top value on the virtual frame into a parameter frame slot. |
| 282 // The value is left in place on top of the frame. | 307 // The value is left in place on top of the frame. |
| 283 void StoreToParameterAt(int index) { | 308 void StoreToParameterAt(int index) { |
| 284 StoreToFrameSlotAt(param0_index() + index); | 309 StoreToFrameSlotAt(param0_index() + index); |
| 285 } | 310 } |
| 286 | 311 |
| 287 // The receiver frame slot. | 312 // The receiver frame slot. |
| 288 Operand Receiver() const { return ParameterAt(-1); } | 313 Operand Receiver() const { return ParameterAt(-1); } |
| 289 | 314 |
| 290 // Push a try-catch or try-finally handler on top of the virtual frame. | 315 // Push a try-catch or try-finally handler on top of the virtual frame. |
| 291 void PushTryHandler(HandlerType type); | 316 void PushTryHandler(HandlerType type); |
| 292 | 317 |
| 293 // Call a code stub, given the number of arguments it expects on (and | 318 // Call a code stub, given the number of arguments it expects on (and |
| 294 // removes from) the top of the physical frame. | 319 // removes from) the top of the physical frame. |
| 295 void CallStub(CodeStub* stub, int frame_arg_count); | 320 void CallStub(CodeStub* stub, int frame_arg_count); |
| 321 Result CallStub(CodeStub* stub, Result* arg, int frame_arg_count); |
| 296 Result CallStub(CodeStub* stub, | 322 Result CallStub(CodeStub* stub, |
| 297 Result* arg0, | 323 Result* arg0, |
| 298 Result* arg1, | 324 Result* arg1, |
| 299 int frame_arg_count); | 325 int frame_arg_count); |
| 300 | 326 |
| 301 // Call the runtime, given the number of arguments expected on (and | 327 // Call the runtime, given the number of arguments expected on (and |
| 302 // removed from) the top of the physical frame. | 328 // removed from) the top of the physical frame. |
| 303 void CallRuntime(Runtime::Function* f, int frame_arg_count); | 329 void CallRuntime(Runtime::Function* f, int frame_arg_count); |
| 304 void CallRuntime(Runtime::FunctionId id, int frame_arg_count); | 330 void CallRuntime(Runtime::FunctionId id, int frame_arg_count); |
| 305 | 331 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 void SyncRange(int begin, int end); | 467 void SyncRange(int begin, int end); |
| 442 | 468 |
| 443 // Sync a single element, assuming that its index is less than | 469 // Sync a single element, assuming that its index is less than |
| 444 // or equal to stack pointer + 1. | 470 // or equal to stack pointer + 1. |
| 445 void RawSyncElementAt(int index); | 471 void RawSyncElementAt(int index); |
| 446 | 472 |
| 447 // Push a copy of a frame slot (typically a local or parameter) on top of | 473 // Push a copy of a frame slot (typically a local or parameter) on top of |
| 448 // the frame. | 474 // the frame. |
| 449 void LoadFrameSlotAt(int index); | 475 void LoadFrameSlotAt(int index); |
| 450 | 476 |
| 477 // Push a the value of a frame slot (typically a local or parameter) on |
| 478 // top of the frame and invalidate the slot. |
| 479 void TakeFrameSlotAt(int index); |
| 480 |
| 451 // Store the value on top of the frame to a frame slot (typically a local | 481 // Store the value on top of the frame to a frame slot (typically a local |
| 452 // or parameter). | 482 // or parameter). |
| 453 void StoreToFrameSlotAt(int index); | 483 void StoreToFrameSlotAt(int index); |
| 454 | 484 |
| 455 // Spill the topmost elements of the frame to memory (eg, they are the | 485 // Spill the topmost elements of the frame to memory (eg, they are the |
| 456 // arguments to a call) and all registers. | 486 // arguments to a call) and all registers. |
| 457 void PrepareForCall(int count); | 487 void PrepareForCall(int count); |
| 458 | 488 |
| 459 // Move frame elements currently in registers or constants, that | 489 // Move frame elements currently in registers or constants, that |
| 460 // should be in memory in the expected frame, to memory. | 490 // should be in memory in the expected frame, to memory. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 474 // Called after all register-to-memory and register-to-register | 504 // Called after all register-to-memory and register-to-register |
| 475 // moves have been made. After this function returns, the frames | 505 // moves have been made. After this function returns, the frames |
| 476 // should be equal. | 506 // should be equal. |
| 477 void MergeMoveMemoryToRegisters(VirtualFrame *expected); | 507 void MergeMoveMemoryToRegisters(VirtualFrame *expected); |
| 478 }; | 508 }; |
| 479 | 509 |
| 480 | 510 |
| 481 } } // namespace v8::internal | 511 } } // namespace v8::internal |
| 482 | 512 |
| 483 #endif // V8_VIRTUAL_FRAME_IA32_H_ | 513 #endif // V8_VIRTUAL_FRAME_IA32_H_ |
| OLD | NEW |