OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_MARK_COMPACT_H_ | 5 #ifndef V8_HEAP_MARK_COMPACT_H_ |
6 #define V8_HEAP_MARK_COMPACT_H_ | 6 #define V8_HEAP_MARK_COMPACT_H_ |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
10 | 10 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 307 |
308 | 308 |
309 // Defined in isolate.h. | 309 // Defined in isolate.h. |
310 class ThreadLocalTop; | 310 class ThreadLocalTop; |
311 | 311 |
312 | 312 |
313 // ------------------------------------------------------------------------- | 313 // ------------------------------------------------------------------------- |
314 // Mark-Compact collector | 314 // Mark-Compact collector |
315 class MarkCompactCollector { | 315 class MarkCompactCollector { |
316 public: | 316 public: |
| 317 enum IterationMode { |
| 318 kKeepMarking, |
| 319 kClearMarkbits, |
| 320 }; |
| 321 |
| 322 class EvacuateNewSpaceVisitor; |
| 323 class EvacuateOldSpaceVisitor; |
| 324 class HeapObjectVisitor; |
| 325 |
317 static void Initialize(); | 326 static void Initialize(); |
318 | 327 |
319 void SetUp(); | 328 void SetUp(); |
320 | 329 |
321 void TearDown(); | 330 void TearDown(); |
322 | 331 |
323 void CollectEvacuationCandidates(PagedSpace* space); | 332 void CollectEvacuationCandidates(PagedSpace* space); |
324 | 333 |
325 void AddEvacuationCandidate(Page* p); | 334 void AddEvacuationCandidate(Page* p); |
326 | 335 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 // After: Live objects are unmarked, non-live regions have been added to | 697 // After: Live objects are unmarked, non-live regions have been added to |
689 // their space's free list. Active eden semispace is compacted by | 698 // their space's free list. Active eden semispace is compacted by |
690 // evacuation. | 699 // evacuation. |
691 // | 700 // |
692 | 701 |
693 // If we are not compacting the heap, we simply sweep the spaces except | 702 // If we are not compacting the heap, we simply sweep the spaces except |
694 // for the large object space, clearing mark bits and adding unmarked | 703 // for the large object space, clearing mark bits and adding unmarked |
695 // regions to each space's free list. | 704 // regions to each space's free list. |
696 void SweepSpaces(); | 705 void SweepSpaces(); |
697 | 706 |
698 int DiscoverAndEvacuateBlackObjectsOnPage(NewSpace* new_space, | 707 // Iterates through all live objects on a page using marking information. |
699 NewSpacePage* p); | 708 // Returns whether all objects have successfully been visited. |
| 709 bool IterateLiveObjectsOnPage(MemoryChunk* page, HeapObjectVisitor* visitor, |
| 710 IterationMode mode); |
700 | 711 |
701 void EvacuateNewSpace(); | 712 void EvacuateNewSpace(); |
702 | 713 |
703 bool EvacuateLiveObjectsFromPage(Page* p, PagedSpace* target_space, | |
704 SlotsBuffer** evacuation_slots_buffer); | |
705 | |
706 void AddEvacuationSlotsBufferSynchronized( | 714 void AddEvacuationSlotsBufferSynchronized( |
707 SlotsBuffer* evacuation_slots_buffer); | 715 SlotsBuffer* evacuation_slots_buffer); |
708 | 716 |
709 void EvacuatePages(CompactionSpaceCollection* compaction_spaces, | 717 void EvacuatePages(CompactionSpaceCollection* compaction_spaces, |
710 SlotsBuffer** evacuation_slots_buffer); | 718 SlotsBuffer** evacuation_slots_buffer); |
711 | 719 |
712 void EvacuatePagesInParallel(); | 720 void EvacuatePagesInParallel(); |
713 | 721 |
714 // The number of parallel compaction tasks, including the main thread. | 722 // The number of parallel compaction tasks, including the main thread. |
715 int NumberOfParallelCompactionTasks(); | 723 int NumberOfParallelCompactionTasks(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 private: | 861 private: |
854 MarkCompactCollector* collector_; | 862 MarkCompactCollector* collector_; |
855 }; | 863 }; |
856 | 864 |
857 | 865 |
858 const char* AllocationSpaceName(AllocationSpace space); | 866 const char* AllocationSpaceName(AllocationSpace space); |
859 } // namespace internal | 867 } // namespace internal |
860 } // namespace v8 | 868 } // namespace v8 |
861 | 869 |
862 #endif // V8_HEAP_MARK_COMPACT_H_ | 870 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |