Commit 486e641c authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Fix Barrier used in Scavenger

The barrier assumed that the number of tasks is fixed. However, we
cannot rely on that because other tasks might take up threads. In the
ein thend this would result in the Scavenge task being (rightfully)
cancelled.

The barrier now assumes no tasks in the beginning and relies on the fact
that reaching the barrier means that no global work is left. Tasks that
lag behing will just observe the barrier being in its end state.

Bug: chromium:738865
Change-Id: I4d47e8ec4b9cf7c615b3d9585e4a6bb9d271d409
Reviewed-on: https://chromium-review.googlesource.com/582947Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46842}
parent 134cc94e
......@@ -1813,6 +1813,7 @@ class ScavengingTask final : public ItemParallelJob::Task {
void RunInParallel() final {
double scavenging_time = 0.0;
{
barrier_->Start();
TimedScope scope(&scavenging_time);
ScavengingItem* item = nullptr;
while ((item = GetItem<ScavengingItem>()) != nullptr) {
......@@ -1922,7 +1923,7 @@ void Heap::Scavenge() {
const bool is_logging = IsLogging(isolate());
const bool is_incremental_marking = incremental_marking()->IsMarking();
const int num_scavenge_tasks = NumberOfScavengeTasks();
Scavenger::Barrier barrier(num_scavenge_tasks);
Scavenger::Barrier barrier;
CopiedList copied_list(num_scavenge_tasks);
PromotionList promotion_list(num_scavenge_tasks);
for (int i = 0; i < num_scavenge_tasks; i++) {
......
......@@ -26,7 +26,12 @@ class Scavenger {
public:
class Barrier {
public:
explicit Barrier(int tasks) : tasks_(tasks), waiting_(0), done_(false) {}
Barrier() : tasks_(0), waiting_(0), done_(false) {}
void Start() {
base::LockGuard<base::Mutex> guard(&mutex_);
tasks_++;
}
void NotifyAll() {
base::LockGuard<base::Mutex> guard(&mutex_);
......
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