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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 Address new_space_front = new_space_.ToSpaceLow(); | 674 Address new_space_front = new_space_.ToSpaceLow(); |
675 promotion_queue.Initialize(new_space_.ToSpaceHigh()); | 675 promotion_queue.Initialize(new_space_.ToSpaceHigh()); |
676 | 676 |
677 ScavengeVisitor scavenge_visitor; | 677 ScavengeVisitor scavenge_visitor; |
678 // Copy roots. | 678 // Copy roots. |
679 IterateRoots(&scavenge_visitor); | 679 IterateRoots(&scavenge_visitor); |
680 | 680 |
681 // Copy objects reachable from weak pointers. | 681 // Copy objects reachable from weak pointers. |
682 GlobalHandles::IterateWeakRoots(&scavenge_visitor); | 682 GlobalHandles::IterateWeakRoots(&scavenge_visitor); |
683 | 683 |
684 #ifdef V8_HOST_ARCH_64_BIT | |
685 // TODO(X64): Make this go away again. We currently disable RSets for | |
686 // 64-bit-mode. | |
687 HeapObjectIterator old_pointer_iterator(old_pointer_space_); | |
688 while (old_pointer_iterator.has_next()) { | |
689 HeapObject* heap_object = old_pointer_iterator.next(); | |
690 heap_object->Iterate(&scavenge_visitor); | |
691 } | |
692 HeapObjectIterator map_iterator(map_space_); | |
693 while (map_iterator.has_next()) { | |
694 HeapObject* heap_object = map_iterator.next(); | |
695 heap_object->Iterate(&scavenge_visitor); | |
696 } | |
697 LargeObjectIterator lo_iterator(lo_space_); | |
698 while (lo_iterator.has_next()) { | |
699 HeapObject* heap_object = lo_iterator.next(); | |
700 if (heap_object->IsFixedArray()) { | |
701 heap_object->Iterate(&scavenge_visitor); | |
702 } | |
703 } | |
704 #else // !defined(V8_HOST_ARCH_64_BIT) | |
705 // Copy objects reachable from the old generation. By definition, | 684 // Copy objects reachable from the old generation. By definition, |
706 // there are no intergenerational pointers in code or data spaces. | 685 // there are no intergenerational pointers in code or data spaces. |
707 IterateRSet(old_pointer_space_, &ScavengePointer); | 686 IterateRSet(old_pointer_space_, &ScavengePointer); |
708 IterateRSet(map_space_, &ScavengePointer); | 687 IterateRSet(map_space_, &ScavengePointer); |
709 lo_space_->IterateRSet(&ScavengePointer); | 688 lo_space_->IterateRSet(&ScavengePointer); |
710 #endif | |
711 | 689 |
712 // Copy objects reachable from cells by scavenging cell values directly. | 690 // Copy objects reachable from cells by scavenging cell values directly. |
713 HeapObjectIterator cell_iterator(cell_space_); | 691 HeapObjectIterator cell_iterator(cell_space_); |
714 while (cell_iterator.has_next()) { | 692 while (cell_iterator.has_next()) { |
715 HeapObject* cell = cell_iterator.next(); | 693 HeapObject* cell = cell_iterator.next(); |
716 if (cell->IsJSGlobalPropertyCell()) { | 694 if (cell->IsJSGlobalPropertyCell()) { |
717 Address value_address = | 695 Address value_address = |
718 reinterpret_cast<Address>(cell) + | 696 reinterpret_cast<Address>(cell) + |
719 (JSGlobalPropertyCell::kValueOffset - kHeapObjectTag); | 697 (JSGlobalPropertyCell::kValueOffset - kHeapObjectTag); |
720 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | 698 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 // mark-compact collector. | 801 // mark-compact collector. |
824 ASSERT(!Page::IsRSetSet(reinterpret_cast<Address>(p), 0)); | 802 ASSERT(!Page::IsRSetSet(reinterpret_cast<Address>(p), 0)); |
825 if (Heap::InNewSpace(*p)) { | 803 if (Heap::InNewSpace(*p)) { |
826 Page::SetRSet(reinterpret_cast<Address>(p), 0); | 804 Page::SetRSet(reinterpret_cast<Address>(p), 0); |
827 } | 805 } |
828 } | 806 } |
829 }; | 807 }; |
830 | 808 |
831 | 809 |
832 int Heap::UpdateRSet(HeapObject* obj) { | 810 int Heap::UpdateRSet(HeapObject* obj) { |
833 #ifndef V8_HOST_ARCH_64_BIT | |
834 // TODO(X64) Reenable RSet when we have a working 64-bit layout of Page. | |
835 ASSERT(!InNewSpace(obj)); | 811 ASSERT(!InNewSpace(obj)); |
836 // Special handling of fixed arrays to iterate the body based on the start | 812 // Special handling of fixed arrays to iterate the body based on the start |
837 // address and offset. Just iterating the pointers as in UpdateRSetVisitor | 813 // address and offset. Just iterating the pointers as in UpdateRSetVisitor |
838 // will not work because Page::SetRSet needs to have the start of the | 814 // will not work because Page::SetRSet needs to have the start of the |
839 // object. | 815 // object for large object pages. |
840 if (obj->IsFixedArray()) { | 816 if (obj->IsFixedArray()) { |
841 FixedArray* array = FixedArray::cast(obj); | 817 FixedArray* array = FixedArray::cast(obj); |
842 int length = array->length(); | 818 int length = array->length(); |
843 for (int i = 0; i < length; i++) { | 819 for (int i = 0; i < length; i++) { |
844 int offset = FixedArray::kHeaderSize + i * kPointerSize; | 820 int offset = FixedArray::kHeaderSize + i * kPointerSize; |
845 ASSERT(!Page::IsRSetSet(obj->address(), offset)); | 821 ASSERT(!Page::IsRSetSet(obj->address(), offset)); |
846 if (Heap::InNewSpace(array->get(i))) { | 822 if (Heap::InNewSpace(array->get(i))) { |
847 Page::SetRSet(obj->address(), offset); | 823 Page::SetRSet(obj->address(), offset); |
848 } | 824 } |
849 } | 825 } |
850 } else if (!obj->IsCode()) { | 826 } else if (!obj->IsCode()) { |
851 // Skip code object, we know it does not contain inter-generational | 827 // Skip code object, we know it does not contain inter-generational |
852 // pointers. | 828 // pointers. |
853 UpdateRSetVisitor v; | 829 UpdateRSetVisitor v; |
854 obj->Iterate(&v); | 830 obj->Iterate(&v); |
855 } | 831 } |
856 #endif // V8_HOST_ARCH_64_BIT | |
857 return obj->Size(); | 832 return obj->Size(); |
858 } | 833 } |
859 | 834 |
860 | 835 |
861 void Heap::RebuildRSets() { | 836 void Heap::RebuildRSets() { |
862 // By definition, we do not care about remembered set bits in code, | 837 // By definition, we do not care about remembered set bits in code, |
863 // data, or cell spaces. | 838 // data, or cell spaces. |
864 map_space_->ClearRSet(); | 839 map_space_->ClearRSet(); |
865 RebuildRSets(map_space_); | 840 RebuildRSets(map_space_); |
866 | 841 |
(...skipping 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3890 #ifdef DEBUG | 3865 #ifdef DEBUG |
3891 bool Heap::GarbageCollectionGreedyCheck() { | 3866 bool Heap::GarbageCollectionGreedyCheck() { |
3892 ASSERT(FLAG_gc_greedy); | 3867 ASSERT(FLAG_gc_greedy); |
3893 if (Bootstrapper::IsActive()) return true; | 3868 if (Bootstrapper::IsActive()) return true; |
3894 if (disallow_allocation_failure()) return true; | 3869 if (disallow_allocation_failure()) return true; |
3895 return CollectGarbage(0, NEW_SPACE); | 3870 return CollectGarbage(0, NEW_SPACE); |
3896 } | 3871 } |
3897 #endif | 3872 #endif |
3898 | 3873 |
3899 } } // namespace v8::internal | 3874 } } // namespace v8::internal |
OLD | NEW |