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

Unified Diff: src/heap/mark-compact.cc

Issue 1244353002: Use a lock in pages to synchronize sweeper threads to allow others to wait on concurrently swept pa… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/heap/spaces.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index c34d12c0f2d92d107083135ebb15a5944eb36a42..92608521e9e502a82f202aec7bf18dcd300c1819 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -4163,12 +4163,19 @@ int MarkCompactCollector::SweepInParallel(PagedSpace* space,
int MarkCompactCollector::SweepInParallel(Page* page, PagedSpace* space) {
int max_freed = 0;
- if (page->TryParallelSweeping()) {
+ if (page->TryLock()) {
+ // If this page was already swept in the meantime, we can return here.
+ if (page->parallel_sweeping() != MemoryChunk::SWEEPING_PENDING) {
+ page->mutex()->Unlock();
+ return 0;
+ }
+ page->set_parallel_sweeping(MemoryChunk::SWEEPING_IN_PROGRESS);
FreeList* free_list = free_list_old_space_.get();
FreeList private_free_list(space);
max_freed = Sweep<SWEEP_ONLY, SWEEP_IN_PARALLEL, IGNORE_SKIP_LIST,
IGNORE_FREE_SPACE>(space, &private_free_list, page, NULL);
free_list->Concatenate(&private_free_list);
+ page->mutex()->Unlock();
}
return max_freed;
}
« no previous file with comments | « no previous file | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698