Skip to content

Commit 4ebb771

Browse files
committed
8334769: Shenandoah: Move CodeCache_lock close to its use in ShenandoahConcurrentNMethodIterator
Reviewed-by: shade, wkemper, kdnilsen
1 parent 817edcb commit 4ebb771

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
23
* Copyright (c) 2017, 2022, Red Hat, Inc. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
@@ -102,12 +103,10 @@ class ShenandoahDisarmNMethodsTask : public WorkerTask {
102103
WorkerTask("Shenandoah Disarm NMethods"),
103104
_iterator(ShenandoahCodeRoots::table()) {
104105
assert(SafepointSynchronize::is_at_safepoint(), "Only at a safepoint");
105-
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
106106
_iterator.nmethods_do_begin();
107107
}
108108

109109
~ShenandoahDisarmNMethodsTask() {
110-
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
111110
_iterator.nmethods_do_end();
112111
}
113112

@@ -177,12 +176,10 @@ class ShenandoahUnlinkTask : public WorkerTask {
177176
WorkerTask("Shenandoah Unlink NMethods"),
178177
_cl(unloading_occurred),
179178
_iterator(ShenandoahCodeRoots::table()) {
180-
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
181179
_iterator.nmethods_do_begin();
182180
}
183181

184182
~ShenandoahUnlinkTask() {
185-
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
186183
_iterator.nmethods_do_end();
187184
}
188185

src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
23
* Copyright (c) 2021, 2022, Red Hat, Inc. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
@@ -771,14 +772,12 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public WorkerTask {
771772
_nmethod_itr(ShenandoahCodeRoots::table()),
772773
_phase(phase) {
773774
if (ShenandoahHeap::heap()->unload_classes()) {
774-
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
775775
_nmethod_itr.nmethods_do_begin();
776776
}
777777
}
778778

779779
~ShenandoahConcurrentWeakRootsEvacUpdateTask() {
780780
if (ShenandoahHeap::heap()->unload_classes()) {
781-
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
782781
_nmethod_itr.nmethods_do_end();
783782
}
784783
// Notify runtime data structures of potentially dead oops
@@ -884,14 +883,12 @@ class ShenandoahConcurrentRootsEvacUpdateTask : public WorkerTask {
884883
_cld_roots(phase, ShenandoahHeap::heap()->workers()->active_workers(), false /*heap iteration*/),
885884
_nmethod_itr(ShenandoahCodeRoots::table()) {
886885
if (!ShenandoahHeap::heap()->unload_classes()) {
887-
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
888886
_nmethod_itr.nmethods_do_begin();
889887
}
890888
}
891889

892890
~ShenandoahConcurrentRootsEvacUpdateTask() {
893891
if (!ShenandoahHeap::heap()->unload_classes()) {
894-
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
895892
_nmethod_itr.nmethods_do_end();
896893
}
897894
}

src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
23
* Copyright (c) 2019, 2022, Red Hat, Inc. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
@@ -478,7 +479,7 @@ ShenandoahConcurrentNMethodIterator::ShenandoahConcurrentNMethodIterator(Shenand
478479
}
479480

480481
void ShenandoahConcurrentNMethodIterator::nmethods_do_begin() {
481-
assert(CodeCache_lock->owned_by_self(), "Lock must be held");
482+
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
482483
_table_snapshot = _table->snapshot_for_iteration();
483484
}
484485

@@ -488,7 +489,7 @@ void ShenandoahConcurrentNMethodIterator::nmethods_do(NMethodClosure* cl) {
488489
}
489490

490491
void ShenandoahConcurrentNMethodIterator::nmethods_do_end() {
491-
assert(CodeCache_lock->owned_by_self(), "Lock must be held");
492+
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
492493
_table->finish_iteration(_table_snapshot);
493494
CodeCache_lock->notify_all();
494495
}

0 commit comments

Comments
 (0)