Commit 6da744d0 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Introduce ConcurrentAllocationMutex

Locks the allocation mutex if SupportsConcurrentAllocation() returns
true. Unifies code/condition from multiple usages.

Bug: v8:10315
Change-Id: I684d12284e862df5d68986841e04ff25527422eb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2352775
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69379}
parent e972c359
......@@ -433,13 +433,7 @@ void PagedSpace::MakeLinearAllocationAreaIterable() {
}
size_t PagedSpace::Available() {
base::Optional<base::MutexGuard> optional_mutex;
if (FLAG_concurrent_allocation && identity() == OLD_SPACE &&
!is_local_space()) {
optional_mutex.emplace(&allocation_mutex_);
}
ConcurrentAllocationMutex guard(this);
return free_list_->Available();
}
......@@ -872,13 +866,7 @@ bool PagedSpace::RefillLabMain(int size_in_bytes, AllocationOrigin origin) {
VMState<GC> state(heap()->isolate());
RuntimeCallTimerScope runtime_timer(
heap()->isolate(), RuntimeCallCounterId::kGC_Custom_SlowAllocateRaw);
base::Optional<base::MutexGuard> optional_mutex;
if (FLAG_concurrent_allocation && origin != AllocationOrigin::kGC &&
identity() == OLD_SPACE) {
optional_mutex.emplace(&allocation_mutex_);
}
ConcurrentAllocationMutex guard(this);
return RawRefillLabMain(size_in_bytes, origin);
}
......
......@@ -309,6 +309,21 @@ class V8_EXPORT_PRIVATE PagedSpace
void SetLinearAllocationArea(Address top, Address limit);
private:
class ConcurrentAllocationMutex {
public:
explicit ConcurrentAllocationMutex(PagedSpace* space) {
if (space->SupportsConcurrentAllocation()) {
guard_.emplace(&space->allocation_mutex_);
}
}
base::Optional<base::MutexGuard> guard_;
};
bool SupportsConcurrentAllocation() {
return FLAG_concurrent_allocation && !is_local_space();
}
// Set space linear allocation area.
void SetTopAndLimit(Address top, Address limit);
void DecreaseLimit(Address new_limit);
......
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