| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Construct a virtual frame as a clone of an existing one. | 76 // Construct a virtual frame as a clone of an existing one. |
| 77 explicit VirtualFrame(VirtualFrame* original); | 77 explicit VirtualFrame(VirtualFrame* original); |
| 78 | 78 |
| 79 CodeGenerator* cgen() { return CodeGeneratorScope::Current(); } | 79 CodeGenerator* cgen() { return CodeGeneratorScope::Current(); } |
| 80 MacroAssembler* masm() { return cgen()->masm(); } | 80 MacroAssembler* masm() { return cgen()->masm(); } |
| 81 | 81 |
| 82 // Create a duplicate of an existing valid frame element. | 82 // Create a duplicate of an existing valid frame element. |
| 83 FrameElement CopyElementAt(int index); | 83 FrameElement CopyElementAt(int index); |
| 84 | 84 |
| 85 // The number of elements on the virtual frame. |
| 86 int element_count() { return elements_.length(); } |
| 87 |
| 85 // The height of the virtual expression stack. | 88 // The height of the virtual expression stack. |
| 86 int height() { | 89 int height() { |
| 87 return elements_.length() - expression_base_index(); | 90 return element_count() - expression_base_index(); |
| 88 } | 91 } |
| 89 | 92 |
| 90 int register_index(Register reg) { | 93 int register_index(Register reg) { |
| 91 return register_locations_[reg.code()]; | 94 return register_locations_[reg.code()]; |
| 92 } | 95 } |
| 93 | 96 |
| 94 bool is_used(int reg_code) { | 97 bool is_used(int reg_code) { |
| 95 return register_locations_[reg_code] != kIllegalIndex; | 98 return register_locations_[reg_code] != kIllegalIndex; |
| 96 } | 99 } |
| 97 | 100 |
| 98 bool is_used(Register reg) { | 101 bool is_used(Register reg) { |
| 99 return is_used(reg.code()); | 102 return is_used(reg.code()); |
| 100 } | 103 } |
| 101 | 104 |
| 102 // Add extra in-memory elements to the top of the frame to match an actual | 105 // Add extra in-memory elements to the top of the frame to match an actual |
| 103 // frame (eg, the frame after an exception handler is pushed). No code is | 106 // frame (eg, the frame after an exception handler is pushed). No code is |
| 104 // emitted. | 107 // emitted. |
| 105 void Adjust(int count); | 108 void Adjust(int count); |
| 106 | 109 |
| 107 // Forget elements from the top of the frame to match an actual frame (eg, | 110 // Forget elements from the top of the frame to match an actual frame (eg, |
| 108 // the frame after a runtime call). No code is emitted. | 111 // the frame after a runtime call). No code is emitted. |
| 109 void Forget(int count) { | 112 void Forget(int count) { |
| 110 ASSERT(count >= 0); | 113 ASSERT(count >= 0); |
| 111 ASSERT(stack_pointer_ == elements_.length() - 1); | 114 ASSERT(stack_pointer_ == element_count() - 1); |
| 112 stack_pointer_ -= count; | 115 stack_pointer_ -= count; |
| 113 ForgetElements(count); | 116 ForgetElements(count); |
| 114 } | 117 } |
| 115 | 118 |
| 116 // Forget count elements from the top of the frame without adjusting | 119 // Forget count elements from the top of the frame without adjusting |
| 117 // the stack pointer downward. This is used, for example, before | 120 // the stack pointer downward. This is used, for example, before |
| 118 // merging frames at break, continue, and return targets. | 121 // merging frames at break, continue, and return targets. |
| 119 void ForgetElements(int count); | 122 void ForgetElements(int count); |
| 120 | 123 |
| 121 // Spill all values from the frame to memory. | 124 // Spill all values from the frame to memory. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // becomes owned by the frame and is invalidated. | 200 // becomes owned by the frame and is invalidated. |
| 198 void SetElementAt(int index, Result* value); | 201 void SetElementAt(int index, Result* value); |
| 199 | 202 |
| 200 // Set a frame element to a constant. The index is frame-top relative. | 203 // Set a frame element to a constant. The index is frame-top relative. |
| 201 void SetElementAt(int index, Handle<Object> value) { | 204 void SetElementAt(int index, Handle<Object> value) { |
| 202 Result temp(value); | 205 Result temp(value); |
| 203 SetElementAt(index, &temp); | 206 SetElementAt(index, &temp); |
| 204 } | 207 } |
| 205 | 208 |
| 206 void PushElementAt(int index) { | 209 void PushElementAt(int index) { |
| 207 PushFrameSlotAt(elements_.length() - index - 1); | 210 PushFrameSlotAt(element_count() - index - 1); |
| 208 } | 211 } |
| 209 | 212 |
| 210 // A frame-allocated local as an assembly operand. | 213 // A frame-allocated local as an assembly operand. |
| 211 MemOperand LocalAt(int index) { | 214 MemOperand LocalAt(int index) { |
| 212 ASSERT(0 <= index); | 215 ASSERT(0 <= index); |
| 213 ASSERT(index < local_count()); | 216 ASSERT(index < local_count()); |
| 214 return MemOperand(fp, kLocal0Offset - index * kPointerSize); | 217 return MemOperand(fp, kLocal0Offset - index * kPointerSize); |
| 215 } | 218 } |
| 216 | 219 |
| 217 // Push a copy of the value of a local frame slot on top of the frame. | 220 // Push a copy of the value of a local frame slot on top of the frame. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 331 |
| 329 // Drop a number of elements from the top of the expression stack. May | 332 // Drop a number of elements from the top of the expression stack. May |
| 330 // emit code to affect the physical frame. Does not clobber any registers | 333 // emit code to affect the physical frame. Does not clobber any registers |
| 331 // excepting possibly the stack pointer. | 334 // excepting possibly the stack pointer. |
| 332 void Drop(int count); | 335 void Drop(int count); |
| 333 | 336 |
| 334 // Drop one element. | 337 // Drop one element. |
| 335 void Drop() { Drop(1); } | 338 void Drop() { Drop(1); } |
| 336 | 339 |
| 337 // Duplicate the top element of the frame. | 340 // Duplicate the top element of the frame. |
| 338 void Dup() { PushFrameSlotAt(elements_.length() - 1); } | 341 void Dup() { PushFrameSlotAt(element_count() - 1); } |
| 339 | 342 |
| 340 // Pop an element from the top of the expression stack. Returns a | 343 // Pop an element from the top of the expression stack. Returns a |
| 341 // Result, which may be a constant or a register. | 344 // Result, which may be a constant or a register. |
| 342 Result Pop(); | 345 Result Pop(); |
| 343 | 346 |
| 344 // Pop and save an element from the top of the expression stack and | 347 // Pop and save an element from the top of the expression stack and |
| 345 // emit a corresponding pop instruction. | 348 // emit a corresponding pop instruction. |
| 346 void EmitPop(Register reg); | 349 void EmitPop(Register reg); |
| 347 | 350 |
| 348 // Push an element on top of the expression stack and emit a | 351 // Push an element on top of the expression stack and emit a |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 // The index of the first local. Between the frame pointer and the | 415 // The index of the first local. Between the frame pointer and the |
| 413 // locals lies the return address. | 416 // locals lies the return address. |
| 414 int local0_index() { return frame_pointer() + 2; } | 417 int local0_index() { return frame_pointer() + 2; } |
| 415 | 418 |
| 416 // The index of the base of the expression stack. | 419 // The index of the base of the expression stack. |
| 417 int expression_base_index() { return local0_index() + local_count(); } | 420 int expression_base_index() { return local0_index() + local_count(); } |
| 418 | 421 |
| 419 // Convert a frame index into a frame pointer relative offset into the | 422 // Convert a frame index into a frame pointer relative offset into the |
| 420 // actual stack. | 423 // actual stack. |
| 421 int fp_relative(int index) { | 424 int fp_relative(int index) { |
| 422 ASSERT(index < elements_.length()); | 425 ASSERT(index < element_count()); |
| 423 ASSERT(frame_pointer() < elements_.length()); // FP is on the frame. | 426 ASSERT(frame_pointer() < element_count()); // FP is on the frame. |
| 424 return (frame_pointer() - index) * kPointerSize; | 427 return (frame_pointer() - index) * kPointerSize; |
| 425 } | 428 } |
| 426 | 429 |
| 427 // Record an occurrence of a register in the virtual frame. This has the | 430 // Record an occurrence of a register in the virtual frame. This has the |
| 428 // effect of incrementing the register's external reference count and | 431 // effect of incrementing the register's external reference count and |
| 429 // of updating the index of the register's location in the frame. | 432 // of updating the index of the register's location in the frame. |
| 430 void Use(Register reg, int index) { | 433 void Use(Register reg, int index) { |
| 431 ASSERT(!is_used(reg)); | 434 ASSERT(!is_used(reg)); |
| 432 register_locations_[reg.code()] = index; | 435 register_locations_[reg.code()] = index; |
| 433 cgen()->allocator()->Use(reg); | 436 cgen()->allocator()->Use(reg); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 519 |
| 517 bool Equals(VirtualFrame* other); | 520 bool Equals(VirtualFrame* other); |
| 518 | 521 |
| 519 friend class JumpTarget; | 522 friend class JumpTarget; |
| 520 }; | 523 }; |
| 521 | 524 |
| 522 | 525 |
| 523 } } // namespace v8::internal | 526 } } // namespace v8::internal |
| 524 | 527 |
| 525 #endif // V8_ARM_VIRTUAL_FRAME_ARM_H_ | 528 #endif // V8_ARM_VIRTUAL_FRAME_ARM_H_ |
| OLD | NEW |