| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 // On entry to a function, the virtual frame already contains the | 43 // On entry to a function, the virtual frame already contains the |
| 44 // receiver and the parameters. All initial frame elements are in | 44 // receiver and the parameters. All initial frame elements are in |
| 45 // memory. | 45 // memory. |
| 46 VirtualFrame::VirtualFrame() | 46 VirtualFrame::VirtualFrame() |
| 47 : elements_(parameter_count() + local_count() + kPreallocatedElements), | 47 : elements_(parameter_count() + local_count() + kPreallocatedElements), |
| 48 stack_pointer_(parameter_count()) { // 0-based index of TOS. | 48 stack_pointer_(parameter_count()) { // 0-based index of TOS. |
| 49 for (int i = 0; i <= stack_pointer_; i++) { | 49 for (int i = 0; i <= stack_pointer_; i++) { |
| 50 elements_.Add(FrameElement::MemoryElement()); | 50 elements_.Add(FrameElement::MemoryElement()); |
| 51 } | 51 } |
| 52 for (int i = 0; i < kNumRegisters; i++) { | 52 for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) { |
| 53 register_locations_[i] = kIllegalIndex; | 53 register_locations_[i] = kIllegalIndex; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 void VirtualFrame::SyncElementBelowStackPointer(int index) { | 58 void VirtualFrame::SyncElementBelowStackPointer(int index) { |
| 59 UNREACHABLE(); | 59 UNREACHABLE(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 89 __ sub(sp, sp, Operand(difference * kPointerSize)); | 89 __ sub(sp, sp, Operand(difference * kPointerSize)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 MergeMoveRegistersToMemory(expected); | 92 MergeMoveRegistersToMemory(expected); |
| 93 MergeMoveRegistersToRegisters(expected); | 93 MergeMoveRegistersToRegisters(expected); |
| 94 MergeMoveMemoryToRegisters(expected); | 94 MergeMoveMemoryToRegisters(expected); |
| 95 | 95 |
| 96 // Fix any sync bit problems from the bottom-up, stopping when we | 96 // Fix any sync bit problems from the bottom-up, stopping when we |
| 97 // hit the stack pointer or the top of the frame if the stack | 97 // hit the stack pointer or the top of the frame if the stack |
| 98 // pointer is floating above the frame. | 98 // pointer is floating above the frame. |
| 99 int limit = Min(static_cast<int>(stack_pointer_), elements_.length() - 1); | 99 int limit = Min(static_cast<int>(stack_pointer_), element_count() - 1); |
| 100 for (int i = 0; i <= limit; i++) { | 100 for (int i = 0; i <= limit; i++) { |
| 101 FrameElement source = elements_[i]; | 101 FrameElement source = elements_[i]; |
| 102 FrameElement target = expected->elements_[i]; | 102 FrameElement target = expected->elements_[i]; |
| 103 if (source.is_synced() && !target.is_synced()) { | 103 if (source.is_synced() && !target.is_synced()) { |
| 104 elements_[i].clear_sync(); | 104 elements_[i].clear_sync(); |
| 105 } else if (!source.is_synced() && target.is_synced()) { | 105 } else if (!source.is_synced() && target.is_synced()) { |
| 106 SyncElementAt(i); | 106 SyncElementAt(i); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 121 | 121 |
| 122 void VirtualFrame::MergeMoveRegistersToMemory(VirtualFrame* expected) { | 122 void VirtualFrame::MergeMoveRegistersToMemory(VirtualFrame* expected) { |
| 123 ASSERT(stack_pointer_ >= expected->stack_pointer_); | 123 ASSERT(stack_pointer_ >= expected->stack_pointer_); |
| 124 | 124 |
| 125 // Move registers, constants, and copies to memory. Perform moves | 125 // Move registers, constants, and copies to memory. Perform moves |
| 126 // from the top downward in the frame in order to leave the backing | 126 // from the top downward in the frame in order to leave the backing |
| 127 // stores of copies in registers. | 127 // stores of copies in registers. |
| 128 // On ARM, all elements are in memory. | 128 // On ARM, all elements are in memory. |
| 129 | 129 |
| 130 #ifdef DEBUG | 130 #ifdef DEBUG |
| 131 int start = Min(static_cast<int>(stack_pointer_), elements_.length() - 1); | 131 int start = Min(static_cast<int>(stack_pointer_), element_count() - 1); |
| 132 for (int i = start; i >= 0; i--) { | 132 for (int i = start; i >= 0; i--) { |
| 133 ASSERT(elements_[i].is_memory()); | 133 ASSERT(elements_[i].is_memory()); |
| 134 ASSERT(expected->elements_[i].is_memory()); | 134 ASSERT(expected->elements_[i].is_memory()); |
| 135 } | 135 } |
| 136 #endif | 136 #endif |
| 137 } | 137 } |
| 138 | 138 |
| 139 | 139 |
| 140 void VirtualFrame::MergeMoveRegistersToRegisters(VirtualFrame* expected) { | 140 void VirtualFrame::MergeMoveRegistersToRegisters(VirtualFrame* expected) { |
| 141 } | 141 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 } | 386 } |
| 387 PrepareForCall(spilled_args, dropped_args); | 387 PrepareForCall(spilled_args, dropped_args); |
| 388 arg0->Unuse(); | 388 arg0->Unuse(); |
| 389 arg1->Unuse(); | 389 arg1->Unuse(); |
| 390 return RawCallCodeObject(code, rmode); | 390 return RawCallCodeObject(code, rmode); |
| 391 } | 391 } |
| 392 | 392 |
| 393 | 393 |
| 394 void VirtualFrame::Drop(int count) { | 394 void VirtualFrame::Drop(int count) { |
| 395 ASSERT(height() >= count); | 395 ASSERT(height() >= count); |
| 396 int num_virtual_elements = (elements_.length() - 1) - stack_pointer_; | 396 int num_virtual_elements = (element_count() - 1) - stack_pointer_; |
| 397 | 397 |
| 398 // Emit code to lower the stack pointer if necessary. | 398 // Emit code to lower the stack pointer if necessary. |
| 399 if (num_virtual_elements < count) { | 399 if (num_virtual_elements < count) { |
| 400 int num_dropped = count - num_virtual_elements; | 400 int num_dropped = count - num_virtual_elements; |
| 401 stack_pointer_ -= num_dropped; | 401 stack_pointer_ -= num_dropped; |
| 402 __ add(sp, sp, Operand(num_dropped * kPointerSize)); | 402 __ add(sp, sp, Operand(num_dropped * kPointerSize)); |
| 403 } | 403 } |
| 404 | 404 |
| 405 // Discard elements from the virtual frame and free any registers. | 405 // Discard elements from the virtual frame and free any registers. |
| 406 for (int i = 0; i < count; i++) { | 406 for (int i = 0; i < count; i++) { |
| 407 FrameElement dropped = elements_.RemoveLast(); | 407 FrameElement dropped = elements_.RemoveLast(); |
| 408 if (dropped.is_register()) { | 408 if (dropped.is_register()) { |
| 409 Unuse(dropped.reg()); | 409 Unuse(dropped.reg()); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 | 413 |
| 414 | 414 |
| 415 Result VirtualFrame::Pop() { | 415 Result VirtualFrame::Pop() { |
| 416 UNIMPLEMENTED(); | 416 UNIMPLEMENTED(); |
| 417 return Result(); | 417 return Result(); |
| 418 } | 418 } |
| 419 | 419 |
| 420 | 420 |
| 421 void VirtualFrame::EmitPop(Register reg) { | 421 void VirtualFrame::EmitPop(Register reg) { |
| 422 ASSERT(stack_pointer_ == elements_.length() - 1); | 422 ASSERT(stack_pointer_ == element_count() - 1); |
| 423 stack_pointer_--; | 423 stack_pointer_--; |
| 424 elements_.RemoveLast(); | 424 elements_.RemoveLast(); |
| 425 __ pop(reg); | 425 __ pop(reg); |
| 426 } | 426 } |
| 427 | 427 |
| 428 | 428 |
| 429 void VirtualFrame::EmitPush(Register reg) { | 429 void VirtualFrame::EmitPush(Register reg) { |
| 430 ASSERT(stack_pointer_ == elements_.length() - 1); | 430 ASSERT(stack_pointer_ == element_count() - 1); |
| 431 elements_.Add(FrameElement::MemoryElement()); | 431 elements_.Add(FrameElement::MemoryElement()); |
| 432 stack_pointer_++; | 432 stack_pointer_++; |
| 433 __ push(reg); | 433 __ push(reg); |
| 434 } | 434 } |
| 435 | 435 |
| 436 | 436 |
| 437 #undef __ | 437 #undef __ |
| 438 | 438 |
| 439 } } // namespace v8::internal | 439 } } // namespace v8::internal |
| OLD | NEW |