Skip to content

Commit d098751

Browse files
committedSep 23, 2021
8273916: Remove 'special' ranking
Reviewed-by: dholmes, pchilanomate
1 parent 4f3b626 commit d098751

File tree

5 files changed

+40
-45
lines changed

5 files changed

+40
-45
lines changed
 

‎src/hotspot/share/runtime/mutex.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ class Mutex : public CHeapObj<mtSynchronizer> {
5151
service = event + 6,
5252
stackwatermark = service + 3,
5353
tty = stackwatermark + 3,
54-
special = tty + 3,
55-
oopstorage = special + 3,
54+
oopstorage = tty + 3,
5655
nosafepoint = oopstorage + 6,
5756
leaf = nosafepoint + 6,
5857
barrier = leaf + 10,

‎src/hotspot/share/runtime/mutexLocker.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,17 @@ void mutex_init() {
225225
def(StringDedup_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never);
226226
def(StringDedupIntern_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
227227
def(ParGCRareEvent_lock , PaddedMutex , leaf, true, _safepoint_check_always);
228-
def(CodeCache_lock , PaddedMonitor, special, true, _safepoint_check_never);
229-
def(CodeSweeper_lock , PaddedMonitor, special-2, true, _safepoint_check_never);
230-
def(RawMonitor_lock , PaddedMutex , special, true, _safepoint_check_never);
228+
def(CodeCache_lock , PaddedMonitor, nosafepoint-3, true, _safepoint_check_never);
229+
def(CodeSweeper_lock , PaddedMonitor, nosafepoint-5, true, _safepoint_check_never);
230+
def(RawMonitor_lock , PaddedMutex , nosafepoint-1, true, _safepoint_check_never);
231231
def(OopMapCacheAlloc_lock , PaddedMutex , leaf, true, _safepoint_check_always); // used for oop_map_cache allocation.
232232

233233
def(Metaspace_lock , PaddedMutex , nosafepoint-3, true, _safepoint_check_never);
234234
def(ClassLoaderDataGraph_lock , PaddedMutex , nonleaf, false, _safepoint_check_always);
235235

236-
def(Patching_lock , PaddedMutex , special, true, _safepoint_check_never); // used for safepointing and code patching.
237-
def(CompiledMethod_lock , PaddedMutex , special-1, true, _safepoint_check_never);
238-
def(MonitorDeflation_lock , PaddedMonitor, special, true, _safepoint_check_never); // used for monitor deflation thread operations
236+
def(Patching_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); // used for safepointing and code patching.
237+
def(CompiledMethod_lock , PaddedMutex , nosafepoint-4, true, _safepoint_check_never);
238+
def(MonitorDeflation_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never); // used for monitor deflation thread operations
239239
def(Service_lock , PaddedMonitor, service, true, _safepoint_check_never); // used for service thread operations
240240

241241
if (UseNotificationThread) {
@@ -244,7 +244,7 @@ void mutex_init() {
244244
Notification_lock = Service_lock;
245245
}
246246

247-
def(JmethodIdCreation_lock , PaddedMutex , special-2, true, _safepoint_check_never); // used for creating jmethodIDs.
247+
def(JmethodIdCreation_lock , PaddedMutex , nosafepoint-2, true, _safepoint_check_never); // used for creating jmethodIDs.
248248

249249
def(SystemDictionary_lock , PaddedMonitor, leaf, true, _safepoint_check_always);
250250
def(SharedDictionary_lock , PaddedMutex , leaf, true, _safepoint_check_always);
@@ -283,7 +283,7 @@ void mutex_init() {
283283
def(CompiledIC_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); // locks VtableStubs_lock, InlineCacheBuffer_lock
284284
def(CompileTaskAlloc_lock , PaddedMutex , nonleaf+2, true, _safepoint_check_always);
285285
def(CompileStatistics_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always);
286-
def(DirectivesStack_lock , PaddedMutex , special, true, _safepoint_check_never);
286+
def(DirectivesStack_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
287287
def(MultiArray_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always);
288288

289289
def(JvmtiThreadState_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always); // Used by JvmtiThreadState/JvmtiEventController
@@ -314,12 +314,12 @@ void mutex_init() {
314314
#endif
315315

316316
#ifndef SUPPORTS_NATIVE_CX8
317-
def(UnsafeJlong_lock , PaddedMutex , special, true, _safepoint_check_never);
317+
def(UnsafeJlong_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
318318
#endif
319319

320320
def(CodeHeapStateAnalytics_lock , PaddedMutex , nonleaf+6, false, _safepoint_check_always);
321-
def(NMethodSweeperStats_lock , PaddedMutex , special, true, _safepoint_check_never);
322-
def(ThreadsSMRDelete_lock , PaddedMonitor, special, true, _safepoint_check_never);
321+
def(NMethodSweeperStats_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
322+
def(ThreadsSMRDelete_lock , PaddedMonitor, nosafepoint-3, true, _safepoint_check_never); // Holds ConcurrentHashTableResize_lock
323323
def(ThreadIdTableCreate_lock , PaddedMutex , leaf, false, _safepoint_check_always);
324324
def(SharedDecoder_lock , PaddedMutex , tty-1, true, _safepoint_check_never);
325325
def(DCmdFactory_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);

‎src/hotspot/share/runtime/mutexLocker.hpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern Mutex* VtableStubs_lock; // a lock on the VtableStubs
5454
extern Mutex* SymbolArena_lock; // a lock on the symbol table arena
5555
extern Monitor* StringDedup_lock; // a lock on the string deduplication facility
5656
extern Mutex* StringDedupIntern_lock; // a lock on StringTable notification of StringDedup
57-
extern Monitor* CodeCache_lock; // a lock on the CodeCache, rank is special
57+
extern Monitor* CodeCache_lock; // a lock on the CodeCache
5858
extern Monitor* CodeSweeper_lock; // a lock used by the sweeper only for wait notify
5959
extern Mutex* MethodData_lock; // a lock on installation of method data
6060
extern Mutex* TouchedMethodLog_lock; // a lock on allocation of LogExecutedMethods info
@@ -196,8 +196,6 @@ class MutexLocker: public StackObj {
196196
_mutex(mutex) {
197197
bool no_safepoint_check = flag == Mutex::_no_safepoint_check_flag;
198198
if (_mutex != NULL) {
199-
assert(_mutex->rank() > Mutex::special || no_safepoint_check,
200-
"Mutexes with rank special or lower should not do safepoint checks");
201199
if (no_safepoint_check) {
202200
_mutex->lock_without_safepoint_check();
203201
} else {
@@ -210,8 +208,6 @@ class MutexLocker: public StackObj {
210208
_mutex(mutex) {
211209
bool no_safepoint_check = flag == Mutex::_no_safepoint_check_flag;
212210
if (_mutex != NULL) {
213-
assert(_mutex->rank() > Mutex::special || no_safepoint_check,
214-
"Mutexes with rank special or lower should not do safepoint checks");
215211
if (no_safepoint_check) {
216212
_mutex->lock_without_safepoint_check(thread);
217213
} else {

‎test/hotspot/gtest/runtime/test_mutex.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,18 @@ TEST_VM_ASSERT_MSG(MutexRank, mutex_lock_event_nosafepoint,
143143
mutex_rank_event->unlock();
144144
}
145145

146-
TEST_VM_ASSERT_MSG(MutexRank, mutex_lock_tty_special,
147-
".* Attempting to acquire lock mutex_rank_special/.* out of order with lock mutex_rank_tty/.*"
146+
TEST_VM_ASSERT_MSG(MutexRank, mutex_lock_tty_nosafepoint,
147+
".* Attempting to acquire lock mutex_rank_nosafepoint/.* out of order with lock mutex_rank_tty/.*"
148148
"-- possible deadlock") {
149149
JavaThread* THREAD = JavaThread::current();
150150
ThreadInVMfromNative invm(THREAD);
151151

152152
Mutex* mutex_rank_tty = new Mutex(Mutex::tty, "mutex_rank_tty", Mutex::_safepoint_check_never);
153-
Mutex* mutex_rank_special = new Mutex(Mutex::special, "mutex_rank_special", Mutex::_safepoint_check_never);
153+
Mutex* mutex_rank_nosafepoint = new Mutex(Mutex::nosafepoint, "mutex_rank_nosafepoint", Mutex::_safepoint_check_never);
154154

155155
mutex_rank_tty->lock_without_safepoint_check();
156-
mutex_rank_special->lock_without_safepoint_check();
157-
mutex_rank_special->unlock();
156+
mutex_rank_nosafepoint->lock_without_safepoint_check();
157+
mutex_rank_nosafepoint->unlock();
158158
mutex_rank_tty->unlock();
159159
}
160160

@@ -204,20 +204,20 @@ TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_out_of_order_trylock,
204204
monitor_rankA->unlock();
205205
}
206206

207-
TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_special,
208-
".* Attempting to wait on monitor monitor_rank_special_minus_one/.* while holding lock monitor_rank_special/.*"
207+
TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_nosafepoint,
208+
".* Attempting to wait on monitor monitor_rank_nosafepoint_minus_one/.* while holding lock monitor_rank_nosafepoint/.*"
209209
"-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank nosafepoint or below.") {
210210
JavaThread* THREAD = JavaThread::current();
211211
ThreadInVMfromNative invm(THREAD);
212212

213-
Monitor* monitor_rank_special = new Monitor(Mutex::special, "monitor_rank_special", Mutex::_safepoint_check_never);
214-
Monitor* monitor_rank_special_minus_one = new Monitor(Mutex::special - 1, "monitor_rank_special_minus_one", Mutex::_safepoint_check_never);
213+
Monitor* monitor_rank_nosafepoint = new Monitor(Mutex::nosafepoint, "monitor_rank_nosafepoint", Mutex::_safepoint_check_never);
214+
Monitor* monitor_rank_nosafepoint_minus_one = new Monitor(Mutex::nosafepoint - 1, "monitor_rank_nosafepoint_minus_one", Mutex::_safepoint_check_never);
215215

216-
monitor_rank_special->lock_without_safepoint_check();
217-
monitor_rank_special_minus_one->lock_without_safepoint_check();
218-
monitor_rank_special_minus_one->wait_without_safepoint_check(1);
219-
monitor_rank_special_minus_one->unlock();
220-
monitor_rank_special->unlock();
216+
monitor_rank_nosafepoint->lock_without_safepoint_check();
217+
monitor_rank_nosafepoint_minus_one->lock_without_safepoint_check();
218+
monitor_rank_nosafepoint_minus_one->wait_without_safepoint_check(1);
219+
monitor_rank_nosafepoint_minus_one->unlock();
220+
monitor_rank_nosafepoint->unlock();
221221
}
222222

223223
TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_event_tty,
@@ -236,30 +236,30 @@ TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_event_tty,
236236
monitor_rank_tty->unlock();
237237
}
238238

239-
TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_tty_special,
240-
".* Attempting to wait on monitor monitor_rank_tty/.* while holding lock monitor_rank_special/.*"
239+
TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_tty_nosafepoint,
240+
".* Attempting to wait on monitor monitor_rank_tty/.* while holding lock monitor_rank_nosafepoint/.*"
241241
"-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank nosafepoint or below.") {
242242
JavaThread* THREAD = JavaThread::current();
243243
ThreadInVMfromNative invm(THREAD);
244244

245-
Monitor* monitor_rank_special = new Monitor(Mutex::special, "monitor_rank_special", Mutex::_safepoint_check_never);
245+
Monitor* monitor_rank_nosafepoint = new Monitor(Mutex::nosafepoint, "monitor_rank_nosafepoint", Mutex::_safepoint_check_never);
246246
Monitor* monitor_rank_tty = new Monitor(Mutex::tty, "monitor_rank_tty", Mutex::_safepoint_check_never);
247247

248-
monitor_rank_special->lock_without_safepoint_check();
248+
monitor_rank_nosafepoint->lock_without_safepoint_check();
249249
monitor_rank_tty->lock_without_safepoint_check();
250250
monitor_rank_tty->wait_without_safepoint_check(1);
251251
monitor_rank_tty->unlock();
252-
monitor_rank_special->unlock();
252+
monitor_rank_nosafepoint->unlock();
253253
}
254254

255-
TEST_VM_ASSERT_MSG(MutexRank, monitor_special_vm_block,
255+
TEST_VM_ASSERT_MSG(MutexRank, monitor_nosafepoint_vm_block,
256256
".*Safepoint check never locks should always allow the vm to block") {
257257
JavaThread* THREAD = JavaThread::current();
258258
ThreadInVMfromNative invm(THREAD);
259259

260-
Monitor* monitor_rank_special = new Monitor(Mutex::special, "monitor_rank_special", Mutex::_safepoint_check_never, false);
261-
monitor_rank_special->lock_without_safepoint_check();
262-
monitor_rank_special->unlock();
260+
Monitor* monitor_rank_nosafepoint = new Monitor(Mutex::nosafepoint, "monitor_rank_nosafepoint", Mutex::_safepoint_check_never, false);
261+
monitor_rank_nosafepoint->lock_without_safepoint_check();
262+
monitor_rank_nosafepoint->unlock();
263263
}
264264

265265
TEST_VM_ASSERT_MSG(MutexRank, monitor_negative_rank,

‎test/hotspot/gtest/runtime/test_safepoint_locks.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ TEST_VM_ASSERT_MSG(SafepointLockAssertTest, never_check,
4242
Mutex::_safepoint_check_flag);
4343
}
4444

45-
TEST_VM_ASSERT_MSG(SafepointLockAssertTest, special_locks,
45+
TEST_VM_ASSERT_MSG(SafepointLockAssertTest, nosafepoint_locks,
4646
".*Locks below nosafepoint rank should never safepoint: SpecialTest_lock") {
47-
MutexLocker ml(new Mutex(Mutex::special, "SpecialTest_lock", Mutex::_safepoint_check_always),
47+
MutexLocker ml(new Mutex(Mutex::nosafepoint, "SpecialTest_lock", Mutex::_safepoint_check_always),
4848
Mutex::_safepoint_check_flag);
4949
}
5050

5151
TEST_VM_ASSERT_MSG(SafepointLockAssertTest, possible_safepoint_lock,
5252
".* Possible safepoint reached by thread that does not allow it") {
5353
JavaThread* thread = JavaThread::current();
5454
ThreadInVMfromNative in_native(thread);
55-
MutexLocker ml(new Mutex(Mutex::special, "SpecialTest_lock", Mutex::_safepoint_check_never),
55+
MutexLocker ml(new Mutex(Mutex::nosafepoint, "SpecialTest_lock", Mutex::_safepoint_check_never),
5656
Mutex::_no_safepoint_check_flag);
5757
thread->print_thread_state_on(tty);
58-
// If the lock above succeeds, try to safepoint to test the NSV implied with this special lock.
58+
// If the lock above succeeds, try to safepoint to test the NSV implied with this nosafepoint lock.
5959
ThreadBlockInVM tbivm(thread);
6060
thread->print_thread_state_on(tty);
6161
}

0 commit comments

Comments
 (0)
Please sign in to comment.