mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-02 15:20:27 +00:00
8387387: Parallel: Clean up startup allocation locking
Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org> Reviewed-by: tschatzl, aboldtch
This commit is contained in:
parent
64ae319b5c
commit
b186074751
@ -315,17 +315,16 @@ HeapWord* ParallelScavengeHeap::mem_allocate_work(size_t size, bool is_tlab) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Ensure that is_init_completed() does not transition while expanding the heap.
|
||||
ConditionalMutexLocker ml_init(InitCompleted_lock, !is_init_completed(), Mutex::_no_safepoint_check_flag);
|
||||
if (!is_init_completed()) {
|
||||
// Double checked locking, this ensure that is_init_completed() does not
|
||||
// transition while expanding the heap.
|
||||
MonitorLocker ml(InitCompleted_lock, Monitor::_no_safepoint_check_flag);
|
||||
if (!is_init_completed()) {
|
||||
result = expand_heap_and_allocate(size, is_tlab);
|
||||
// Return the result if it's tlab-allocation. If the result is null, callers will retry
|
||||
// non-tlab allocation.
|
||||
if (result != nullptr || is_tlab) {
|
||||
return result;
|
||||
}
|
||||
// Rechecked !is_init_completed() implies we have mutual exclusion via
|
||||
// `Heap_lock` and `InitCompleted_lock`
|
||||
result = expand_heap_and_allocate(size, is_tlab);
|
||||
// Return the result if it's tlab-allocation. If the result is null,
|
||||
// callers will retry non-tlab allocation.
|
||||
if (result != nullptr || is_tlab) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user