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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 copy.clear_sync(); | 543 copy.clear_sync(); |
544 } | 544 } |
545 elements_[j] = copy; | 545 elements_[j] = copy; |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 copy.clear_sync(); | 549 copy.clear_sync(); |
550 return copy; | 550 return copy; |
551 } | 551 } |
552 | 552 |
553 elements_[index].clear_copied(); | |
554 return FrameElement::InvalidElement(); | 553 return FrameElement::InvalidElement(); |
555 } | 554 } |
556 | 555 |
557 | 556 |
558 void VirtualFrame::TakeFrameSlotAt(int index) { | 557 void VirtualFrame::TakeFrameSlotAt(int index) { |
559 ASSERT(index >= 0); | 558 ASSERT(index >= 0); |
560 ASSERT(index <= elements_.length()); | 559 ASSERT(index <= elements_.length()); |
561 FrameElement original = elements_[index]; | 560 FrameElement original = elements_[index]; |
562 | 561 |
563 switch (original.type()) { | 562 switch (original.type()) { |
564 case FrameElement::INVALID: | 563 case FrameElement::INVALID: |
565 UNREACHABLE(); | 564 UNREACHABLE(); |
566 break; | 565 break; |
567 | 566 |
568 case FrameElement::MEMORY: { | 567 case FrameElement::MEMORY: { |
569 // Allocate the element to a register. If it is not copied, | 568 // Allocate the element to a register. If it is not copied, |
570 // push that register on top of the frame. If it is copied, | 569 // push that register on top of the frame. If it is copied, |
571 // make the first copy the backing store and push a fresh copy | 570 // make the first copy the backing store and push a fresh copy |
572 // on top of the frame. | 571 // on top of the frame. |
573 FrameElement copy = original.is_copied() | 572 FrameElement copy = AdjustCopies(index); |
574 ? AdjustCopies(index) | |
575 : FrameElement::InvalidElement(); | |
576 if (copy.is_valid()) { | 573 if (copy.is_valid()) { |
577 // The original element was a copy. Push the copy of the new | 574 // The original element was a copy. Push the copy of the new |
578 // backing store. | 575 // backing store. |
579 elements_.Add(copy); | 576 elements_.Add(copy); |
580 } else { | 577 } else { |
581 // The element was not a copy. Move it to a register and push | 578 // The element was not a copy. Move it to a register and push |
582 // that. | 579 // that. |
583 Result fresh = cgen_->allocator()->Allocate(); | 580 Result fresh = cgen_->allocator()->Allocate(); |
584 ASSERT(fresh.is_valid()); | 581 ASSERT(fresh.is_valid()); |
585 FrameElement new_element = | 582 FrameElement new_element = |
586 FrameElement::RegisterElement(fresh.reg(), | 583 FrameElement::RegisterElement(fresh.reg(), |
587 FrameElement::NOT_SYNCED); | 584 FrameElement::NOT_SYNCED); |
588 Use(fresh.reg()); | 585 Use(fresh.reg()); |
589 elements_.Add(new_element); | 586 elements_.Add(new_element); |
590 __ mov(fresh.reg(), Operand(ebp, fp_relative(index))); | 587 __ mov(fresh.reg(), Operand(ebp, fp_relative(index))); |
591 } | 588 } |
592 break; | 589 break; |
593 } | 590 } |
594 | 591 |
595 case FrameElement::REGISTER: { | 592 case FrameElement::REGISTER: { |
596 // If the element is not copied, push it on top of the frame. | 593 // If the element is not copied, push it on top of the frame. |
597 // If it is copied, make the first copy be the new backing store | 594 // If it is copied, make the first copy be the new backing store |
598 // and push a fresh copy on top of the frame. | 595 // and push a fresh copy on top of the frame. |
599 FrameElement copy = original.is_copied() | 596 FrameElement copy = AdjustCopies(index); |
600 ? AdjustCopies(index) | |
601 : FrameElement::InvalidElement(); | |
602 if (copy.is_valid()) { | 597 if (copy.is_valid()) { |
603 // The original element was a copy. Push the copy of the new | 598 // The original element was a copy. Push the copy of the new |
604 // backing store. | 599 // backing store. |
605 elements_.Add(copy); | 600 elements_.Add(copy); |
606 // This is the only case where we have to unuse the original | 601 // This is the only case where we have to unuse the original |
607 // register. The original is still counted and so is the new | 602 // register. The original is still counted and so is the new |
608 // backing store of the copies. | 603 // backing store of the copies. |
609 Unuse(original.reg()); | 604 Unuse(original.reg()); |
610 } else { | 605 } else { |
611 // The element was not a copy. Push it. | 606 // The element was not a copy. Push it. |
(...skipping 20 matching lines...) Expand all Loading... |
632 void VirtualFrame::StoreToFrameSlotAt(int index) { | 627 void VirtualFrame::StoreToFrameSlotAt(int index) { |
633 // Store the value on top of the frame to the virtual frame slot at | 628 // Store the value on top of the frame to the virtual frame slot at |
634 // a given index. The value on top of the frame is left in place. | 629 // a given index. The value on top of the frame is left in place. |
635 // This is a duplicating operation, so it can create copies. | 630 // This is a duplicating operation, so it can create copies. |
636 ASSERT(index >= 0); | 631 ASSERT(index >= 0); |
637 ASSERT(index < elements_.length()); | 632 ASSERT(index < elements_.length()); |
638 | 633 |
639 FrameElement original = elements_[index]; | 634 FrameElement original = elements_[index]; |
640 // If the stored-to slot may be copied, adjust to preserve the | 635 // If the stored-to slot may be copied, adjust to preserve the |
641 // copy-on-write semantics of copied elements. | 636 // copy-on-write semantics of copied elements. |
642 if (original.is_copied() && | 637 if (original.is_register() || original.is_memory()) { |
643 (original.is_register() || original.is_memory())) { | |
644 FrameElement ignored = AdjustCopies(index); | 638 FrameElement ignored = AdjustCopies(index); |
645 } | 639 } |
646 | 640 |
647 // If the stored-to slot is a register reference, deallocate it. | 641 // If the stored-to slot is a register reference, deallocate it. |
648 if (original.is_register()) { | 642 if (original.is_register()) { |
649 Unuse(original.reg()); | 643 Unuse(original.reg()); |
650 } | 644 } |
651 | 645 |
652 int top_index = elements_.length() - 1; | 646 int top_index = elements_.length() - 1; |
653 FrameElement top = elements_[top_index]; | 647 FrameElement top = elements_[top_index]; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 ASSERT(stack_pointer_ == elements_.length() - 1); | 986 ASSERT(stack_pointer_ == elements_.length() - 1); |
993 elements_.Add(FrameElement::MemoryElement()); | 987 elements_.Add(FrameElement::MemoryElement()); |
994 stack_pointer_++; | 988 stack_pointer_++; |
995 __ push(immediate); | 989 __ push(immediate); |
996 } | 990 } |
997 | 991 |
998 | 992 |
999 #undef __ | 993 #undef __ |
1000 | 994 |
1001 } } // namespace v8::internal | 995 } } // namespace v8::internal |
OLD | NEW |