Commit f152f832 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Fix dead-lock between scavenger and sweeper

The deadlock can happen when two scavenging tasks process two different
pages for their old->new sets and at the same time try to allocate in
old space which triggers sweeping of the other task's page.

Bug: v8:6754
Change-Id: I6087553631e198d5ecfb8ab37925ac41cd6995bd
Reviewed-on: https://chromium-review.googlesource.com/635843
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47610}
parent c7a7bf6a
......@@ -3168,13 +3168,16 @@ HeapObject* PagedSpace::RawSlowAllocateRaw(int size_in_bytes) {
free_list_.Allocate(static_cast<size_t>(size_in_bytes));
if (object != NULL) return object;
// If sweeping is still in progress try to sweep pages on the main thread.
int max_freed = collector->sweeper().ParallelSweepSpace(
identity(), size_in_bytes, kMaxPagesToSweep);
RefillFreeList();
if (max_freed >= size_in_bytes) {
object = free_list_.Allocate(static_cast<size_t>(size_in_bytes));
if (object != nullptr) return object;
// TODO(v8:6754): Resolve the race with sweeping during scavenge.
if (heap()->gc_state() != Heap::SCAVENGE) {
// If sweeping is still in progress try to sweep pages on the main thread.
int max_freed = collector->sweeper().ParallelSweepSpace(
identity(), size_in_bytes, kMaxPagesToSweep);
RefillFreeList();
if (max_freed >= size_in_bytes) {
object = free_list_.Allocate(static_cast<size_t>(size_in_bytes));
if (object != nullptr) return object;
}
}
} else if (is_local()) {
// Sweeping not in progress and we are on a {CompactionSpace}. This can
......
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