From: hpayer Date: Wed, 5 Aug 2015 13:11:29 +0000 (-0700) Subject: Sweep map space concurrently. X-Git-Tag: upstream/4.7.83~1013 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e52e66591e4d661f0cb740bd56c8c2fbdbbd165;p=platform%2Fupstream%2Fv8.git Sweep map space concurrently. BUG=chromium:507211 LOG=n Review URL: https://codereview.chromium.org/1226773003 Cr-Commit-Position: refs/heads/master@{#30027} --- diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 84e18d0..ec2e18e 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -227,6 +227,7 @@ static void VerifyEvacuation(Heap* heap) { void MarkCompactCollector::SetUp() { free_list_old_space_.Reset(new FreeList(heap_->old_space())); free_list_code_space_.Reset(new FreeList(heap_->code_space())); + free_list_map_space_.Reset(new FreeList(heap_->map_space())); EnsureMarkingDequeIsReserved(); EnsureMarkingDequeIsCommitted(kMinMarkingDequeSize); } @@ -496,12 +497,16 @@ class MarkCompactCollector::SweeperTask : public v8::Task { void MarkCompactCollector::StartSweeperThreads() { DCHECK(free_list_old_space_.get()->IsEmpty()); DCHECK(free_list_code_space_.get()->IsEmpty()); + DCHECK(free_list_map_space_.get()->IsEmpty()); V8::GetCurrentPlatform()->CallOnBackgroundThread( new SweeperTask(heap(), heap()->old_space()), v8::Platform::kShortRunningTask); V8::GetCurrentPlatform()->CallOnBackgroundThread( new SweeperTask(heap(), heap()->code_space()), v8::Platform::kShortRunningTask); + V8::GetCurrentPlatform()->CallOnBackgroundThread( + new SweeperTask(heap(), heap()->map_space()), + v8::Platform::kShortRunningTask); } @@ -527,18 +532,22 @@ void MarkCompactCollector::EnsureSweepingCompleted() { if (!heap()->concurrent_sweeping_enabled() || !IsSweepingCompleted()) { SweepInParallel(heap()->paged_space(OLD_SPACE), 0); SweepInParallel(heap()->paged_space(CODE_SPACE), 0); + SweepInParallel(heap()->paged_space(MAP_SPACE), 0); } // Wait twice for both jobs. if (heap()->concurrent_sweeping_enabled()) { pending_sweeper_jobs_semaphore_.Wait(); pending_sweeper_jobs_semaphore_.Wait(); + pending_sweeper_jobs_semaphore_.Wait(); } ParallelSweepSpacesComplete(); sweeping_in_progress_ = false; RefillFreeList(heap()->paged_space(OLD_SPACE)); RefillFreeList(heap()->paged_space(CODE_SPACE)); + RefillFreeList(heap()->paged_space(MAP_SPACE)); heap()->paged_space(OLD_SPACE)->ResetUnsweptFreeBytes(); heap()->paged_space(CODE_SPACE)->ResetUnsweptFreeBytes(); + heap()->paged_space(MAP_SPACE)->ResetUnsweptFreeBytes(); #ifdef VERIFY_HEAP if (FLAG_verify_heap && !evacuation()) { @@ -565,6 +574,8 @@ void MarkCompactCollector::RefillFreeList(PagedSpace* space) { free_list = free_list_old_space_.get(); } else if (space == heap()->code_space()) { free_list = free_list_code_space_.get(); + } else if (space == heap()->map_space()) { + free_list = free_list_map_space_.get(); } else { // Any PagedSpace might invoke RefillFreeLists, so we need to make sure // to only refill them for the old space. @@ -4235,13 +4246,18 @@ int MarkCompactCollector::SweepInParallel(Page* page, PagedSpace* space) { page->set_parallel_sweeping(MemoryChunk::SWEEPING_IN_PROGRESS); FreeList* free_list; FreeList private_free_list(space); - if (space->identity() == CODE_SPACE) { + if (space->identity() == OLD_SPACE) { + free_list = free_list_old_space_.get(); + max_freed = + Sweep(space, &private_free_list, page, NULL); + } else if (space->identity() == CODE_SPACE) { free_list = free_list_code_space_.get(); max_freed = Sweep(space, &private_free_list, page, NULL); } else { - free_list = free_list_old_space_.get(); + free_list = free_list_map_space_.get(); max_freed = Sweep(space, &private_free_list, page, NULL); @@ -4312,7 +4328,6 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { IGNORE_FREE_SPACE>(space, NULL, p, NULL); } } else { - DCHECK(space->identity() == OLD_SPACE); Sweep(space, NULL, p, NULL); } @@ -4341,8 +4356,6 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) { IGNORE_FREE_SPACE>(space, NULL, p, NULL); } } else { - DCHECK(space->identity() == OLD_SPACE || - space->identity() == MAP_SPACE); Sweep(space, NULL, p, NULL); } @@ -4392,7 +4405,11 @@ void MarkCompactCollector::SweepSpaces() { GCTracer::Scope::MC_SWEEP_CODE); SweepSpace(heap()->code_space(), CONCURRENT_SWEEPING); } - + { + GCTracer::Scope sweep_scope(heap()->tracer(), + GCTracer::Scope::MC_SWEEP_MAP); + SweepSpace(heap()->map_space(), CONCURRENT_SWEEPING); + } sweeping_in_progress_ = true; if (heap()->concurrent_sweeping_enabled()) { StartSweeperThreads(); @@ -4405,15 +4422,6 @@ void MarkCompactCollector::SweepSpaces() { heap()->FreeDeadArrayBuffers(false); - // ClearNonLiveReferences depends on precise sweeping of map space to - // detect whether unmarked map became dead in this collection or in one - // of the previous ones. - { - GCTracer::Scope sweep_scope(heap()->tracer(), - GCTracer::Scope::MC_SWEEP_MAP); - SweepSpace(heap()->map_space(), SEQUENTIAL_SWEEPING); - } - // Deallocate unmarked objects and clear marked bits for marked objects. heap_->lo_space()->FreeUnmarkedObjects(); @@ -4453,6 +4461,7 @@ void MarkCompactCollector::ParallelSweepSpaceComplete(PagedSpace* space) { void MarkCompactCollector::ParallelSweepSpacesComplete() { ParallelSweepSpaceComplete(heap()->old_space()); ParallelSweepSpaceComplete(heap()->code_space()); + ParallelSweepSpaceComplete(heap()->map_space()); } diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h index 938adc6..d78e9bd 100644 --- a/src/heap/mark-compact.h +++ b/src/heap/mark-compact.h @@ -977,6 +977,7 @@ class MarkCompactCollector { base::SmartPointer free_list_old_space_; base::SmartPointer free_list_code_space_; + base::SmartPointer free_list_map_space_; friend class Heap; };