File tree Expand file tree Collapse file tree 6 files changed +12
-9
lines changed
Expand file tree Collapse file tree 6 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ bool VM_GC_Operation::doit_prologue() {
132132void VM_GC_Operation::doit_epilogue () {
133133 // GC thread root traversal likely used OopMapCache a lot, which
134134 // might have created lots of old entries. Trigger the cleanup now.
135- OopMapCache::trigger_cleanup ();
135+ OopMapCache::try_trigger_cleanup ();
136136 if (Universe::has_reference_pending_list ()) {
137137 Heap_lock->notify_all ();
138138 }
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ void VM_ShenandoahOperation::doit_epilogue() {
4444 assert (!ShenandoahHeap::heap ()->has_gc_state_changed (), " GC State was not synchronized to java threads." );
4545 // GC thread root traversal likely used OopMapCache a lot, which
4646 // might have created lots of old entries. Trigger the cleanup now.
47- OopMapCache::trigger_cleanup ();
47+ OopMapCache::try_trigger_cleanup ();
4848}
4949
5050bool VM_ShenandoahReferenceOperation::doit_prologue () {
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ class VM_XOperation : public VM_Operation {
134134
135135 // GC thread root traversal likely used OopMapCache a lot, which
136136 // might have created lots of old entries. Trigger the cleanup now.
137- OopMapCache::trigger_cleanup ();
137+ OopMapCache::try_trigger_cleanup ();
138138 }
139139
140140 bool gc_locked () const {
Original file line number Diff line number Diff line change @@ -456,7 +456,7 @@ class VM_ZOperation : public VM_Operation {
456456
457457 // GC thread root traversal likely used OopMapCache a lot, which
458458 // might have created lots of old entries. Trigger the cleanup now.
459- OopMapCache::trigger_cleanup ();
459+ OopMapCache::try_trigger_cleanup ();
460460 }
461461
462462 bool success () const {
Original file line number Diff line number Diff line change @@ -592,10 +592,13 @@ bool OopMapCache::has_cleanup_work() {
592592 return Atomic::load (&_old_entries) != nullptr ;
593593}
594594
595- void OopMapCache::trigger_cleanup () {
596- if (has_cleanup_work ()) {
597- MutexLocker ml (Service_lock, Mutex::_no_safepoint_check_flag);
595+ void OopMapCache::try_trigger_cleanup () {
596+ // See we can take the lock for the notification without blocking.
597+ // This allows triggering the cleanup from GC paths, that can hold
598+ // the service lock for e.g. oop iteration in service thread.
599+ if (has_cleanup_work () && Service_lock->try_lock_without_rank_check ()) {
598600 Service_lock->notify_all ();
601+ Service_lock->unlock ();
599602 }
600603}
601604
Original file line number Diff line number Diff line change @@ -183,8 +183,8 @@ class OopMapCache : public CHeapObj<mtClass> {
183183 // Check if we need to clean up old entries
184184 static bool has_cleanup_work ();
185185
186- // Request cleanup if work is needed
187- static void trigger_cleanup ();
186+ // Request cleanup if work is needed and notification is currently possible
187+ static void try_trigger_cleanup ();
188188
189189 // Clean up the old entries
190190 static void cleanup ();
You can’t perform that action at this time.
0 commit comments