| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 bool is_compacting() const { return compacting_; } | 415 bool is_compacting() const { return compacting_; } |
| 416 | 416 |
| 417 MarkingParity marking_parity() { return marking_parity_; } | 417 MarkingParity marking_parity() { return marking_parity_; } |
| 418 | 418 |
| 419 // Concurrent and parallel sweeping support. If required_freed_bytes was set | 419 // Concurrent and parallel sweeping support. If required_freed_bytes was set |
| 420 // to a value larger than 0, then sweeping returns after a block of at least | 420 // to a value larger than 0, then sweeping returns after a block of at least |
| 421 // required_freed_bytes was freed. If required_freed_bytes was set to zero | 421 // required_freed_bytes was freed. If required_freed_bytes was set to zero |
| 422 // then the whole given space is swept. It returns the size of the maximum | 422 // then the whole given space is swept. It returns the size of the maximum |
| 423 // continuous freed memory chunk. | 423 // continuous freed memory chunk. |
| 424 int SweepInParallel(PagedSpace* space, int required_freed_bytes); | 424 int SweepInParallel(PagedSpace* space, int required_freed_bytes, |
| 425 int max_pages = 0); |
| 425 | 426 |
| 426 // Sweeps a given page concurrently to the sweeper threads. It returns the | 427 // Sweeps a given page concurrently to the sweeper threads. It returns the |
| 427 // size of the maximum continuous freed memory chunk. | 428 // size of the maximum continuous freed memory chunk. |
| 428 int SweepInParallel(Page* page, PagedSpace* space); | 429 int SweepInParallel(Page* page, PagedSpace* space); |
| 429 | 430 |
| 430 // Ensures that sweeping is finished. | 431 // Ensures that sweeping is finished. |
| 431 // | 432 // |
| 432 // Note: Can only be called safely from main thread. | 433 // Note: Can only be called safely from main thread. |
| 433 void EnsureSweepingCompleted(); | 434 void EnsureSweepingCompleted(); |
| 434 | 435 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 } | 505 } |
| 505 | 506 |
| 506 private: | 507 private: |
| 507 class CompactionTask; | 508 class CompactionTask; |
| 508 class EvacuateNewSpaceVisitor; | 509 class EvacuateNewSpaceVisitor; |
| 509 class EvacuateOldSpaceVisitor; | 510 class EvacuateOldSpaceVisitor; |
| 510 class EvacuateVisitorBase; | 511 class EvacuateVisitorBase; |
| 511 class HeapObjectVisitor; | 512 class HeapObjectVisitor; |
| 512 class SweeperTask; | 513 class SweeperTask; |
| 513 | 514 |
| 515 typedef std::vector<Page*> SweepingList; |
| 516 |
| 514 static const int kInitialLocalPretenuringFeedbackCapacity = 256; | 517 static const int kInitialLocalPretenuringFeedbackCapacity = 256; |
| 515 | 518 |
| 516 explicit MarkCompactCollector(Heap* heap); | 519 explicit MarkCompactCollector(Heap* heap); |
| 517 | 520 |
| 518 bool WillBeDeoptimized(Code* code); | 521 bool WillBeDeoptimized(Code* code); |
| 519 void EvictPopularEvacuationCandidate(Page* page); | 522 void EvictPopularEvacuationCandidate(Page* page); |
| 520 void ClearInvalidStoreAndSlotsBufferEntries(); | 523 void ClearInvalidStoreAndSlotsBufferEntries(); |
| 521 | 524 |
| 522 void StartSweeperThreads(); | 525 void StartSweeperThreads(); |
| 523 | 526 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 // Phase 2: Sweeping to clear mark bits and free non-live objects for | 689 // Phase 2: Sweeping to clear mark bits and free non-live objects for |
| 687 // a non-compacting collection. | 690 // a non-compacting collection. |
| 688 // | 691 // |
| 689 // Before: Live objects are marked and non-live objects are unmarked. | 692 // Before: Live objects are marked and non-live objects are unmarked. |
| 690 // | 693 // |
| 691 // After: Live objects are unmarked, non-live regions have been added to | 694 // After: Live objects are unmarked, non-live regions have been added to |
| 692 // their space's free list. Active eden semispace is compacted by | 695 // their space's free list. Active eden semispace is compacted by |
| 693 // evacuation. | 696 // evacuation. |
| 694 // | 697 // |
| 695 | 698 |
| 699 inline SweepingList& sweeping_list(Space* space); |
| 700 |
| 696 // 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 |
| 697 // for the large object space, clearing mark bits and adding unmarked | 702 // for the large object space, clearing mark bits and adding unmarked |
| 698 // regions to each space's free list. | 703 // regions to each space's free list. |
| 699 void SweepSpaces(); | 704 void SweepSpaces(); |
| 700 | 705 |
| 701 void EvacuateNewSpacePrologue(); | 706 void EvacuateNewSpacePrologue(); |
| 702 | 707 |
| 703 // Returns local pretenuring feedback. | 708 // Returns local pretenuring feedback. |
| 704 HashMap* EvacuateNewSpaceInParallel(); | 709 HashMap* EvacuateNewSpaceInParallel(); |
| 705 | 710 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 729 IterationMode mode); | 734 IterationMode mode); |
| 730 | 735 |
| 731 void VisitLiveObjectsBody(Page* page, ObjectVisitor* visitor); | 736 void VisitLiveObjectsBody(Page* page, ObjectVisitor* visitor); |
| 732 | 737 |
| 733 void RecomputeLiveBytes(MemoryChunk* page); | 738 void RecomputeLiveBytes(MemoryChunk* page); |
| 734 | 739 |
| 735 void SweepAbortedPages(); | 740 void SweepAbortedPages(); |
| 736 | 741 |
| 737 void ReleaseEvacuationCandidates(); | 742 void ReleaseEvacuationCandidates(); |
| 738 | 743 |
| 739 // Moves the pages of the evacuation_candidates_ list to the end of their | |
| 740 // corresponding space pages list. | |
| 741 void MoveEvacuationCandidatesToEndOfPagesList(); | |
| 742 | |
| 743 // Starts sweeping of a space by contributing on the main thread and setting | 744 // Starts sweeping of a space by contributing on the main thread and setting |
| 744 // up other pages for sweeping. | 745 // up other pages for sweeping. |
| 745 void StartSweepSpace(PagedSpace* space); | 746 void StartSweepSpace(PagedSpace* space); |
| 746 | 747 |
| 747 // Finalizes the parallel sweeping phase. Marks all the pages that were | 748 // Finalizes the parallel sweeping phase. Marks all the pages that were |
| 748 // swept in parallel. | 749 // swept in parallel. |
| 749 void ParallelSweepSpacesComplete(); | 750 void ParallelSweepSpacesComplete(); |
| 750 | 751 |
| 751 void ParallelSweepSpaceComplete(PagedSpace* space); | 752 void ParallelSweepSpaceComplete(PagedSpace* space); |
| 752 | 753 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 // AddEvacuationSlotsbufferSynchronized to adds its slots buffer to the | 787 // AddEvacuationSlotsbufferSynchronized to adds its slots buffer to the |
| 787 // evacuation_slots_buffers_ list using the evacuation_slots_buffers_mutex_ | 788 // evacuation_slots_buffers_ list using the evacuation_slots_buffers_mutex_ |
| 788 // lock. | 789 // lock. |
| 789 base::Mutex evacuation_slots_buffers_mutex_; | 790 base::Mutex evacuation_slots_buffers_mutex_; |
| 790 List<SlotsBuffer*> evacuation_slots_buffers_; | 791 List<SlotsBuffer*> evacuation_slots_buffers_; |
| 791 | 792 |
| 792 base::SmartPointer<FreeList> free_list_old_space_; | 793 base::SmartPointer<FreeList> free_list_old_space_; |
| 793 base::SmartPointer<FreeList> free_list_code_space_; | 794 base::SmartPointer<FreeList> free_list_code_space_; |
| 794 base::SmartPointer<FreeList> free_list_map_space_; | 795 base::SmartPointer<FreeList> free_list_map_space_; |
| 795 | 796 |
| 797 SweepingList sweeping_list_old_space_; |
| 798 SweepingList sweeping_list_code_space_; |
| 799 SweepingList sweeping_list_map_space_; |
| 800 |
| 796 // True if we are collecting slots to perform evacuation from evacuation | 801 // True if we are collecting slots to perform evacuation from evacuation |
| 797 // candidates. | 802 // candidates. |
| 798 bool compacting_; | 803 bool compacting_; |
| 799 | 804 |
| 800 // True if concurrent or parallel sweeping is currently in progress. | 805 // True if concurrent or parallel sweeping is currently in progress. |
| 801 bool sweeping_in_progress_; | 806 bool sweeping_in_progress_; |
| 802 | 807 |
| 803 // True if parallel compaction is currently in progress. | 808 // True if parallel compaction is currently in progress. |
| 804 bool compaction_in_progress_; | 809 bool compaction_in_progress_; |
| 805 | 810 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 private: | 900 private: |
| 896 MarkCompactCollector* collector_; | 901 MarkCompactCollector* collector_; |
| 897 }; | 902 }; |
| 898 | 903 |
| 899 | 904 |
| 900 const char* AllocationSpaceName(AllocationSpace space); | 905 const char* AllocationSpaceName(AllocationSpace space); |
| 901 } // namespace internal | 906 } // namespace internal |
| 902 } // namespace v8 | 907 } // namespace v8 |
| 903 | 908 |
| 904 #endif // V8_HEAP_MARK_COMPACT_H_ | 909 #endif // V8_HEAP_MARK_COMPACT_H_ |
| OLD | NEW |