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

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

Issue 2049063004: Reland of "heap] Fix Sweeper::IsSweepingCompleted" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | « src/heap/mark-compact.h ('k') | 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 48d66ac2f2f1c2f3e092e4ce3e4269049bb77d65..a1736e9728a13ef05dff6e0c7da218d26cf271ca 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -508,7 +508,7 @@ void MarkCompactCollector::Sweeper::StartSweeping() {
void MarkCompactCollector::Sweeper::StartSweepingHelper(
AllocationSpace space_to_start) {
- num_sweeping_tasks_++;
+ num_sweeping_tasks_.Increment(1);
V8::GetCurrentPlatform()->CallOnBackgroundThread(
new SweeperTask(this, &pending_sweeper_tasks_semaphore_, space_to_start),
v8::Platform::kShortRunningTask);
@@ -555,9 +555,9 @@ void MarkCompactCollector::Sweeper::EnsureCompleted() {
}
if (FLAG_concurrent_sweeping) {
- while (num_sweeping_tasks_ > 0) {
+ while (num_sweeping_tasks_.Value() > 0) {
pending_sweeper_tasks_semaphore_.Wait();
- num_sweeping_tasks_--;
+ num_sweeping_tasks_.Increment(-1);
}
}
@@ -583,12 +583,11 @@ void MarkCompactCollector::EnsureSweepingCompleted() {
}
bool MarkCompactCollector::Sweeper::IsSweepingCompleted() {
- if (!pending_sweeper_tasks_semaphore_.WaitFor(
- base::TimeDelta::FromSeconds(0))) {
- return false;
+ while (pending_sweeper_tasks_semaphore_.WaitFor(
+ base::TimeDelta::FromSeconds(0))) {
+ num_sweeping_tasks_.Increment(-1);
}
- pending_sweeper_tasks_semaphore_.Signal();
- return true;
+ return num_sweeping_tasks_.Value() == 0;
}
void Marking::TransferMark(Heap* heap, Address old_start, Address new_start) {
« 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