133
134 #ifndef SUPPORTS_NATIVE_CX8
135 Mutex* UnsafeJlong_lock = NULL;
136 #endif
137 Mutex* CodeHeapStateAnalytics_lock = NULL;
138
139 Mutex* MetaspaceExpand_lock = NULL;
140 Mutex* ClassLoaderDataGraph_lock = NULL;
141 Monitor* ThreadsSMRDelete_lock = NULL;
142 Mutex* ThreadIdTableCreate_lock = NULL;
143 Mutex* SharedDecoder_lock = NULL;
144 Mutex* DCmdFactory_lock = NULL;
145 #if INCLUDE_NMT
146 Mutex* NMTQuery_lock = NULL;
147 #endif
148 #if INCLUDE_CDS
149 #if INCLUDE_JVMTI
150 Mutex* CDSClassFileStream_lock = NULL;
151 #endif
152 Mutex* DumpTimeTable_lock = NULL;
153 #endif // INCLUDE_CDS
154
155 #if INCLUDE_JVMCI
156 Monitor* JVMCI_lock = NULL;
157 #endif
158
159
160 #define MAX_NUM_MUTEX 128
161 static Mutex* _mutex_array[MAX_NUM_MUTEX];
162 static int _num_mutex;
163
164 #ifdef ASSERT
165 void assert_locked_or_safepoint(const Mutex* lock) {
166 // check if this thread owns the lock (common case)
167 assert(lock != NULL, "Need non-NULL lock");
168 if (lock->owned_by_self()) return;
169 if (SafepointSynchronize::is_at_safepoint()) return;
170 if (!Universe::is_fully_initialized()) return;
171 // see if invoker of VM operation owns it
172 VM_Operation* op = VMThread::vm_operation();
327 #endif
328
329 #ifndef SUPPORTS_NATIVE_CX8
330 def(UnsafeJlong_lock , PaddedMutex , special, false, _safepoint_check_never);
331 #endif
332
333 def(CodeHeapStateAnalytics_lock , PaddedMutex , leaf, true, _safepoint_check_never);
334 def(NMethodSweeperStats_lock , PaddedMutex , special, true, _safepoint_check_never);
335 def(ThreadsSMRDelete_lock , PaddedMonitor, special, true, _safepoint_check_never);
336 def(ThreadIdTableCreate_lock , PaddedMutex , leaf, false, _safepoint_check_always);
337 def(SharedDecoder_lock , PaddedMutex , native, true, _safepoint_check_never);
338 def(DCmdFactory_lock , PaddedMutex , leaf, true, _safepoint_check_never);
339 #if INCLUDE_NMT
340 def(NMTQuery_lock , PaddedMutex , max_nonleaf, false, _safepoint_check_always);
341 #endif
342 #if INCLUDE_CDS
343 #if INCLUDE_JVMTI
344 def(CDSClassFileStream_lock , PaddedMutex , max_nonleaf, false, _safepoint_check_always);
345 #endif
346 def(DumpTimeTable_lock , PaddedMutex , leaf - 1, true, _safepoint_check_never);
347 #endif // INCLUDE_CDS
348
349 #if INCLUDE_JVMCI
350 def(JVMCI_lock , PaddedMonitor, nonleaf+2, true, _safepoint_check_always);
351 #endif
352 }
353
354 GCMutexLocker::GCMutexLocker(Mutex* mutex) {
355 if (SafepointSynchronize::is_at_safepoint()) {
356 _locked = false;
357 } else {
358 _mutex = mutex;
359 _locked = true;
360 _mutex->lock();
361 }
362 }
363
364 // Print all mutexes/monitors that are currently owned by a thread; called
365 // by fatal error handler.
366 void print_owned_locks_on_error(outputStream* st) {
|
133
134 #ifndef SUPPORTS_NATIVE_CX8
135 Mutex* UnsafeJlong_lock = NULL;
136 #endif
137 Mutex* CodeHeapStateAnalytics_lock = NULL;
138
139 Mutex* MetaspaceExpand_lock = NULL;
140 Mutex* ClassLoaderDataGraph_lock = NULL;
141 Monitor* ThreadsSMRDelete_lock = NULL;
142 Mutex* ThreadIdTableCreate_lock = NULL;
143 Mutex* SharedDecoder_lock = NULL;
144 Mutex* DCmdFactory_lock = NULL;
145 #if INCLUDE_NMT
146 Mutex* NMTQuery_lock = NULL;
147 #endif
148 #if INCLUDE_CDS
149 #if INCLUDE_JVMTI
150 Mutex* CDSClassFileStream_lock = NULL;
151 #endif
152 Mutex* DumpTimeTable_lock = NULL;
153 Mutex* CDSLambda_lock = NULL;
154 #endif // INCLUDE_CDS
155
156 #if INCLUDE_JVMCI
157 Monitor* JVMCI_lock = NULL;
158 #endif
159
160
161 #define MAX_NUM_MUTEX 128
162 static Mutex* _mutex_array[MAX_NUM_MUTEX];
163 static int _num_mutex;
164
165 #ifdef ASSERT
166 void assert_locked_or_safepoint(const Mutex* lock) {
167 // check if this thread owns the lock (common case)
168 assert(lock != NULL, "Need non-NULL lock");
169 if (lock->owned_by_self()) return;
170 if (SafepointSynchronize::is_at_safepoint()) return;
171 if (!Universe::is_fully_initialized()) return;
172 // see if invoker of VM operation owns it
173 VM_Operation* op = VMThread::vm_operation();
328 #endif
329
330 #ifndef SUPPORTS_NATIVE_CX8
331 def(UnsafeJlong_lock , PaddedMutex , special, false, _safepoint_check_never);
332 #endif
333
334 def(CodeHeapStateAnalytics_lock , PaddedMutex , leaf, true, _safepoint_check_never);
335 def(NMethodSweeperStats_lock , PaddedMutex , special, true, _safepoint_check_never);
336 def(ThreadsSMRDelete_lock , PaddedMonitor, special, true, _safepoint_check_never);
337 def(ThreadIdTableCreate_lock , PaddedMutex , leaf, false, _safepoint_check_always);
338 def(SharedDecoder_lock , PaddedMutex , native, true, _safepoint_check_never);
339 def(DCmdFactory_lock , PaddedMutex , leaf, true, _safepoint_check_never);
340 #if INCLUDE_NMT
341 def(NMTQuery_lock , PaddedMutex , max_nonleaf, false, _safepoint_check_always);
342 #endif
343 #if INCLUDE_CDS
344 #if INCLUDE_JVMTI
345 def(CDSClassFileStream_lock , PaddedMutex , max_nonleaf, false, _safepoint_check_always);
346 #endif
347 def(DumpTimeTable_lock , PaddedMutex , leaf - 1, true, _safepoint_check_never);
348 def(CDSLambda_lock , PaddedMutex , leaf, true, _safepoint_check_never);
349 #endif // INCLUDE_CDS
350
351 #if INCLUDE_JVMCI
352 def(JVMCI_lock , PaddedMonitor, nonleaf+2, true, _safepoint_check_always);
353 #endif
354 }
355
356 GCMutexLocker::GCMutexLocker(Mutex* mutex) {
357 if (SafepointSynchronize::is_at_safepoint()) {
358 _locked = false;
359 } else {
360 _mutex = mutex;
361 _locked = true;
362 _mutex->lock();
363 }
364 }
365
366 // Print all mutexes/monitors that are currently owned by a thread; called
367 // by fatal error handler.
368 void print_owned_locks_on_error(outputStream* st) {
|