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