OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 Context::SECURITY_TOKEN_INDEX * kPointerSize; | 613 Context::SECURITY_TOKEN_INDEX * kPointerSize; |
614 mov(scratch, FieldOperand(scratch, token_offset)); | 614 mov(scratch, FieldOperand(scratch, token_offset)); |
615 cmp(scratch, FieldOperand(holder_reg, token_offset)); | 615 cmp(scratch, FieldOperand(holder_reg, token_offset)); |
616 pop(holder_reg); | 616 pop(holder_reg); |
617 j(not_equal, miss, not_taken); | 617 j(not_equal, miss, not_taken); |
618 | 618 |
619 bind(&same_contexts); | 619 bind(&same_contexts); |
620 } | 620 } |
621 | 621 |
622 | 622 |
623 void MacroAssembler::LoadAllocationTopHelper( | 623 void MacroAssembler::LoadAllocationTopHelper(Register result, |
624 Register result, | 624 Register result_end, |
625 Register result_end, | 625 Register scratch, |
626 Register scratch, | 626 AllocationFlags flags) { |
627 bool result_contains_top_on_entry) { | |
628 ExternalReference new_space_allocation_top = | 627 ExternalReference new_space_allocation_top = |
629 ExternalReference::new_space_allocation_top_address(); | 628 ExternalReference::new_space_allocation_top_address(); |
630 | 629 |
631 // Just return if allocation top is already known. | 630 // Just return if allocation top is already known. |
632 if (result_contains_top_on_entry) { | 631 if ((flags & RESULT_CONTAINS_TOP) != 0) { |
633 // No use of scratch if allocation top is provided. | 632 // No use of scratch if allocation top is provided. |
634 ASSERT(scratch.is(no_reg)); | 633 ASSERT(scratch.is(no_reg)); |
635 return; | 634 return; |
636 } | 635 } |
637 | 636 |
638 // Move address of new object to result. Use scratch register if available. | 637 // Move address of new object to result. Use scratch register if available. |
639 if (scratch.is(no_reg)) { | 638 if (scratch.is(no_reg)) { |
640 mov(result, Operand::StaticVariable(new_space_allocation_top)); | 639 mov(result, Operand::StaticVariable(new_space_allocation_top)); |
641 } else { | 640 } else { |
642 ASSERT(!scratch.is(result_end)); | 641 ASSERT(!scratch.is(result_end)); |
643 mov(Operand(scratch), Immediate(new_space_allocation_top)); | 642 mov(Operand(scratch), Immediate(new_space_allocation_top)); |
644 mov(result, Operand(scratch, 0)); | 643 mov(result, Operand(scratch, 0)); |
645 } | 644 } |
646 } | 645 } |
647 | 646 |
648 | 647 |
649 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, | 648 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, |
650 Register scratch) { | 649 Register scratch) { |
651 ExternalReference new_space_allocation_top = | 650 ExternalReference new_space_allocation_top = |
652 ExternalReference::new_space_allocation_top_address(); | 651 ExternalReference::new_space_allocation_top_address(); |
653 | 652 |
654 // Update new top. Use scratch if available. | 653 // Update new top. Use scratch if available. |
655 if (scratch.is(no_reg)) { | 654 if (scratch.is(no_reg)) { |
656 mov(Operand::StaticVariable(new_space_allocation_top), result_end); | 655 mov(Operand::StaticVariable(new_space_allocation_top), result_end); |
657 } else { | 656 } else { |
658 mov(Operand(scratch, 0), result_end); | 657 mov(Operand(scratch, 0), result_end); |
659 } | 658 } |
660 } | 659 } |
661 | 660 |
662 void MacroAssembler::AllocateObjectInNewSpace( | 661 |
663 int object_size, | 662 void MacroAssembler::AllocateObjectInNewSpace(int object_size, |
664 Register result, | 663 Register result, |
665 Register result_end, | 664 Register result_end, |
666 Register scratch, | 665 Register scratch, |
667 Label* gc_required, | 666 Label* gc_required, |
668 bool result_contains_top_on_entry) { | 667 AllocationFlags flags) { |
669 ASSERT(!result.is(result_end)); | 668 ASSERT(!result.is(result_end)); |
670 | 669 |
671 // Load address of new object into result. | 670 // Load address of new object into result. |
672 LoadAllocationTopHelper(result, | 671 LoadAllocationTopHelper(result, result_end, scratch, flags); |
673 result_end, | |
674 scratch, | |
675 result_contains_top_on_entry); | |
676 | 672 |
677 // Calculate new top and bail out if new space is exhausted. | 673 // Calculate new top and bail out if new space is exhausted. |
678 ExternalReference new_space_allocation_limit = | 674 ExternalReference new_space_allocation_limit = |
679 ExternalReference::new_space_allocation_limit_address(); | 675 ExternalReference::new_space_allocation_limit_address(); |
680 lea(result_end, Operand(result, object_size)); | 676 lea(result_end, Operand(result, object_size)); |
681 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); | 677 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); |
682 j(above, gc_required, not_taken); | 678 j(above, gc_required, not_taken); |
683 | 679 |
684 // Update allocation top. | 680 // Update allocation top. |
685 UpdateAllocationTopHelper(result_end, scratch); | 681 UpdateAllocationTopHelper(result_end, scratch); |
| 682 |
| 683 // Tag result if requested. |
| 684 if ((flags & TAG_OBJECT) != 0) { |
| 685 or_(Operand(result), Immediate(kHeapObjectTag)); |
| 686 } |
686 } | 687 } |
687 | 688 |
688 | 689 |
689 void MacroAssembler::AllocateObjectInNewSpace( | 690 void MacroAssembler::AllocateObjectInNewSpace(int header_size, |
690 int header_size, | 691 ScaleFactor element_size, |
691 ScaleFactor element_size, | 692 Register element_count, |
692 Register element_count, | 693 Register result, |
693 Register result, | 694 Register result_end, |
694 Register result_end, | 695 Register scratch, |
695 Register scratch, | 696 Label* gc_required, |
696 Label* gc_required, | 697 AllocationFlags flags) { |
697 bool result_contains_top_on_entry) { | |
698 ASSERT(!result.is(result_end)); | 698 ASSERT(!result.is(result_end)); |
699 | 699 |
700 // Load address of new object into result. | 700 // Load address of new object into result. |
701 LoadAllocationTopHelper(result, | 701 LoadAllocationTopHelper(result, result_end, scratch, flags); |
702 result_end, | |
703 scratch, | |
704 result_contains_top_on_entry); | |
705 | 702 |
706 // Calculate new top and bail out if new space is exhausted. | 703 // Calculate new top and bail out if new space is exhausted. |
707 ExternalReference new_space_allocation_limit = | 704 ExternalReference new_space_allocation_limit = |
708 ExternalReference::new_space_allocation_limit_address(); | 705 ExternalReference::new_space_allocation_limit_address(); |
709 lea(result_end, Operand(result, element_count, element_size, header_size)); | 706 lea(result_end, Operand(result, element_count, element_size, header_size)); |
710 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); | 707 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); |
711 j(above, gc_required); | 708 j(above, gc_required); |
712 | 709 |
713 // Update allocation top. | 710 // Update allocation top. |
714 UpdateAllocationTopHelper(result_end, scratch); | 711 UpdateAllocationTopHelper(result_end, scratch); |
| 712 |
| 713 // Tag result if requested. |
| 714 if ((flags & TAG_OBJECT) != 0) { |
| 715 or_(Operand(result), Immediate(kHeapObjectTag)); |
| 716 } |
715 } | 717 } |
716 | 718 |
717 | 719 |
718 void MacroAssembler::AllocateObjectInNewSpace( | 720 void MacroAssembler::AllocateObjectInNewSpace(Register object_size, |
719 Register object_size, | 721 Register result, |
720 Register result, | 722 Register result_end, |
721 Register result_end, | 723 Register scratch, |
722 Register scratch, | 724 Label* gc_required, |
723 Label* gc_required, | 725 AllocationFlags flags) { |
724 bool result_contains_top_on_entry) { | |
725 ASSERT(!result.is(result_end)); | 726 ASSERT(!result.is(result_end)); |
726 | 727 |
727 // Load address of new object into result. | 728 // Load address of new object into result. |
728 LoadAllocationTopHelper(result, | 729 LoadAllocationTopHelper(result, result_end, scratch, flags); |
729 result_end, | |
730 scratch, | |
731 result_contains_top_on_entry); | |
732 | |
733 | 730 |
734 // Calculate new top and bail out if new space is exhausted. | 731 // Calculate new top and bail out if new space is exhausted. |
735 ExternalReference new_space_allocation_limit = | 732 ExternalReference new_space_allocation_limit = |
736 ExternalReference::new_space_allocation_limit_address(); | 733 ExternalReference::new_space_allocation_limit_address(); |
737 if (!object_size.is(result_end)) { | 734 if (!object_size.is(result_end)) { |
738 mov(result_end, object_size); | 735 mov(result_end, object_size); |
739 } | 736 } |
740 add(result_end, Operand(result)); | 737 add(result_end, Operand(result)); |
741 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); | 738 cmp(result_end, Operand::StaticVariable(new_space_allocation_limit)); |
742 j(above, gc_required, not_taken); | 739 j(above, gc_required, not_taken); |
743 | 740 |
744 // Update allocation top. | 741 // Update allocation top. |
745 UpdateAllocationTopHelper(result_end, scratch); | 742 UpdateAllocationTopHelper(result_end, scratch); |
| 743 |
| 744 // Tag result if requested. |
| 745 if ((flags & TAG_OBJECT) != 0) { |
| 746 or_(Operand(result), Immediate(kHeapObjectTag)); |
| 747 } |
746 } | 748 } |
747 | 749 |
748 | 750 |
749 void MacroAssembler::UndoAllocationInNewSpace(Register object) { | 751 void MacroAssembler::UndoAllocationInNewSpace(Register object) { |
750 ExternalReference new_space_allocation_top = | 752 ExternalReference new_space_allocation_top = |
751 ExternalReference::new_space_allocation_top_address(); | 753 ExternalReference::new_space_allocation_top_address(); |
752 | 754 |
753 // Make sure the object has no tag before resetting top. | 755 // Make sure the object has no tag before resetting top. |
754 and_(Operand(object), Immediate(~kHeapObjectTagMask)); | 756 and_(Operand(object), Immediate(~kHeapObjectTagMask)); |
755 #ifdef DEBUG | 757 #ifdef DEBUG |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 // Indicate that code has changed. | 1177 // Indicate that code has changed. |
1176 CPU::FlushICache(address_, size_); | 1178 CPU::FlushICache(address_, size_); |
1177 | 1179 |
1178 // Check that the code was patched as expected. | 1180 // Check that the code was patched as expected. |
1179 ASSERT(masm_.pc_ == address_ + size_); | 1181 ASSERT(masm_.pc_ == address_ + size_); |
1180 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1182 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
1181 } | 1183 } |
1182 | 1184 |
1183 | 1185 |
1184 } } // namespace v8::internal | 1186 } } // namespace v8::internal |
OLD | NEW |