Commit f4e4fd71 authored by mlippautz's avatar mlippautz Committed by Commit bot

Reland of "heap] Fix Sweeper::IsSweepingCompleted"

This reverts commit 0bccf3e6.

R=ulan@chromium.org

Review-Url: https://codereview.chromium.org/2049063004
Cr-Commit-Position: refs/heads/master@{#36851}
parent 0bccf3e6
......@@ -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) {
......
......@@ -467,7 +467,7 @@ class MarkCompactCollector {
SweepingList sweeping_list_[kAllocationSpaces];
bool sweeping_in_progress_;
bool late_pages_;
int num_sweeping_tasks_;
base::AtomicNumber<intptr_t> num_sweeping_tasks_;
};
enum IterationMode {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment