Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 12 matching lines...) Expand all Loading... | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_X64_VIRTUAL_FRAME_X64_H_ | 28 #ifndef V8_X64_VIRTUAL_FRAME_X64_H_ |
| 29 #define V8_X64_VIRTUAL_FRAME_X64_H_ | 29 #define V8_X64_VIRTUAL_FRAME_X64_H_ |
| 30 | 30 |
| 31 #include "type-info.h" | 31 #include "type-info.h" |
| 32 #include "register-allocator.h" | 32 #include "register-allocator.h" |
| 33 #include "scopes.h" | 33 #include "scopes.h" |
|
Søren Thygesen Gjesse
2010/05/06 07:48:11
Sort includes.
| |
| 34 #include "codegen.h" | |
| 34 | 35 |
| 35 namespace v8 { | 36 namespace v8 { |
| 36 namespace internal { | 37 namespace internal { |
| 37 | 38 |
| 38 // ------------------------------------------------------------------------- | 39 // ------------------------------------------------------------------------- |
| 39 // Virtual frames | 40 // Virtual frames |
| 40 // | 41 // |
| 41 // The virtual frame is an abstraction of the physical stack frame. It | 42 // The virtual frame is an abstraction of the physical stack frame. It |
| 42 // encapsulates the parameters, frame-allocated locals, and the expression | 43 // encapsulates the parameters, frame-allocated locals, and the expression |
| 43 // stack. It supports push/pop operations on the expression stack, as well | 44 // stack. It supports push/pop operations on the expression stack, as well |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // The height of the virtual expression stack. | 92 // The height of the virtual expression stack. |
| 92 int height() { | 93 int height() { |
| 93 return element_count() - expression_base_index(); | 94 return element_count() - expression_base_index(); |
| 94 } | 95 } |
| 95 | 96 |
| 96 int register_location(int num) { | 97 int register_location(int num) { |
| 97 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters); | 98 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters); |
| 98 return register_locations_[num]; | 99 return register_locations_[num]; |
| 99 } | 100 } |
| 100 | 101 |
| 101 int register_location(Register reg) { | 102 inline int register_location(Register reg); |
| 102 return register_locations_[RegisterAllocator::ToNumber(reg)]; | |
| 103 } | |
| 104 | 103 |
| 105 void set_register_location(Register reg, int index) { | 104 inline void set_register_location(Register reg, int index); |
| 106 register_locations_[RegisterAllocator::ToNumber(reg)] = index; | |
| 107 } | |
| 108 | 105 |
| 109 bool is_used(int num) { | 106 bool is_used(int num) { |
| 110 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters); | 107 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters); |
| 111 return register_locations_[num] != kIllegalIndex; | 108 return register_locations_[num] != kIllegalIndex; |
| 112 } | 109 } |
| 113 | 110 |
| 114 bool is_used(Register reg) { | 111 inline bool is_used(Register reg); |
| 115 return register_locations_[RegisterAllocator::ToNumber(reg)] | |
| 116 != kIllegalIndex; | |
| 117 } | |
| 118 | 112 |
| 119 // Add extra in-memory elements to the top of the frame to match an actual | 113 // Add extra in-memory elements to the top of the frame to match an actual |
| 120 // frame (eg, the frame after an exception handler is pushed). No code is | 114 // frame (eg, the frame after an exception handler is pushed). No code is |
| 121 // emitted. | 115 // emitted. |
| 122 void Adjust(int count); | 116 void Adjust(int count); |
| 123 | 117 |
| 124 // Forget count elements from the top of the frame all in-memory | 118 // Forget count elements from the top of the frame all in-memory |
| 125 // (including synced) and adjust the stack pointer downward, to | 119 // (including synced) and adjust the stack pointer downward, to |
| 126 // match an external frame effect (examples include a call removing | 120 // match an external frame effect (examples include a call removing |
| 127 // its arguments, and exiting a try/catch removing an exception | 121 // its arguments, and exiting a try/catch removing an exception |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 // An element of the expression stack as an assembly operand. | 205 // An element of the expression stack as an assembly operand. |
| 212 Operand ElementAt(int index) const { | 206 Operand ElementAt(int index) const { |
| 213 return Operand(rsp, index * kPointerSize); | 207 return Operand(rsp, index * kPointerSize); |
| 214 } | 208 } |
| 215 | 209 |
| 216 // Random-access store to a frame-top relative frame element. The result | 210 // Random-access store to a frame-top relative frame element. The result |
| 217 // becomes owned by the frame and is invalidated. | 211 // becomes owned by the frame and is invalidated. |
| 218 void SetElementAt(int index, Result* value); | 212 void SetElementAt(int index, Result* value); |
| 219 | 213 |
| 220 // Set a frame element to a constant. The index is frame-top relative. | 214 // Set a frame element to a constant. The index is frame-top relative. |
| 221 void SetElementAt(int index, Handle<Object> value) { | 215 inline void SetElementAt(int index, Handle<Object> value); |
| 222 Result temp(value); | |
| 223 SetElementAt(index, &temp); | |
| 224 } | |
| 225 | 216 |
| 226 void PushElementAt(int index) { | 217 void PushElementAt(int index) { |
| 227 PushFrameSlotAt(element_count() - index - 1); | 218 PushFrameSlotAt(element_count() - index - 1); |
| 228 } | 219 } |
| 229 | 220 |
| 230 void StoreToElementAt(int index) { | 221 void StoreToElementAt(int index) { |
| 231 StoreToFrameSlotAt(element_count() - index - 1); | 222 StoreToFrameSlotAt(element_count() - index - 1); |
| 232 } | 223 } |
| 233 | 224 |
| 234 // A frame-allocated local as an assembly operand. | 225 // A frame-allocated local as an assembly operand. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 } | 286 } |
| 296 | 287 |
| 297 // The receiver frame slot. | 288 // The receiver frame slot. |
| 298 Operand Receiver() { return ParameterAt(-1); } | 289 Operand Receiver() { return ParameterAt(-1); } |
| 299 | 290 |
| 300 // Push a try-catch or try-finally handler on top of the virtual frame. | 291 // Push a try-catch or try-finally handler on top of the virtual frame. |
| 301 void PushTryHandler(HandlerType type); | 292 void PushTryHandler(HandlerType type); |
| 302 | 293 |
| 303 // Call stub given the number of arguments it expects on (and | 294 // Call stub given the number of arguments it expects on (and |
| 304 // removes from) the stack. | 295 // removes from) the stack. |
| 305 Result CallStub(CodeStub* stub, int arg_count) { | 296 inline Result CallStub(CodeStub* stub, int arg_count); |
| 306 PrepareForCall(arg_count, arg_count); | |
| 307 return RawCallStub(stub); | |
| 308 } | |
| 309 | 297 |
| 310 // Call stub that takes a single argument passed in eax. The | 298 // Call stub that takes a single argument passed in eax. The |
| 311 // argument is given as a result which does not have to be eax or | 299 // argument is given as a result which does not have to be eax or |
| 312 // even a register. The argument is consumed by the call. | 300 // even a register. The argument is consumed by the call. |
| 313 Result CallStub(CodeStub* stub, Result* arg); | 301 Result CallStub(CodeStub* stub, Result* arg); |
| 314 | 302 |
| 315 // Call stub that takes a pair of arguments passed in edx (arg0, rdx) and | 303 // Call stub that takes a pair of arguments passed in edx (arg0, rdx) and |
| 316 // eax (arg1, rax). The arguments are given as results which do not have | 304 // eax (arg1, rax). The arguments are given as results which do not have |
| 317 // to be in the proper registers or even in registers. The | 305 // to be in the proper registers or even in registers. The |
| 318 // arguments are consumed by the call. | 306 // arguments are consumed by the call. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 | 427 |
| 440 // The index of the element that is at the processor's stack pointer | 428 // The index of the element that is at the processor's stack pointer |
| 441 // (the esp register). | 429 // (the esp register). |
| 442 int stack_pointer_; | 430 int stack_pointer_; |
| 443 | 431 |
| 444 // The index of the register frame element using each register, or | 432 // The index of the register frame element using each register, or |
| 445 // kIllegalIndex if a register is not on the frame. | 433 // kIllegalIndex if a register is not on the frame. |
| 446 int register_locations_[RegisterAllocator::kNumRegisters]; | 434 int register_locations_[RegisterAllocator::kNumRegisters]; |
| 447 | 435 |
| 448 // The number of frame-allocated locals and parameters respectively. | 436 // The number of frame-allocated locals and parameters respectively. |
| 449 int parameter_count() { return cgen()->scope()->num_parameters(); } | 437 inline int parameter_count(); |
| 450 int local_count() { return cgen()->scope()->num_stack_slots(); } | 438 inline int local_count(); |
| 451 | 439 |
| 452 // The index of the element that is at the processor's frame pointer | 440 // The index of the element that is at the processor's frame pointer |
| 453 // (the ebp register). The parameters, receiver, and return address | 441 // (the ebp register). The parameters, receiver, and return address |
| 454 // are below the frame pointer. | 442 // are below the frame pointer. |
| 455 int frame_pointer() { return parameter_count() + 2; } | 443 int frame_pointer() { return parameter_count() + 2; } |
| 456 | 444 |
| 457 // The index of the first parameter. The receiver lies below the first | 445 // The index of the first parameter. The receiver lies below the first |
| 458 // parameter. | 446 // parameter. |
| 459 int param0_index() { return 1; } | 447 int param0_index() { return 1; } |
| 460 | 448 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 | 560 |
| 573 // Classes that need raw access to the elements_ array. | 561 // Classes that need raw access to the elements_ array. |
| 574 friend class DeferredCode; | 562 friend class DeferredCode; |
| 575 friend class JumpTarget; | 563 friend class JumpTarget; |
| 576 }; | 564 }; |
| 577 | 565 |
| 578 | 566 |
| 579 } } // namespace v8::internal | 567 } } // namespace v8::internal |
| 580 | 568 |
| 581 #endif // V8_X64_VIRTUAL_FRAME_X64_H_ | 569 #endif // V8_X64_VIRTUAL_FRAME_X64_H_ |
| OLD | NEW |