Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: src/heap/mark-compact.cc

Issue 1521573002: [heap] Remove SweeperType and clean up SweepSpace a bit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/mark-compact.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/heap/mark-compact.h" 5 #include "src/heap/mark-compact.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/base/sys-info.h" 9 #include "src/base/sys-info.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 3704 matching lines...) Expand 10 before | Expand all | Expand 10 after
3715 Sweep<SWEEP_ONLY, SWEEP_IN_PARALLEL, IGNORE_SKIP_LIST, 3715 Sweep<SWEEP_ONLY, SWEEP_IN_PARALLEL, IGNORE_SKIP_LIST,
3716 IGNORE_FREE_SPACE>(space, &private_free_list, page, NULL); 3716 IGNORE_FREE_SPACE>(space, &private_free_list, page, NULL);
3717 } 3717 }
3718 free_list->Concatenate(&private_free_list); 3718 free_list->Concatenate(&private_free_list);
3719 page->mutex()->Unlock(); 3719 page->mutex()->Unlock();
3720 } 3720 }
3721 return max_freed; 3721 return max_freed;
3722 } 3722 }
3723 3723
3724 3724
3725 void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { 3725 void MarkCompactCollector::StartSweepSpace(PagedSpace* space) {
3726 space->ClearStats(); 3726 space->ClearStats();
3727 3727
3728 // We defensively initialize end_of_unswept_pages_ here with the first page 3728 // We defensively initialize end_of_unswept_pages_ here with the first page
3729 // of the pages list. 3729 // of the pages list.
3730 space->set_end_of_unswept_pages(space->FirstPage()); 3730 space->set_end_of_unswept_pages(space->FirstPage());
3731 3731
3732 PageIterator it(space); 3732 PageIterator it(space);
3733 3733
3734 int pages_swept = 0; 3734 int pages_swept = 0;
3735 bool unused_page_present = false; 3735 bool unused_page_present = false;
(...skipping 10 matching lines...) Expand all
3746 p->IsEvacuationCandidate()) { 3746 p->IsEvacuationCandidate()) {
3747 // Will be processed in EvacuateNewSpaceAndCandidates. 3747 // Will be processed in EvacuateNewSpaceAndCandidates.
3748 DCHECK(evacuation_candidates_.length() > 0); 3748 DCHECK(evacuation_candidates_.length() > 0);
3749 continue; 3749 continue;
3750 } 3750 }
3751 3751
3752 // One unused page is kept, all further are released before sweeping them. 3752 // One unused page is kept, all further are released before sweeping them.
3753 if (p->LiveBytes() == 0) { 3753 if (p->LiveBytes() == 0) {
3754 if (unused_page_present) { 3754 if (unused_page_present) {
3755 if (FLAG_gc_verbose) { 3755 if (FLAG_gc_verbose) {
3756 PrintF("Sweeping 0x%" V8PRIxPTR " released page.\n", 3756 PrintIsolate(isolate(), "sweeping: released page: %p", p);
3757 reinterpret_cast<intptr_t>(p));
3758 } 3757 }
3759 space->ReleasePage(p); 3758 space->ReleasePage(p);
3760 continue; 3759 continue;
3761 } 3760 }
3762 unused_page_present = true; 3761 unused_page_present = true;
3763 } 3762 }
3764 3763
3765 switch (sweeper) { 3764 if (!parallel_sweeping_active) {
3766 case CONCURRENT_SWEEPING: 3765 if (FLAG_gc_verbose) {
3767 if (!parallel_sweeping_active) { 3766 PrintIsolate(isolate(), "sweeping: %p", p);
3768 if (FLAG_gc_verbose) { 3767 }
3769 PrintF("Sweeping 0x%" V8PRIxPTR ".\n", 3768 if (space->identity() == CODE_SPACE) {
3770 reinterpret_cast<intptr_t>(p)); 3769 if (FLAG_zap_code_space) {
3771 } 3770 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
3772 if (space->identity() == CODE_SPACE) { 3771 ZAP_FREE_SPACE>(space, NULL, p, NULL);
3773 if (FLAG_zap_code_space) {
3774 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
3775 ZAP_FREE_SPACE>(space, NULL, p, NULL);
3776 } else {
3777 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
3778 IGNORE_FREE_SPACE>(space, NULL, p, NULL);
3779 }
3780 } else {
3781 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST,
3782 IGNORE_FREE_SPACE>(space, NULL, p, NULL);
3783 }
3784 pages_swept++;
3785 parallel_sweeping_active = true;
3786 } else { 3772 } else {
3787 if (FLAG_gc_verbose) { 3773 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
3788 PrintF("Sweeping 0x%" V8PRIxPTR " in parallel.\n",
3789 reinterpret_cast<intptr_t>(p));
3790 }
3791 p->parallel_sweeping_state().SetValue(MemoryChunk::kSweepingPending);
3792 int to_sweep = p->area_size() - p->LiveBytes();
3793 space->accounting_stats_.ShrinkSpace(to_sweep);
3794 }
3795 space->set_end_of_unswept_pages(p);
3796 break;
3797 case SEQUENTIAL_SWEEPING: {
3798 if (FLAG_gc_verbose) {
3799 PrintF("Sweeping 0x%" V8PRIxPTR ".\n", reinterpret_cast<intptr_t>(p));
3800 }
3801 if (space->identity() == CODE_SPACE) {
3802 if (FLAG_zap_code_space) {
3803 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
3804 ZAP_FREE_SPACE>(space, NULL, p, NULL);
3805 } else {
3806 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, REBUILD_SKIP_LIST,
3807 IGNORE_FREE_SPACE>(space, NULL, p, NULL);
3808 }
3809 } else {
3810 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST,
3811 IGNORE_FREE_SPACE>(space, NULL, p, NULL); 3774 IGNORE_FREE_SPACE>(space, NULL, p, NULL);
3812 } 3775 }
3813 pages_swept++; 3776 } else {
3814 break; 3777 Sweep<SWEEP_ONLY, SWEEP_ON_MAIN_THREAD, IGNORE_SKIP_LIST,
3778 IGNORE_FREE_SPACE>(space, NULL, p, NULL);
3815 } 3779 }
3816 default: { UNREACHABLE(); } 3780 pages_swept++;
3781 parallel_sweeping_active = true;
3782 } else {
3783 if (FLAG_gc_verbose) {
3784 PrintIsolate(isolate(), "sweeping: initialized for parallel: %p", p);
3785 }
3786 p->parallel_sweeping_state().SetValue(MemoryChunk::kSweepingPending);
3787 int to_sweep = p->area_size() - p->LiveBytes();
3788 space->accounting_stats_.ShrinkSpace(to_sweep);
3817 } 3789 }
3790 space->set_end_of_unswept_pages(p);
3818 } 3791 }
3819 3792
3820 if (FLAG_gc_verbose) { 3793 if (FLAG_gc_verbose) {
3821 PrintF("SweepSpace: %s (%d pages swept)\n", 3794 PrintIsolate(isolate(), "sweeping: space=%s pages_swept=%d",
3822 AllocationSpaceName(space->identity()), pages_swept); 3795 AllocationSpaceName(space->identity()), pages_swept);
3823 } 3796 }
3824 } 3797 }
3825 3798
3826 3799
3827 void MarkCompactCollector::SweepSpaces() { 3800 void MarkCompactCollector::SweepSpaces() {
3828 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP); 3801 GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP);
3829 double start_time = 0.0; 3802 double start_time = 0.0;
3830 if (FLAG_print_cumulative_gc_stat) { 3803 if (FLAG_print_cumulative_gc_stat) {
3831 start_time = heap_->MonotonicallyIncreasingTimeInMs(); 3804 start_time = heap_->MonotonicallyIncreasingTimeInMs();
3832 } 3805 }
3833 3806
3834 #ifdef DEBUG 3807 #ifdef DEBUG
3835 state_ = SWEEP_SPACES; 3808 state_ = SWEEP_SPACES;
3836 #endif 3809 #endif
3837 3810
3838 MoveEvacuationCandidatesToEndOfPagesList(); 3811 MoveEvacuationCandidatesToEndOfPagesList();
3839 3812
3840 { 3813 {
3841 { 3814 {
3842 GCTracer::Scope sweep_scope(heap()->tracer(), 3815 GCTracer::Scope sweep_scope(heap()->tracer(),
3843 GCTracer::Scope::MC_SWEEP_OLD); 3816 GCTracer::Scope::MC_SWEEP_OLD);
3844 SweepSpace(heap()->old_space(), CONCURRENT_SWEEPING); 3817 StartSweepSpace(heap()->old_space());
3845 } 3818 }
3846 { 3819 {
3847 GCTracer::Scope sweep_scope(heap()->tracer(), 3820 GCTracer::Scope sweep_scope(heap()->tracer(),
3848 GCTracer::Scope::MC_SWEEP_CODE); 3821 GCTracer::Scope::MC_SWEEP_CODE);
3849 SweepSpace(heap()->code_space(), CONCURRENT_SWEEPING); 3822 StartSweepSpace(heap()->code_space());
3850 } 3823 }
3851 { 3824 {
3852 GCTracer::Scope sweep_scope(heap()->tracer(), 3825 GCTracer::Scope sweep_scope(heap()->tracer(),
3853 GCTracer::Scope::MC_SWEEP_MAP); 3826 GCTracer::Scope::MC_SWEEP_MAP);
3854 SweepSpace(heap()->map_space(), CONCURRENT_SWEEPING); 3827 StartSweepSpace(heap()->map_space());
3855 } 3828 }
3856 sweeping_in_progress_ = true; 3829 sweeping_in_progress_ = true;
3857 if (FLAG_concurrent_sweeping) { 3830 if (FLAG_concurrent_sweeping) {
3858 StartSweeperThreads(); 3831 StartSweeperThreads();
3859 } 3832 }
3860 } 3833 }
3861 3834
3862 // Deallocate unmarked large objects. 3835 // Deallocate unmarked large objects.
3863 heap_->lo_space()->FreeUnmarkedObjects(); 3836 heap_->lo_space()->FreeUnmarkedObjects();
3864 3837
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3961 MarkBit mark_bit = Marking::MarkBitFrom(host); 3934 MarkBit mark_bit = Marking::MarkBitFrom(host);
3962 if (Marking::IsBlack(mark_bit)) { 3935 if (Marking::IsBlack(mark_bit)) {
3963 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 3936 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
3964 RecordRelocSlot(&rinfo, target); 3937 RecordRelocSlot(&rinfo, target);
3965 } 3938 }
3966 } 3939 }
3967 } 3940 }
3968 3941
3969 } // namespace internal 3942 } // namespace internal
3970 } // namespace v8 3943 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698