Skip to content

Commit 167c952

Browse files
committed
8371369: Parallel: Relax precondition of PSOldGen::expand_and_allocate
Reviewed-by: eosterlund, fandreuzzi
1 parent 59d2309 commit 167c952

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/hotspot/share/gc/parallel/mutableSpace.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,11 @@ bool MutableSpace::cas_deallocate(HeapWord *obj, size_t size) {
182182

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

src/hotspot/share/gc/parallel/psOldGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ void PSOldGen::initialize_performance_counters() {
118118
}
119119

120120
HeapWord* PSOldGen::expand_and_allocate(size_t word_size) {
121-
assert(SafepointSynchronize::is_at_safepoint(), "precondition");
122-
assert(Thread::current()->is_VM_thread(), "precondition");
121+
assert(Heap_lock->is_locked(), "precondition");
122+
123123
if (object_space()->needs_expand(word_size)) {
124124
expand(word_size*HeapWordSize);
125125
}

0 commit comments

Comments
 (0)