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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 { | 317 enum IterationMode { |
318 kKeepMarking, | 318 kKeepMarking, |
319 kClearMarkbits, | 319 kClearMarkbits, |
320 }; | 320 }; |
321 | 321 |
322 class EvacuateNewSpaceVisitor; | |
323 class EvacuateOldSpaceVisitor; | |
324 class HeapObjectVisitor; | |
325 | |
326 static void Initialize(); | 322 static void Initialize(); |
327 | 323 |
328 void SetUp(); | 324 void SetUp(); |
329 | 325 |
330 void TearDown(); | 326 void TearDown(); |
331 | 327 |
332 void CollectEvacuationCandidates(PagedSpace* space); | 328 void CollectEvacuationCandidates(PagedSpace* space); |
333 | 329 |
334 void AddEvacuationCandidate(Page* p); | 330 void AddEvacuationCandidate(Page* p); |
335 | 331 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 INLINE(void ForceRecordSlot(HeapObject* object, Object** slot, | 398 INLINE(void ForceRecordSlot(HeapObject* object, Object** slot, |
403 Object* target)); | 399 Object* target)); |
404 | 400 |
405 void UpdateSlots(SlotsBuffer* buffer); | 401 void UpdateSlots(SlotsBuffer* buffer); |
406 void UpdateSlotsRecordedIn(SlotsBuffer* buffer); | 402 void UpdateSlotsRecordedIn(SlotsBuffer* buffer); |
407 | 403 |
408 void MigrateObject(HeapObject* dst, HeapObject* src, int size, | 404 void MigrateObject(HeapObject* dst, HeapObject* src, int size, |
409 AllocationSpace to_old_space, | 405 AllocationSpace to_old_space, |
410 SlotsBuffer** evacuation_slots_buffer); | 406 SlotsBuffer** evacuation_slots_buffer); |
411 | 407 |
412 bool TryPromoteObject(HeapObject* object, int object_size); | |
413 | |
414 void InvalidateCode(Code* code); | 408 void InvalidateCode(Code* code); |
415 | 409 |
416 void ClearMarkbits(); | 410 void ClearMarkbits(); |
417 | 411 |
418 bool is_compacting() const { return compacting_; } | 412 bool is_compacting() const { return compacting_; } |
419 | 413 |
420 MarkingParity marking_parity() { return marking_parity_; } | 414 MarkingParity marking_parity() { return marking_parity_; } |
421 | 415 |
422 // Concurrent and parallel sweeping support. If required_freed_bytes was set | 416 // Concurrent and parallel sweeping support. If required_freed_bytes was set |
423 // to a value larger than 0, then sweeping returns after a block of at least | 417 // to a value larger than 0, then sweeping returns after a block of at least |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 } | 495 } |
502 base::SmartPointer<FreeList>& free_list_code_space() { | 496 base::SmartPointer<FreeList>& free_list_code_space() { |
503 return free_list_code_space_; | 497 return free_list_code_space_; |
504 } | 498 } |
505 base::SmartPointer<FreeList>& free_list_map_space() { | 499 base::SmartPointer<FreeList>& free_list_map_space() { |
506 return free_list_map_space_; | 500 return free_list_map_space_; |
507 } | 501 } |
508 | 502 |
509 private: | 503 private: |
510 class CompactionTask; | 504 class CompactionTask; |
| 505 class EvacuateNewSpaceVisitor; |
| 506 class EvacuateOldSpaceVisitor; |
| 507 class EvacuateVisitorBase; |
| 508 class HeapObjectVisitor; |
511 class SweeperTask; | 509 class SweeperTask; |
512 | 510 |
513 explicit MarkCompactCollector(Heap* heap); | 511 explicit MarkCompactCollector(Heap* heap); |
514 | 512 |
515 bool WillBeDeoptimized(Code* code); | 513 bool WillBeDeoptimized(Code* code); |
516 void EvictPopularEvacuationCandidate(Page* page); | 514 void EvictPopularEvacuationCandidate(Page* page); |
517 void ClearInvalidStoreAndSlotsBufferEntries(); | 515 void ClearInvalidStoreAndSlotsBufferEntries(); |
518 | 516 |
519 void StartSweeperThreads(); | 517 void StartSweeperThreads(); |
520 | 518 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 // After: Live objects are unmarked, non-live regions have been added to | 695 // After: Live objects are unmarked, non-live regions have been added to |
698 // their space's free list. Active eden semispace is compacted by | 696 // their space's free list. Active eden semispace is compacted by |
699 // evacuation. | 697 // evacuation. |
700 // | 698 // |
701 | 699 |
702 // If we are not compacting the heap, we simply sweep the spaces except | 700 // If we are not compacting the heap, we simply sweep the spaces except |
703 // for the large object space, clearing mark bits and adding unmarked | 701 // for the large object space, clearing mark bits and adding unmarked |
704 // regions to each space's free list. | 702 // regions to each space's free list. |
705 void SweepSpaces(); | 703 void SweepSpaces(); |
706 | 704 |
707 // Iterates through all live objects on a page using marking information. | |
708 // Returns whether all objects have successfully been visited. | |
709 bool IterateLiveObjectsOnPage(MemoryChunk* page, HeapObjectVisitor* visitor, | |
710 IterationMode mode); | |
711 | 705 |
712 void EvacuateNewSpace(); | 706 void EvacuateNewSpace(); |
713 | 707 |
714 void AddEvacuationSlotsBufferSynchronized( | 708 void AddEvacuationSlotsBufferSynchronized( |
715 SlotsBuffer* evacuation_slots_buffer); | 709 SlotsBuffer* evacuation_slots_buffer); |
716 | 710 |
717 void EvacuatePages(CompactionSpaceCollection* compaction_spaces, | 711 void EvacuatePages(CompactionSpaceCollection* compaction_spaces, |
718 SlotsBuffer** evacuation_slots_buffer); | 712 SlotsBuffer** evacuation_slots_buffer); |
719 | 713 |
720 void EvacuatePagesInParallel(); | 714 void EvacuatePagesInParallel(); |
721 | 715 |
722 // The number of parallel compaction tasks, including the main thread. | 716 // The number of parallel compaction tasks, including the main thread. |
723 int NumberOfParallelCompactionTasks(); | 717 int NumberOfParallelCompactionTasks(); |
724 | 718 |
725 | 719 |
726 void StartParallelCompaction(CompactionSpaceCollection** compaction_spaces, | 720 void StartParallelCompaction(CompactionSpaceCollection** compaction_spaces, |
727 uint32_t* task_ids, int len); | 721 uint32_t* task_ids, int len); |
728 void WaitUntilCompactionCompleted(uint32_t* task_ids, int len); | 722 void WaitUntilCompactionCompleted(uint32_t* task_ids, int len); |
729 | 723 |
730 void EvacuateNewSpaceAndCandidates(); | 724 void EvacuateNewSpaceAndCandidates(); |
731 | 725 |
732 void VisitLiveObjects(Page* page, ObjectVisitor* visitor); | 726 // Iterates through all live objects on a page using marking information. |
| 727 // Returns whether all objects have successfully been visited. |
| 728 bool VisitLiveObjects(MemoryChunk* page, HeapObjectVisitor* visitor, |
| 729 IterationMode mode); |
| 730 |
| 731 void VisitLiveObjectsBody(Page* page, ObjectVisitor* visitor); |
733 | 732 |
734 void SweepAbortedPages(); | 733 void SweepAbortedPages(); |
735 | 734 |
736 void ReleaseEvacuationCandidates(); | 735 void ReleaseEvacuationCandidates(); |
737 | 736 |
738 // Moves the pages of the evacuation_candidates_ list to the end of their | 737 // Moves the pages of the evacuation_candidates_ list to the end of their |
739 // corresponding space pages list. | 738 // corresponding space pages list. |
740 void MoveEvacuationCandidatesToEndOfPagesList(); | 739 void MoveEvacuationCandidatesToEndOfPagesList(); |
741 | 740 |
742 void SweepSpace(PagedSpace* space, SweeperType sweeper); | 741 void SweepSpace(PagedSpace* space, SweeperType sweeper); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 private: | 861 private: |
863 MarkCompactCollector* collector_; | 862 MarkCompactCollector* collector_; |
864 }; | 863 }; |
865 | 864 |
866 | 865 |
867 const char* AllocationSpaceName(AllocationSpace space); | 866 const char* AllocationSpaceName(AllocationSpace space); |
868 } // namespace internal | 867 } // namespace internal |
869 } // namespace v8 | 868 } // namespace v8 |
870 | 869 |
871 #endif // V8_HEAP_MARK_COMPACT_H_ | 870 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |