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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (stack_pointer_ < expected->stack_pointer_) { | 164 if (stack_pointer_ < expected->stack_pointer_) { |
165 int difference = expected->stack_pointer_ - stack_pointer_; | 165 int difference = expected->stack_pointer_ - stack_pointer_; |
166 stack_pointer_ = expected->stack_pointer_; | 166 stack_pointer_ = expected->stack_pointer_; |
167 __ sub(Operand(esp), Immediate(difference * kPointerSize)); | 167 __ sub(Operand(esp), Immediate(difference * kPointerSize)); |
168 } | 168 } |
169 | 169 |
170 MergeMoveRegistersToMemory(expected); | 170 MergeMoveRegistersToMemory(expected); |
171 MergeMoveRegistersToRegisters(expected); | 171 MergeMoveRegistersToRegisters(expected); |
172 MergeMoveMemoryToRegisters(expected); | 172 MergeMoveMemoryToRegisters(expected); |
173 | 173 |
174 // Fix any sync bit problems from the bottom-up, stopping when we | 174 // Fix any sync flag problems from the bottom-up and make the copied |
175 // hit the stack pointer or the top of the frame if the stack | 175 // flags exact. This assumes that the backing store of copies is |
176 // pointer is floating above the frame. | 176 // always lower in the frame. |
177 int limit = Min(stack_pointer_, elements_.length() - 1); | 177 for (int i = 0; i < elements_.length(); i++) { |
178 for (int i = 0; i <= limit; i++) { | |
179 FrameElement source = elements_[i]; | 178 FrameElement source = elements_[i]; |
180 FrameElement target = expected->elements_[i]; | 179 FrameElement target = expected->elements_[i]; |
181 if (source.is_synced() && !target.is_synced()) { | 180 if (source.is_synced() && !target.is_synced()) { |
182 elements_[i].clear_sync(); | 181 elements_[i].clear_sync(); |
183 } else if (!source.is_synced() && target.is_synced()) { | 182 } else if (!source.is_synced() && target.is_synced()) { |
184 SyncElementAt(i); | 183 SyncElementAt(i); |
185 } | 184 } |
| 185 elements_[i].clear_copied(); |
| 186 if (elements_[i].is_copy()) { |
| 187 elements_[elements_[i].index()].set_copied(); |
| 188 } |
186 } | 189 } |
187 | 190 |
188 // Adjust the stack point downard if necessary. | 191 // Adjust the stack point downard if necessary. |
189 if (stack_pointer_ > expected->stack_pointer_) { | 192 if (stack_pointer_ > expected->stack_pointer_) { |
190 int difference = stack_pointer_ - expected->stack_pointer_; | 193 int difference = stack_pointer_ - expected->stack_pointer_; |
191 stack_pointer_ = expected->stack_pointer_; | 194 stack_pointer_ = expected->stack_pointer_; |
192 __ add(Operand(esp), Immediate(difference * kPointerSize)); | 195 __ add(Operand(esp), Immediate(difference * kPointerSize)); |
193 } | 196 } |
194 | 197 |
195 // At this point, the frames should be identical. | 198 // At this point, the frames should be identical. |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 copy.clear_sync(); | 546 copy.clear_sync(); |
544 } | 547 } |
545 elements_[j] = copy; | 548 elements_[j] = copy; |
546 } | 549 } |
547 } | 550 } |
548 | 551 |
549 copy.clear_sync(); | 552 copy.clear_sync(); |
550 return copy; | 553 return copy; |
551 } | 554 } |
552 | 555 |
| 556 elements_[index].clear_copied(); |
553 return FrameElement::InvalidElement(); | 557 return FrameElement::InvalidElement(); |
554 } | 558 } |
555 | 559 |
556 | 560 |
557 void VirtualFrame::TakeFrameSlotAt(int index) { | 561 void VirtualFrame::TakeFrameSlotAt(int index) { |
558 ASSERT(index >= 0); | 562 ASSERT(index >= 0); |
559 ASSERT(index <= elements_.length()); | 563 ASSERT(index <= elements_.length()); |
560 FrameElement original = elements_[index]; | 564 FrameElement original = elements_[index]; |
561 | 565 |
562 switch (original.type()) { | 566 switch (original.type()) { |
563 case FrameElement::INVALID: | 567 case FrameElement::INVALID: |
564 UNREACHABLE(); | 568 UNREACHABLE(); |
565 break; | 569 break; |
566 | 570 |
567 case FrameElement::MEMORY: { | 571 case FrameElement::MEMORY: { |
568 // Allocate the element to a register. If it is not copied, | 572 // Allocate the element to a register. If it is not copied, |
569 // push that register on top of the frame. If it is copied, | 573 // push that register on top of the frame. If it is copied, |
570 // make the first copy the backing store and push a fresh copy | 574 // make the first copy the backing store and push a fresh copy |
571 // on top of the frame. | 575 // on top of the frame. |
572 FrameElement copy = AdjustCopies(index); | 576 FrameElement copy = original.is_copied() |
| 577 ? AdjustCopies(index) |
| 578 : FrameElement::InvalidElement(); |
573 if (copy.is_valid()) { | 579 if (copy.is_valid()) { |
574 // The original element was a copy. Push the copy of the new | 580 // The original element was a copy. Push the copy of the new |
575 // backing store. | 581 // backing store. |
576 elements_.Add(copy); | 582 elements_.Add(copy); |
577 } else { | 583 } else { |
578 // The element was not a copy. Move it to a register and push | 584 // The element was not a copy. Move it to a register and push |
579 // that. | 585 // that. |
580 Result fresh = cgen_->allocator()->Allocate(); | 586 Result fresh = cgen_->allocator()->Allocate(); |
581 ASSERT(fresh.is_valid()); | 587 ASSERT(fresh.is_valid()); |
582 FrameElement new_element = | 588 FrameElement new_element = |
583 FrameElement::RegisterElement(fresh.reg(), | 589 FrameElement::RegisterElement(fresh.reg(), |
584 FrameElement::NOT_SYNCED); | 590 FrameElement::NOT_SYNCED); |
585 Use(fresh.reg()); | 591 Use(fresh.reg()); |
586 elements_.Add(new_element); | 592 elements_.Add(new_element); |
587 __ mov(fresh.reg(), Operand(ebp, fp_relative(index))); | 593 __ mov(fresh.reg(), Operand(ebp, fp_relative(index))); |
588 } | 594 } |
589 break; | 595 break; |
590 } | 596 } |
591 | 597 |
592 case FrameElement::REGISTER: { | 598 case FrameElement::REGISTER: { |
593 // If the element is not copied, push it on top of the frame. | 599 // If the element is not copied, push it on top of the frame. |
594 // If it is copied, make the first copy be the new backing store | 600 // If it is copied, make the first copy be the new backing store |
595 // and push a fresh copy on top of the frame. | 601 // and push a fresh copy on top of the frame. |
596 FrameElement copy = AdjustCopies(index); | 602 FrameElement copy = original.is_copied() |
| 603 ? AdjustCopies(index) |
| 604 : FrameElement::InvalidElement(); |
597 if (copy.is_valid()) { | 605 if (copy.is_valid()) { |
598 // The original element was a copy. Push the copy of the new | 606 // The original element was a copy. Push the copy of the new |
599 // backing store. | 607 // backing store. |
600 elements_.Add(copy); | 608 elements_.Add(copy); |
601 // This is the only case where we have to unuse the original | 609 // This is the only case where we have to unuse the original |
602 // register. The original is still counted and so is the new | 610 // register. The original is still counted and so is the new |
603 // backing store of the copies. | 611 // backing store of the copies. |
604 Unuse(original.reg()); | 612 Unuse(original.reg()); |
605 } else { | 613 } else { |
606 // The element was not a copy. Push it. | 614 // The element was not a copy. Push it. |
(...skipping 20 matching lines...) Expand all Loading... |
627 void VirtualFrame::StoreToFrameSlotAt(int index) { | 635 void VirtualFrame::StoreToFrameSlotAt(int index) { |
628 // Store the value on top of the frame to the virtual frame slot at | 636 // Store the value on top of the frame to the virtual frame slot at |
629 // a given index. The value on top of the frame is left in place. | 637 // a given index. The value on top of the frame is left in place. |
630 // This is a duplicating operation, so it can create copies. | 638 // This is a duplicating operation, so it can create copies. |
631 ASSERT(index >= 0); | 639 ASSERT(index >= 0); |
632 ASSERT(index < elements_.length()); | 640 ASSERT(index < elements_.length()); |
633 | 641 |
634 FrameElement original = elements_[index]; | 642 FrameElement original = elements_[index]; |
635 // If the stored-to slot may be copied, adjust to preserve the | 643 // If the stored-to slot may be copied, adjust to preserve the |
636 // copy-on-write semantics of copied elements. | 644 // copy-on-write semantics of copied elements. |
637 if (original.is_register() || original.is_memory()) { | 645 if (original.is_copied() && |
| 646 (original.is_register() || original.is_memory())) { |
638 FrameElement ignored = AdjustCopies(index); | 647 FrameElement ignored = AdjustCopies(index); |
639 } | 648 } |
640 | 649 |
641 // If the stored-to slot is a register reference, deallocate it. | 650 // If the stored-to slot is a register reference, deallocate it. |
642 if (original.is_register()) { | 651 if (original.is_register()) { |
643 Unuse(original.reg()); | 652 Unuse(original.reg()); |
644 } | 653 } |
645 | 654 |
646 int top_index = elements_.length() - 1; | 655 int top_index = elements_.length() - 1; |
647 FrameElement top = elements_[top_index]; | 656 FrameElement top = elements_[top_index]; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 ASSERT(stack_pointer_ == elements_.length() - 1); | 995 ASSERT(stack_pointer_ == elements_.length() - 1); |
987 elements_.Add(FrameElement::MemoryElement()); | 996 elements_.Add(FrameElement::MemoryElement()); |
988 stack_pointer_++; | 997 stack_pointer_++; |
989 __ push(immediate); | 998 __ push(immediate); |
990 } | 999 } |
991 | 1000 |
992 | 1001 |
993 #undef __ | 1002 #undef __ |
994 | 1003 |
995 } } // namespace v8::internal | 1004 } } // namespace v8::internal |
OLD | NEW |