8371369: Parallel: Relax precondition of PSOldGen::expand_and_allocate

Reviewed-by: eosterlund, fandreuzzi
This commit is contained in:
Albert Mingkun Yang 2025-11-07 10:48:07 +00:00
parent 59d2309578
commit 167c952bb0
2 changed files with 7 additions and 8 deletions

View File

@ -182,12 +182,11 @@ bool MutableSpace::cas_deallocate(HeapWord *obj, size_t size) {
// Only used by oldgen allocation.
bool MutableSpace::needs_expand(size_t word_size) const {
#ifdef ASSERT
// If called by VM thread, locking is not needed.
if (!Thread::current()->is_VM_thread()) {
assert_lock_strong(PSOldGenExpand_lock);
}
#endif
// This method can be invoked either outside of safepoint by java threads or
// in safepoint by gc workers. Such accesses are synchronized by holding one
// of the following locks.
assert(Heap_lock->is_locked() || PSOldGenExpand_lock->is_locked(), "precondition");
// Holding the lock means end is stable. So while top may be advancing
// via concurrent allocations, there is no need to order the reads of top
// and end here, unlike in cas_allocate.

View File

@ -118,8 +118,8 @@ void PSOldGen::initialize_performance_counters() {
}
HeapWord* PSOldGen::expand_and_allocate(size_t word_size) {
assert(SafepointSynchronize::is_at_safepoint(), "precondition");
assert(Thread::current()->is_VM_thread(), "precondition");
assert(Heap_lock->is_locked(), "precondition");
if (object_space()->needs_expand(word_size)) {
expand(word_size*HeapWordSize);
}