< prev index next >

src/hotspot/share/runtime/mutexLocker.hpp

Print this page

        

*** 140,150 **** extern Mutex* MetaspaceExpand_lock; // protects Metaspace virtualspace and chunk expansions extern Mutex* ClassLoaderDataGraph_lock; // protects CLDG list, needed for concurrent unloading ! extern Monitor* CodeHeapStateAnalytics_lock; // lock print functions against concurrent analyze functions. // Only used locally in PrintCodeCacheLayout processing. #if INCLUDE_JVMCI extern Monitor* JVMCI_lock; // Monitor to control initialization of JVMCI #endif --- 140,150 ---- extern Mutex* MetaspaceExpand_lock; // protects Metaspace virtualspace and chunk expansions extern Mutex* ClassLoaderDataGraph_lock; // protects CLDG list, needed for concurrent unloading ! extern Mutex* CodeHeapStateAnalytics_lock; // lock print functions against concurrent analyze functions. // Only used locally in PrintCodeCacheLayout processing. #if INCLUDE_JVMCI extern Monitor* JVMCI_lock; // Monitor to control initialization of JVMCI #endif
*** 169,193 **** char *lock_name(Mutex *mutex); // for debugging: check that we're already owning this lock (or are at a safepoint) #ifdef ASSERT ! void assert_locked_or_safepoint(const Monitor * lock); ! void assert_locked_or_safepoint_weak(const Monitor * lock); ! void assert_lock_strong(const Monitor * lock); #else #define assert_locked_or_safepoint(lock) #define assert_locked_or_safepoint_weak(lock) #define assert_lock_strong(lock) #endif class MutexLocker: public StackObj { protected: ! Monitor* _mutex; private: public: ! MutexLocker(Monitor* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : _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"); --- 169,193 ---- char *lock_name(Mutex *mutex); // for debugging: check that we're already owning this lock (or are at a safepoint) #ifdef ASSERT ! void assert_locked_or_safepoint(const Mutex* lock); ! void assert_locked_or_safepoint_weak(const Mutex* lock); ! void assert_lock_strong(const Mutex* lock); #else #define assert_locked_or_safepoint(lock) #define assert_locked_or_safepoint_weak(lock) #define assert_lock_strong(lock) #endif class MutexLocker: public StackObj { protected: ! Mutex* _mutex; private: public: ! MutexLocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : _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");
*** 197,207 **** _mutex->lock(); } } } ! MutexLocker(Monitor* mutex, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : _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"); --- 197,207 ---- _mutex->lock(); } } } ! MutexLocker(Mutex* mutex, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : _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");
*** 225,263 **** // wait/notify as well which are delegated to the underlying Monitor. // It also disallows NULL. class MonitorLocker: public MutexLocker { Mutex::SafepointCheckFlag _flag; public: MonitorLocker(Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : ! MutexLocker(monitor, flag), _flag(flag) { // Superclass constructor did locking ! assert(_mutex != NULL, "NULL monitor not allowed"); } MonitorLocker(Monitor* monitor, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : ! MutexLocker(monitor, thread, flag), _flag(flag) { // Superclass constructor did locking ! assert(_mutex != NULL, "NULL monitor not allowed"); } bool wait(long timeout = 0, bool as_suspend_equivalent = !Mutex::_as_suspend_equivalent_flag) { if (_flag == Mutex::_safepoint_check_flag) { ! return _mutex->wait(timeout, as_suspend_equivalent); } else { ! return _mutex->wait_without_safepoint_check(timeout); } return false; } void notify_all() { ! _mutex->notify_all(); } void notify() { ! _mutex->notify(); } }; // A GCMutexLocker is usually initialized with a mutex that is --- 225,264 ---- // wait/notify as well which are delegated to the underlying Monitor. // It also disallows NULL. class MonitorLocker: public MutexLocker { Mutex::SafepointCheckFlag _flag; + Monitor* _monitor; public: MonitorLocker(Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : ! MutexLocker(monitor, flag), _flag(flag), _monitor(monitor) { // Superclass constructor did locking ! assert(_monitor != NULL, "NULL monitor not allowed"); } MonitorLocker(Monitor* monitor, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : ! MutexLocker(monitor, thread, flag), _flag(flag), _monitor(monitor) { // Superclass constructor did locking ! assert(_monitor != NULL, "NULL monitor not allowed"); } bool wait(long timeout = 0, bool as_suspend_equivalent = !Mutex::_as_suspend_equivalent_flag) { if (_flag == Mutex::_safepoint_check_flag) { ! return _monitor->wait(timeout, as_suspend_equivalent); } else { ! return _monitor->wait_without_safepoint_check(timeout); } return false; } void notify_all() { ! _monitor->notify_all(); } void notify() { ! _monitor->notify(); } }; // A GCMutexLocker is usually initialized with a mutex that is
*** 266,292 **** // GC's. Thus, it must acquire the mutex if GC is not in progress, but not // if GC is in progress (since the mutex is already held on its behalf.) class GCMutexLocker: public StackObj { private: ! Monitor* _mutex; bool _locked; public: ! GCMutexLocker(Monitor* mutex); ~GCMutexLocker() { if (_locked) _mutex->unlock(); } }; // A MutexUnlocker temporarily exits a previously // entered mutex for the scope which contains the unlocker. class MutexUnlocker: StackObj { private: ! Monitor* _mutex; bool _no_safepoint_check; public: ! MutexUnlocker(Monitor* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : _mutex(mutex), _no_safepoint_check(flag) { _mutex->unlock(); } --- 267,293 ---- // GC's. Thus, it must acquire the mutex if GC is not in progress, but not // if GC is in progress (since the mutex is already held on its behalf.) class GCMutexLocker: public StackObj { private: ! Mutex* _mutex; bool _locked; public: ! GCMutexLocker(Mutex* mutex); ~GCMutexLocker() { if (_locked) _mutex->unlock(); } }; // A MutexUnlocker temporarily exits a previously // entered mutex for the scope which contains the unlocker. class MutexUnlocker: StackObj { private: ! Mutex* _mutex; bool _no_safepoint_check; public: ! MutexUnlocker(Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : _mutex(mutex), _no_safepoint_check(flag) { _mutex->unlock(); }
< prev index next >