diff --git a/src/hotspot/share/runtime/mutex.hpp b/src/hotspot/share/runtime/mutex.hpp index f8aafbeb17473..cb98d42655cba 100644 --- a/src/hotspot/share/runtime/mutex.hpp +++ b/src/hotspot/share/runtime/mutex.hpp @@ -51,8 +51,7 @@ class Mutex : public CHeapObj { service = event + 6, stackwatermark = service + 3, tty = stackwatermark + 3, - special = tty + 3, - oopstorage = special + 3, + oopstorage = tty + 3, nosafepoint = oopstorage + 6, leaf = nosafepoint + 6, barrier = leaf + 10, diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index 497c514b4a13c..f93a7ecbce1f2 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -225,17 +225,17 @@ void mutex_init() { def(StringDedup_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never); def(StringDedupIntern_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); def(ParGCRareEvent_lock , PaddedMutex , leaf, true, _safepoint_check_always); - def(CodeCache_lock , PaddedMonitor, special, true, _safepoint_check_never); - def(CodeSweeper_lock , PaddedMonitor, special-2, true, _safepoint_check_never); - def(RawMonitor_lock , PaddedMutex , special, true, _safepoint_check_never); + def(CodeCache_lock , PaddedMonitor, nosafepoint-3, true, _safepoint_check_never); + def(CodeSweeper_lock , PaddedMonitor, nosafepoint-5, true, _safepoint_check_never); + def(RawMonitor_lock , PaddedMutex , nosafepoint-1, true, _safepoint_check_never); def(OopMapCacheAlloc_lock , PaddedMutex , leaf, true, _safepoint_check_always); // used for oop_map_cache allocation. def(Metaspace_lock , PaddedMutex , nosafepoint-3, true, _safepoint_check_never); def(ClassLoaderDataGraph_lock , PaddedMutex , nonleaf, false, _safepoint_check_always); - def(Patching_lock , PaddedMutex , special, true, _safepoint_check_never); // used for safepointing and code patching. - def(CompiledMethod_lock , PaddedMutex , special-1, true, _safepoint_check_never); - def(MonitorDeflation_lock , PaddedMonitor, special, true, _safepoint_check_never); // used for monitor deflation thread operations + def(Patching_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); // used for safepointing and code patching. + def(CompiledMethod_lock , PaddedMutex , nosafepoint-4, true, _safepoint_check_never); + def(MonitorDeflation_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never); // used for monitor deflation thread operations def(Service_lock , PaddedMonitor, service, true, _safepoint_check_never); // used for service thread operations if (UseNotificationThread) { @@ -244,7 +244,7 @@ void mutex_init() { Notification_lock = Service_lock; } - def(JmethodIdCreation_lock , PaddedMutex , special-2, true, _safepoint_check_never); // used for creating jmethodIDs. + def(JmethodIdCreation_lock , PaddedMutex , nosafepoint-2, true, _safepoint_check_never); // used for creating jmethodIDs. def(SystemDictionary_lock , PaddedMonitor, leaf, true, _safepoint_check_always); def(SharedDictionary_lock , PaddedMutex , leaf, true, _safepoint_check_always); @@ -283,7 +283,7 @@ void mutex_init() { def(CompiledIC_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); // locks VtableStubs_lock, InlineCacheBuffer_lock def(CompileTaskAlloc_lock , PaddedMutex , nonleaf+2, true, _safepoint_check_always); def(CompileStatistics_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always); - def(DirectivesStack_lock , PaddedMutex , special, true, _safepoint_check_never); + def(DirectivesStack_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); def(MultiArray_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always); def(JvmtiThreadState_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always); // Used by JvmtiThreadState/JvmtiEventController @@ -314,12 +314,12 @@ void mutex_init() { #endif #ifndef SUPPORTS_NATIVE_CX8 - def(UnsafeJlong_lock , PaddedMutex , special, true, _safepoint_check_never); + def(UnsafeJlong_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); #endif def(CodeHeapStateAnalytics_lock , PaddedMutex , nonleaf+6, false, _safepoint_check_always); - def(NMethodSweeperStats_lock , PaddedMutex , special, true, _safepoint_check_never); - def(ThreadsSMRDelete_lock , PaddedMonitor, special, true, _safepoint_check_never); + def(NMethodSweeperStats_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); + def(ThreadsSMRDelete_lock , PaddedMonitor, nosafepoint-3, true, _safepoint_check_never); // Holds ConcurrentHashTableResize_lock def(ThreadIdTableCreate_lock , PaddedMutex , leaf, false, _safepoint_check_always); def(SharedDecoder_lock , PaddedMutex , tty-1, true, _safepoint_check_never); def(DCmdFactory_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 9ab0d4309185a..c4c7215006067 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -54,7 +54,7 @@ extern Mutex* VtableStubs_lock; // a lock on the VtableStubs extern Mutex* SymbolArena_lock; // a lock on the symbol table arena extern Monitor* StringDedup_lock; // a lock on the string deduplication facility extern Mutex* StringDedupIntern_lock; // a lock on StringTable notification of StringDedup -extern Monitor* CodeCache_lock; // a lock on the CodeCache, rank is special +extern Monitor* CodeCache_lock; // a lock on the CodeCache extern Monitor* CodeSweeper_lock; // a lock used by the sweeper only for wait notify extern Mutex* MethodData_lock; // a lock on installation of method data extern Mutex* TouchedMethodLog_lock; // a lock on allocation of LogExecutedMethods info @@ -196,8 +196,6 @@ class MutexLocker: public StackObj { _mutex(mutex) { bool no_safepoint_check = flag == Mutex::_no_safepoint_check_flag; if (_mutex != NULL) { - assert(_mutex->rank() > Mutex::special || no_safepoint_check, - "Mutexes with rank special or lower should not do safepoint checks"); if (no_safepoint_check) { _mutex->lock_without_safepoint_check(); } else { @@ -210,8 +208,6 @@ class MutexLocker: public StackObj { _mutex(mutex) { bool no_safepoint_check = flag == Mutex::_no_safepoint_check_flag; if (_mutex != NULL) { - assert(_mutex->rank() > Mutex::special || no_safepoint_check, - "Mutexes with rank special or lower should not do safepoint checks"); if (no_safepoint_check) { _mutex->lock_without_safepoint_check(thread); } else { diff --git a/test/hotspot/gtest/runtime/test_mutex.cpp b/test/hotspot/gtest/runtime/test_mutex.cpp index 2908aa74ab5e8..2115ae2dfb93e 100644 --- a/test/hotspot/gtest/runtime/test_mutex.cpp +++ b/test/hotspot/gtest/runtime/test_mutex.cpp @@ -143,18 +143,18 @@ TEST_VM_ASSERT_MSG(MutexRank, mutex_lock_event_nosafepoint, mutex_rank_event->unlock(); } -TEST_VM_ASSERT_MSG(MutexRank, mutex_lock_tty_special, - ".* Attempting to acquire lock mutex_rank_special/.* out of order with lock mutex_rank_tty/.*" +TEST_VM_ASSERT_MSG(MutexRank, mutex_lock_tty_nosafepoint, + ".* Attempting to acquire lock mutex_rank_nosafepoint/.* out of order with lock mutex_rank_tty/.*" "-- possible deadlock") { JavaThread* THREAD = JavaThread::current(); ThreadInVMfromNative invm(THREAD); Mutex* mutex_rank_tty = new Mutex(Mutex::tty, "mutex_rank_tty", Mutex::_safepoint_check_never); - Mutex* mutex_rank_special = new Mutex(Mutex::special, "mutex_rank_special", Mutex::_safepoint_check_never); + Mutex* mutex_rank_nosafepoint = new Mutex(Mutex::nosafepoint, "mutex_rank_nosafepoint", Mutex::_safepoint_check_never); mutex_rank_tty->lock_without_safepoint_check(); - mutex_rank_special->lock_without_safepoint_check(); - mutex_rank_special->unlock(); + mutex_rank_nosafepoint->lock_without_safepoint_check(); + mutex_rank_nosafepoint->unlock(); mutex_rank_tty->unlock(); } @@ -204,20 +204,20 @@ TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_out_of_order_trylock, monitor_rankA->unlock(); } -TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_special, - ".* Attempting to wait on monitor monitor_rank_special_minus_one/.* while holding lock monitor_rank_special/.*" +TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_nosafepoint, + ".* Attempting to wait on monitor monitor_rank_nosafepoint_minus_one/.* while holding lock monitor_rank_nosafepoint/.*" "-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank nosafepoint or below.") { JavaThread* THREAD = JavaThread::current(); ThreadInVMfromNative invm(THREAD); - Monitor* monitor_rank_special = new Monitor(Mutex::special, "monitor_rank_special", Mutex::_safepoint_check_never); - Monitor* monitor_rank_special_minus_one = new Monitor(Mutex::special - 1, "monitor_rank_special_minus_one", Mutex::_safepoint_check_never); + Monitor* monitor_rank_nosafepoint = new Monitor(Mutex::nosafepoint, "monitor_rank_nosafepoint", Mutex::_safepoint_check_never); + Monitor* monitor_rank_nosafepoint_minus_one = new Monitor(Mutex::nosafepoint - 1, "monitor_rank_nosafepoint_minus_one", Mutex::_safepoint_check_never); - monitor_rank_special->lock_without_safepoint_check(); - monitor_rank_special_minus_one->lock_without_safepoint_check(); - monitor_rank_special_minus_one->wait_without_safepoint_check(1); - monitor_rank_special_minus_one->unlock(); - monitor_rank_special->unlock(); + monitor_rank_nosafepoint->lock_without_safepoint_check(); + monitor_rank_nosafepoint_minus_one->lock_without_safepoint_check(); + monitor_rank_nosafepoint_minus_one->wait_without_safepoint_check(1); + monitor_rank_nosafepoint_minus_one->unlock(); + monitor_rank_nosafepoint->unlock(); } TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_event_tty, @@ -236,30 +236,30 @@ TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_event_tty, monitor_rank_tty->unlock(); } -TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_tty_special, - ".* Attempting to wait on monitor monitor_rank_tty/.* while holding lock monitor_rank_special/.*" +TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_tty_nosafepoint, + ".* Attempting to wait on monitor monitor_rank_tty/.* while holding lock monitor_rank_nosafepoint/.*" "-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank nosafepoint or below.") { JavaThread* THREAD = JavaThread::current(); ThreadInVMfromNative invm(THREAD); - Monitor* monitor_rank_special = new Monitor(Mutex::special, "monitor_rank_special", Mutex::_safepoint_check_never); + Monitor* monitor_rank_nosafepoint = new Monitor(Mutex::nosafepoint, "monitor_rank_nosafepoint", Mutex::_safepoint_check_never); Monitor* monitor_rank_tty = new Monitor(Mutex::tty, "monitor_rank_tty", Mutex::_safepoint_check_never); - monitor_rank_special->lock_without_safepoint_check(); + monitor_rank_nosafepoint->lock_without_safepoint_check(); monitor_rank_tty->lock_without_safepoint_check(); monitor_rank_tty->wait_without_safepoint_check(1); monitor_rank_tty->unlock(); - monitor_rank_special->unlock(); + monitor_rank_nosafepoint->unlock(); } -TEST_VM_ASSERT_MSG(MutexRank, monitor_special_vm_block, +TEST_VM_ASSERT_MSG(MutexRank, monitor_nosafepoint_vm_block, ".*Safepoint check never locks should always allow the vm to block") { JavaThread* THREAD = JavaThread::current(); ThreadInVMfromNative invm(THREAD); - Monitor* monitor_rank_special = new Monitor(Mutex::special, "monitor_rank_special", Mutex::_safepoint_check_never, false); - monitor_rank_special->lock_without_safepoint_check(); - monitor_rank_special->unlock(); + Monitor* monitor_rank_nosafepoint = new Monitor(Mutex::nosafepoint, "monitor_rank_nosafepoint", Mutex::_safepoint_check_never, false); + monitor_rank_nosafepoint->lock_without_safepoint_check(); + monitor_rank_nosafepoint->unlock(); } TEST_VM_ASSERT_MSG(MutexRank, monitor_negative_rank, diff --git a/test/hotspot/gtest/runtime/test_safepoint_locks.cpp b/test/hotspot/gtest/runtime/test_safepoint_locks.cpp index a1050b7b87494..6b6d68ccb5554 100644 --- a/test/hotspot/gtest/runtime/test_safepoint_locks.cpp +++ b/test/hotspot/gtest/runtime/test_safepoint_locks.cpp @@ -42,9 +42,9 @@ TEST_VM_ASSERT_MSG(SafepointLockAssertTest, never_check, Mutex::_safepoint_check_flag); } -TEST_VM_ASSERT_MSG(SafepointLockAssertTest, special_locks, +TEST_VM_ASSERT_MSG(SafepointLockAssertTest, nosafepoint_locks, ".*Locks below nosafepoint rank should never safepoint: SpecialTest_lock") { - MutexLocker ml(new Mutex(Mutex::special, "SpecialTest_lock", Mutex::_safepoint_check_always), + MutexLocker ml(new Mutex(Mutex::nosafepoint, "SpecialTest_lock", Mutex::_safepoint_check_always), Mutex::_safepoint_check_flag); } @@ -52,10 +52,10 @@ TEST_VM_ASSERT_MSG(SafepointLockAssertTest, possible_safepoint_lock, ".* Possible safepoint reached by thread that does not allow it") { JavaThread* thread = JavaThread::current(); ThreadInVMfromNative in_native(thread); - MutexLocker ml(new Mutex(Mutex::special, "SpecialTest_lock", Mutex::_safepoint_check_never), + MutexLocker ml(new Mutex(Mutex::nosafepoint, "SpecialTest_lock", Mutex::_safepoint_check_never), Mutex::_no_safepoint_check_flag); thread->print_thread_state_on(tty); - // If the lock above succeeds, try to safepoint to test the NSV implied with this special lock. + // If the lock above succeeds, try to safepoint to test the NSV implied with this nosafepoint lock. ThreadBlockInVM tbivm(thread); thread->print_thread_state_on(tty); }