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 <deque> | 8 #include <deque> |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 class MarkCompactCollector { | 401 class MarkCompactCollector { |
402 public: | 402 public: |
403 class Evacuator; | 403 class Evacuator; |
404 | 404 |
405 class Sweeper { | 405 class Sweeper { |
406 public: | 406 public: |
407 class SweeperTask; | 407 class SweeperTask; |
408 | 408 |
409 enum SweepingMode { SWEEP_ONLY, SWEEP_AND_VISIT_LIVE_OBJECTS }; | 409 enum SweepingMode { SWEEP_ONLY, SWEEP_AND_VISIT_LIVE_OBJECTS }; |
410 enum SkipListRebuildingMode { REBUILD_SKIP_LIST, IGNORE_SKIP_LIST }; | 410 enum SkipListRebuildingMode { REBUILD_SKIP_LIST, IGNORE_SKIP_LIST }; |
411 enum FreeListRebuildingMode { REBUILD_FREE_LIST, IGNORE_FREE_LIST }; | |
412 enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE }; | 411 enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE }; |
413 enum SweepingParallelism { SWEEP_ON_MAIN_THREAD, SWEEP_IN_PARALLEL }; | 412 enum SweepingParallelism { SWEEP_ON_MAIN_THREAD, SWEEP_IN_PARALLEL }; |
414 | 413 |
415 typedef std::deque<Page*> SweepingList; | 414 typedef std::deque<Page*> SweepingList; |
416 typedef List<Page*> SweptList; | 415 typedef List<Page*> SweptList; |
417 | 416 |
418 template <SweepingMode sweeping_mode, SweepingParallelism parallelism, | 417 template <SweepingMode sweeping_mode, SweepingParallelism parallelism, |
419 SkipListRebuildingMode skip_list_mode, | 418 SkipListRebuildingMode skip_list_mode, |
420 FreeListRebuildingMode free_list_mode, | |
421 FreeSpaceTreatmentMode free_space_mode> | 419 FreeSpaceTreatmentMode free_space_mode> |
422 static int RawSweep(PagedSpace* space, Page* p, ObjectVisitor* v); | 420 static int RawSweep(PagedSpace* space, Page* p, ObjectVisitor* v); |
423 | 421 |
424 explicit Sweeper(Heap* heap) | 422 explicit Sweeper(Heap* heap) |
425 : heap_(heap), | 423 : heap_(heap), |
426 pending_sweeper_tasks_semaphore_(0), | 424 pending_sweeper_tasks_semaphore_(0), |
427 sweeping_in_progress_(false), | 425 sweeping_in_progress_(false), |
428 late_pages_(false), | 426 late_pages_(false), |
429 num_sweeping_tasks_(0) {} | 427 num_sweeping_tasks_(0) {} |
430 | 428 |
431 bool sweeping_in_progress() { return sweeping_in_progress_; } | 429 bool sweeping_in_progress() { return sweeping_in_progress_; } |
432 bool contains_late_pages() { return late_pages_; } | 430 bool contains_late_pages() { return late_pages_; } |
433 | 431 |
434 void AddPage(AllocationSpace space, Page* page); | 432 void AddPage(AllocationSpace space, Page* page); |
435 void AddLatePage(AllocationSpace space, Page* page); | 433 void AddLatePage(AllocationSpace space, Page* page); |
436 | 434 |
437 int ParallelSweepSpace(AllocationSpace identity, int required_freed_bytes, | 435 int ParallelSweepSpace(AllocationSpace identity, int required_freed_bytes, |
438 int max_pages = 0); | 436 int max_pages = 0); |
439 int ParallelSweepPage(Page* page, AllocationSpace identity); | 437 int ParallelSweepPage(Page* page, PagedSpace* space); |
440 | 438 |
441 void StartSweeping(); | 439 void StartSweeping(); |
442 void StartSweepingHelper(AllocationSpace space_to_start); | 440 void StartSweepingHelper(AllocationSpace space_to_start); |
443 void EnsureCompleted(); | 441 void EnsureCompleted(); |
444 void EnsureNewSpaceCompleted(); | |
445 bool IsSweepingCompleted(); | 442 bool IsSweepingCompleted(); |
446 void SweepOrWaitUntilSweepingCompleted(Page* page); | 443 void SweepOrWaitUntilSweepingCompleted(Page* page); |
447 | 444 |
448 void AddSweptPageSafe(PagedSpace* space, Page* page); | 445 void AddSweptPageSafe(PagedSpace* space, Page* page); |
449 Page* GetSweptPageSafe(PagedSpace* space); | 446 Page* GetSweptPageSafe(PagedSpace* space); |
450 | 447 |
451 private: | 448 private: |
452 static const int kAllocationSpaces = LAST_PAGED_SPACE + 1; | 449 static const int kAllocationSpaces = LAST_PAGED_SPACE + 1; |
453 | 450 |
454 template <typename Callback> | 451 template <typename Callback> |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // their space's free list. Active eden semispace is compacted by | 784 // their space's free list. Active eden semispace is compacted by |
788 // evacuation. | 785 // evacuation. |
789 // | 786 // |
790 | 787 |
791 // If we are not compacting the heap, we simply sweep the spaces except | 788 // If we are not compacting the heap, we simply sweep the spaces except |
792 // for the large object space, clearing mark bits and adding unmarked | 789 // for the large object space, clearing mark bits and adding unmarked |
793 // regions to each space's free list. | 790 // regions to each space's free list. |
794 void SweepSpaces(); | 791 void SweepSpaces(); |
795 | 792 |
796 void EvacuateNewSpacePrologue(); | 793 void EvacuateNewSpacePrologue(); |
| 794 void EvacuateNewSpaceEpilogue(); |
797 | 795 |
798 void EvacuatePagesInParallel(); | 796 void EvacuatePagesInParallel(); |
799 | 797 |
800 // The number of parallel compaction tasks, including the main thread. | 798 // The number of parallel compaction tasks, including the main thread. |
801 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes); | 799 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes); |
802 | 800 |
803 void EvacuateNewSpaceAndCandidates(); | 801 void EvacuateNewSpaceAndCandidates(); |
804 | 802 |
805 void UpdatePointersAfterEvacuation(); | 803 void UpdatePointersAfterEvacuation(); |
806 | 804 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 private: | 890 private: |
893 MarkCompactCollector* collector_; | 891 MarkCompactCollector* collector_; |
894 }; | 892 }; |
895 | 893 |
896 | 894 |
897 const char* AllocationSpaceName(AllocationSpace space); | 895 const char* AllocationSpaceName(AllocationSpace space); |
898 } // namespace internal | 896 } // namespace internal |
899 } // namespace v8 | 897 } // namespace v8 |
900 | 898 |
901 #endif // V8_HEAP_MARK_COMPACT_H_ | 899 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |