| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 // AddEvacuationSlotsbufferSynchronized to adds its slots buffer to the | 791 // AddEvacuationSlotsbufferSynchronized to adds its slots buffer to the |
| 787 // evacuation_slots_buffers_ list using the evacuation_slots_buffers_mutex_ | 792 // evacuation_slots_buffers_ list using the evacuation_slots_buffers_mutex_ |
| 788 // lock. | 793 // lock. |
| 789 base::Mutex evacuation_slots_buffers_mutex_; | 794 base::Mutex evacuation_slots_buffers_mutex_; |
| 790 List<SlotsBuffer*> evacuation_slots_buffers_; | 795 List<SlotsBuffer*> evacuation_slots_buffers_; |
| 791 | 796 |
| 792 base::SmartPointer<FreeList> free_list_old_space_; | 797 base::SmartPointer<FreeList> free_list_old_space_; |
| 793 base::SmartPointer<FreeList> free_list_code_space_; | 798 base::SmartPointer<FreeList> free_list_code_space_; |
| 794 base::SmartPointer<FreeList> free_list_map_space_; | 799 base::SmartPointer<FreeList> free_list_map_space_; |
| 795 | 800 |
| 801 SweepingList sweeping_list_old_space_; |
| 802 SweepingList sweeping_list_code_space_; |
| 803 SweepingList sweeping_list_map_space_; |
| 804 |
| 796 // True if we are collecting slots to perform evacuation from evacuation | 805 // True if we are collecting slots to perform evacuation from evacuation |
| 797 // candidates. | 806 // candidates. |
| 798 bool compacting_; | 807 bool compacting_; |
| 799 | 808 |
| 800 // True if concurrent or parallel sweeping is currently in progress. | 809 // True if concurrent or parallel sweeping is currently in progress. |
| 801 bool sweeping_in_progress_; | 810 bool sweeping_in_progress_; |
| 802 | 811 |
| 803 // True if parallel compaction is currently in progress. | 812 // True if parallel compaction is currently in progress. |
| 804 bool compaction_in_progress_; | 813 bool compaction_in_progress_; |
| 805 | 814 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 private: | 904 private: |
| 896 MarkCompactCollector* collector_; | 905 MarkCompactCollector* collector_; |
| 897 }; | 906 }; |
| 898 | 907 |
| 899 | 908 |
| 900 const char* AllocationSpaceName(AllocationSpace space); | 909 const char* AllocationSpaceName(AllocationSpace space); |
| 901 } // namespace internal | 910 } // namespace internal |
| 902 } // namespace v8 | 911 } // namespace v8 |
| 903 | 912 |
| 904 #endif // V8_HEAP_MARK_COMPACT_H_ | 913 #endif // V8_HEAP_MARK_COMPACT_H_ |
| OLD | NEW |