Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: src/mark-compact.cc

Issue 109012: Some cleanup of the mark-sweep/compact collector following the symbol... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/mark-compact.h ('K') | « src/mark-compact.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 object->ClearOverflow(); 548 object->ClearOverflow();
549 ASSERT(object->IsMarked()); 549 ASSERT(object->IsMarked());
550 ASSERT(Heap::Contains(object)); 550 ASSERT(Heap::Contains(object));
551 marking_stack.Push(object); 551 marking_stack.Push(object);
552 if (marking_stack.is_full()) return; 552 if (marking_stack.is_full()) return;
553 } 553 }
554 } 554 }
555 } 555 }
556 556
557 557
558 bool MarkCompactCollector::MustBeMarked(Object** p) { 558 bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) {
559 // Check whether *p is a HeapObject pointer. 559 return (*p)->IsHeapObject() && !HeapObject::cast(*p)->IsMarked();
560 if (!(*p)->IsHeapObject()) return false;
561 return !HeapObject::cast(*p)->IsMarked();
562 } 560 }
563 561
564 562
565 class SymbolMarkingVisitor : public ObjectVisitor { 563 class SymbolMarkingVisitor : public ObjectVisitor {
566 public: 564 public:
567 void VisitPointers(Object** start, Object** end) { 565 void VisitPointers(Object** start, Object** end) {
568 MarkingVisitor marker; 566 MarkingVisitor marker;
569 for (Object** p = start; p < end; p++) { 567 for (Object** p = start; p < end; p++) {
570 if (!(*p)->IsHeapObject()) continue; 568 if (!(*p)->IsHeapObject()) continue;
571 569
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 // The to space contains live objects, the from space is used as a marking 747 // The to space contains live objects, the from space is used as a marking
750 // stack. 748 // stack.
751 marking_stack.Initialize(Heap::new_space()->FromSpaceLow(), 749 marking_stack.Initialize(Heap::new_space()->FromSpaceLow(),
752 Heap::new_space()->FromSpaceHigh()); 750 Heap::new_space()->FromSpaceHigh());
753 751
754 ASSERT(!marking_stack.overflowed()); 752 ASSERT(!marking_stack.overflowed());
755 753
756 RootMarkingVisitor root_visitor; 754 RootMarkingVisitor root_visitor;
757 MarkRoots(&root_visitor); 755 MarkRoots(&root_visitor);
758 756
759 // The objects reachable from the roots are marked black, unreachable 757 // The objects reachable from the roots are marked, yet unreachable
760 // objects are white. Mark objects reachable from object groups with at 758 // objects are unmarked. Mark objects reachable from object groups
761 // least one marked object, and continue until no new objects are 759 // containing at least one marked object, and continue until no new
762 // reachable from the object groups. 760 // objects are reachable from the object groups.
763 ProcessObjectGroups(root_visitor.stack_visitor()); 761 ProcessObjectGroups(root_visitor.stack_visitor());
764 762
765 // The objects reachable from the roots or object groups are marked black, 763 // The objects reachable from the roots or object groups are marked,
766 // unreachable objects are white. Process objects reachable only from 764 // yet unreachable objects are unmarked. Mark objects reachable
767 // weak global handles. 765 // only from weak global handles.
768 // 766 //
769 // First we mark weak pointers not yet reachable. 767 // First we identify nonlive weak handles and mark them as pending
770 GlobalHandles::MarkWeakRoots(&MustBeMarked); 768 // destruction.
771 // Then we process weak pointers and process the transitive closure. 769 GlobalHandles::IdentifyWeakHandles(&IsUnmarkedHeapObject);
770 // Then we mark the objects and process the transitive closure.
772 GlobalHandles::IterateWeakRoots(&root_visitor); 771 GlobalHandles::IterateWeakRoots(&root_visitor);
773 while (marking_stack.overflowed()) { 772 while (marking_stack.overflowed()) {
774 RefillMarkingStack(); 773 RefillMarkingStack();
775 EmptyMarkingStack(root_visitor.stack_visitor()); 774 EmptyMarkingStack(root_visitor.stack_visitor());
776 } 775 }
777 776
778 // Repeat the object groups to mark unmarked groups reachable from the 777 // Repeat the object groups to mark unmarked groups reachable from the
779 // weak roots. 778 // weak roots.
780 ProcessObjectGroups(root_visitor.stack_visitor()); 779 ProcessObjectGroups(root_visitor.stack_visitor());
781 780
(...skipping 12 matching lines...) Expand all
794 793
795 794
796 static int CountMarkedCallback(HeapObject* obj) { 795 static int CountMarkedCallback(HeapObject* obj) {
797 MapWord map_word = obj->map_word(); 796 MapWord map_word = obj->map_word();
798 map_word.ClearMark(); 797 map_word.ClearMark();
799 return obj->SizeFromMap(map_word.ToMap()); 798 return obj->SizeFromMap(map_word.ToMap());
800 } 799 }
801 800
802 801
803 #ifdef DEBUG 802 #ifdef DEBUG
804 void MarkCompactCollector::UpdateLiveObjectCount(HeapObject* obj, int scale) { 803 void MarkCompactCollector::UpdateLiveObjectCount(HeapObject* obj) {
805 ASSERT(scale == -1 || scale == 1); 804 live_bytes_ += obj->Size();
806 live_bytes_ += obj->Size() * scale;
807 if (Heap::new_space()->Contains(obj)) { 805 if (Heap::new_space()->Contains(obj)) {
808 live_young_objects_ += scale; 806 live_young_objects_++;
809 } else if (Heap::map_space()->Contains(obj)) { 807 } else if (Heap::map_space()->Contains(obj)) {
810 ASSERT(obj->IsMap()); 808 ASSERT(obj->IsMap());
811 live_map_objects_ += scale; 809 live_map_objects_ ++;
812 } else if (Heap::old_pointer_space()->Contains(obj)) { 810 } else if (Heap::old_pointer_space()->Contains(obj)) {
813 live_old_pointer_objects_ += scale; 811 live_old_pointer_objects_++;
814 } else if (Heap::old_data_space()->Contains(obj)) { 812 } else if (Heap::old_data_space()->Contains(obj)) {
815 live_old_data_objects_ += scale; 813 live_old_data_objects_++;
816 } else if (Heap::code_space()->Contains(obj)) { 814 } else if (Heap::code_space()->Contains(obj)) {
817 live_code_objects_ += scale; 815 live_code_objects_++;
818 } else if (Heap::lo_space()->Contains(obj)) { 816 } else if (Heap::lo_space()->Contains(obj)) {
819 live_lo_objects_ +=scale; 817 live_lo_objects_++;
820 } else { 818 } else {
821 UNREACHABLE(); 819 UNREACHABLE();
822 } 820 }
823 } 821 }
824 #endif // DEBUG 822 #endif // DEBUG
825 823
826 824
827 void MarkCompactCollector::SweepLargeObjectSpace() { 825 void MarkCompactCollector::SweepLargeObjectSpace() {
828 #ifdef DEBUG 826 #ifdef DEBUG
829 ASSERT(state_ == MARK_LIVE_OBJECTS); 827 ASSERT(state_ == MARK_LIVE_OBJECTS);
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 1794
1797 void MarkCompactCollector::RebuildRSets() { 1795 void MarkCompactCollector::RebuildRSets() {
1798 #ifdef DEBUG 1796 #ifdef DEBUG
1799 ASSERT(state_ == RELOCATE_OBJECTS); 1797 ASSERT(state_ == RELOCATE_OBJECTS);
1800 state_ = REBUILD_RSETS; 1798 state_ = REBUILD_RSETS;
1801 #endif 1799 #endif
1802 Heap::RebuildRSets(); 1800 Heap::RebuildRSets();
1803 } 1801 }
1804 1802
1805 } } // namespace v8::internal 1803 } } // namespace v8::internal
OLDNEW
« src/mark-compact.h ('K') | « src/mark-compact.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698