8353263: Parallel: Remove locking in PSOldGen::resize

Reviewed-by: tschatzl, zgu
This commit is contained in:
Albert Mingkun Yang 2025-04-02 14:19:26 +00:00
parent 8608b16341
commit a0677d94d8

View File

@ -262,8 +262,9 @@ bool PSOldGen::expand_to_reserved() {
}
void PSOldGen::shrink(size_t bytes) {
assert_lock_strong(PSOldGenExpand_lock);
assert_locked_or_safepoint(Heap_lock);
assert(Thread::current()->is_VM_thread(), "precondition");
assert(SafepointSynchronize::is_at_safepoint(), "precondition");
assert(bytes > 0, "precondition");
size_t size = align_down(bytes, virtual_space()->alignment());
if (size > 0) {
@ -314,11 +315,9 @@ void PSOldGen::resize(size_t desired_free_space) {
}
if (new_size > current_size) {
size_t change_bytes = new_size - current_size;
MutexLocker x(PSOldGenExpand_lock);
expand(change_bytes);
} else {
size_t change_bytes = current_size - new_size;
MutexLocker x(PSOldGenExpand_lock);
shrink(change_bytes);
}