Skip to content
Permalink
Browse files
8276205: Shenandoah: CodeCache_lock should always be held for initial…
…izing code cache iteration

Reviewed-by: shade
  • Loading branch information
zhengyu123 committed Nov 1, 2021
1 parent 9771544 commit 99b7b95e014da6e491ba7adfd21de53d6ae166fe
Showing with 6 additions and 2 deletions.
  1. +3 −0 src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp
  2. +3 −2 src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
@@ -355,12 +355,15 @@ ShenandoahCodeRootsIterator::ShenandoahCodeRootsIterator() :
_par_iterator(CodeCache::heaps()),
_table_snapshot(NULL) {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint");
MutexLocker locker(CodeCache_lock, Mutex::_no_safepoint_check_flag);
_table_snapshot = ShenandoahCodeRoots::table()->snapshot_for_iteration();
}

ShenandoahCodeRootsIterator::~ShenandoahCodeRootsIterator() {
MonitorLocker locker(CodeCache_lock, Mutex::_no_safepoint_check_flag);
ShenandoahCodeRoots::table()->finish_iteration(_table_snapshot);
_table_snapshot = NULL;
locker.notify_all();
}

void ShenandoahCodeRootsIterator::possibly_parallel_blobs_do(CodeBlobClosure *f) {
@@ -158,7 +158,7 @@ ShenandoahConcurrentRootScanner::ShenandoahConcurrentRootScanner(uint n_workers,
_codecache_snapshot(NULL),
_phase(phase) {
if (!ShenandoahHeap::heap()->unload_classes()) {
CodeCache_lock->lock_without_safepoint_check();
MutexLocker locker(CodeCache_lock, Mutex::_no_safepoint_check_flag);
_codecache_snapshot = ShenandoahCodeRoots::table()->snapshot_for_iteration();
}
update_tlab_stats();
@@ -167,8 +167,9 @@ ShenandoahConcurrentRootScanner::ShenandoahConcurrentRootScanner(uint n_workers,

ShenandoahConcurrentRootScanner::~ShenandoahConcurrentRootScanner() {
if (!ShenandoahHeap::heap()->unload_classes()) {
MonitorLocker locker(CodeCache_lock, Mutex::_no_safepoint_check_flag);
ShenandoahCodeRoots::table()->finish_iteration(_codecache_snapshot);
CodeCache_lock->unlock();
locker.notify_all();
}
}

1 comment on commit 99b7b95

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 99b7b95 Nov 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.