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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 320 |
321 | 321 |
322 // Defined in isolate.h. | 322 // Defined in isolate.h. |
323 class ThreadLocalTop; | 323 class ThreadLocalTop; |
324 | 324 |
325 | 325 |
326 // ------------------------------------------------------------------------- | 326 // ------------------------------------------------------------------------- |
327 // Mark-Compact collector | 327 // Mark-Compact collector |
328 class MarkCompactCollector { | 328 class MarkCompactCollector { |
329 public: | 329 public: |
| 330 enum IterationMode { |
| 331 kKeepMarking, |
| 332 kClearMarkbits, |
| 333 }; |
| 334 |
| 335 class EvacuateNewSpaceVisitor; |
| 336 class EvacuateOldSpaceVisitor; |
| 337 class HeapObjectVisitor; |
| 338 |
330 static void Initialize(); | 339 static void Initialize(); |
331 | 340 |
332 void SetUp(); | 341 void SetUp(); |
333 | 342 |
334 void TearDown(); | 343 void TearDown(); |
335 | 344 |
336 void CollectEvacuationCandidates(PagedSpace* space); | 345 void CollectEvacuationCandidates(PagedSpace* space); |
337 | 346 |
338 void AddEvacuationCandidate(Page* p); | 347 void AddEvacuationCandidate(Page* p); |
339 | 348 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 // After: Live objects are unmarked, non-live regions have been added to | 705 // After: Live objects are unmarked, non-live regions have been added to |
697 // their space's free list. Active eden semispace is compacted by | 706 // their space's free list. Active eden semispace is compacted by |
698 // evacuation. | 707 // evacuation. |
699 // | 708 // |
700 | 709 |
701 // If we are not compacting the heap, we simply sweep the spaces except | 710 // If we are not compacting the heap, we simply sweep the spaces except |
702 // for the large object space, clearing mark bits and adding unmarked | 711 // for the large object space, clearing mark bits and adding unmarked |
703 // regions to each space's free list. | 712 // regions to each space's free list. |
704 void SweepSpaces(); | 713 void SweepSpaces(); |
705 | 714 |
706 int DiscoverAndEvacuateBlackObjectsOnPage(NewSpace* new_space, | 715 // Iterates through all live objects on a page using marking information. |
707 NewSpacePage* p); | 716 // Returns whether all objects have successfully been visited. |
| 717 bool IterateLiveObjectsOnPage(MemoryChunk* page, HeapObjectVisitor* visitor, |
| 718 IterationMode mode); |
708 | 719 |
709 void EvacuateNewSpace(); | 720 void EvacuateNewSpace(); |
710 | 721 |
711 bool EvacuateLiveObjectsFromPage(Page* p, PagedSpace* target_space, | |
712 SlotsBuffer** evacuation_slots_buffer); | |
713 | |
714 void AddEvacuationSlotsBufferSynchronized( | 722 void AddEvacuationSlotsBufferSynchronized( |
715 SlotsBuffer* evacuation_slots_buffer); | 723 SlotsBuffer* evacuation_slots_buffer); |
716 | 724 |
717 void EvacuatePages(CompactionSpaceCollection* compaction_spaces, | 725 void EvacuatePages(CompactionSpaceCollection* compaction_spaces, |
718 SlotsBuffer** evacuation_slots_buffer); | 726 SlotsBuffer** evacuation_slots_buffer); |
719 | 727 |
720 void EvacuatePagesInParallel(); | 728 void EvacuatePagesInParallel(); |
721 | 729 |
722 // The number of parallel compaction tasks, including the main thread. | 730 // The number of parallel compaction tasks, including the main thread. |
723 int NumberOfParallelCompactionTasks(); | 731 int NumberOfParallelCompactionTasks(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 private: | 869 private: |
862 MarkCompactCollector* collector_; | 870 MarkCompactCollector* collector_; |
863 }; | 871 }; |
864 | 872 |
865 | 873 |
866 const char* AllocationSpaceName(AllocationSpace space); | 874 const char* AllocationSpaceName(AllocationSpace space); |
867 } // namespace internal | 875 } // namespace internal |
868 } // namespace v8 | 876 } // namespace v8 |
869 | 877 |
870 #endif // V8_HEAP_MARK_COMPACT_H_ | 878 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |