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

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

Issue 2484153004: [heap] Ensure that the sweeper does not lose unswept pages. (Closed)
Patch Set: address comment Created 4 years, 1 month 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 | no next file » | 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 ce7d8782a8601c1a9f8be61b04f51631f173f8f2..1bfc15da4ea66d70bf0dcbb49d6a5f01728bef7a 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -3741,12 +3741,12 @@ int MarkCompactCollector::Sweeper::ParallelSweepSpace(AllocationSpace identity,
int MarkCompactCollector::Sweeper::ParallelSweepPage(Page* page,
AllocationSpace identity) {
int max_freed = 0;
- if (page->mutex()->TryLock()) {
+ {
+ base::LockGuard<base::Mutex> guard(page->mutex());
// If this page was already swept in the meantime, we can return here.
- if (page->concurrent_sweeping_state().Value() != Page::kSweepingPending) {
- page->mutex()->Unlock();
- return 0;
- }
+ if (page->SweepingDone()) return 0;
+ DCHECK_EQ(Page::kSweepingPending,
+ page->concurrent_sweeping_state().Value());
page->concurrent_sweeping_state().SetValue(Page::kSweepingInProgress);
const Sweeper::FreeSpaceTreatmentMode free_space_mode =
Heap::ShouldZapGarbage() ? ZAP_FREE_SPACE : IGNORE_FREE_SPACE;
@@ -3755,6 +3755,7 @@ int MarkCompactCollector::Sweeper::ParallelSweepPage(Page* page,
} else {
max_freed = RawSweep(page, REBUILD_FREE_LIST, free_space_mode);
}
+ DCHECK(page->SweepingDone());
// After finishing sweeping of a page we clean up its remembered set.
if (page->typed_old_to_new_slots()) {
@@ -3763,13 +3764,11 @@ int MarkCompactCollector::Sweeper::ParallelSweepPage(Page* page,
if (page->old_to_new_slots()) {
page->old_to_new_slots()->FreeToBeFreedBuckets();
}
+ }
- {
- base::LockGuard<base::Mutex> guard(&mutex_);
- swept_list_[identity].Add(page);
- }
- page->concurrent_sweeping_state().SetValue(Page::kSweepingDone);
- page->mutex()->Unlock();
+ {
+ base::LockGuard<base::Mutex> guard(&mutex_);
+ swept_list_[identity].Add(page);
}
return max_freed;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698