109
110 Mutex* tty_lock = NULL;
111
112 Mutex* RawMonitor_lock = NULL;
113 Mutex* PerfDataMemAlloc_lock = NULL;
114 Mutex* PerfDataManager_lock = NULL;
115 Mutex* OopMapCacheAlloc_lock = NULL;
116
117 Mutex* FreeList_lock = NULL;
118 Monitor* SecondaryFreeList_lock = NULL;
119 Mutex* OldSets_lock = NULL;
120 Monitor* RootRegionScan_lock = NULL;
121 Mutex* MMUTracker_lock = NULL;
122
123 Monitor* GCTaskManager_lock = NULL;
124
125 Mutex* Management_lock = NULL;
126 Monitor* Service_lock = NULL;
127 Monitor* PeriodicTask_lock = NULL;
128
129 #ifdef INCLUDE_TRACE
130 Mutex* JfrStacktrace_lock = NULL;
131 Monitor* JfrMsg_lock = NULL;
132 Mutex* JfrBuffer_lock = NULL;
133 Mutex* JfrStream_lock = NULL;
134 Mutex* JfrThreadGroups_lock = NULL;
135 #endif
136
137 #ifndef SUPPORTS_NATIVE_CX8
138 Mutex* UnsafeJlong_lock = NULL;
139 #endif
140
141 #define MAX_NUM_MUTEX 128
142 static Monitor * _mutex_array[MAX_NUM_MUTEX];
143 static int _num_mutex;
144
145 #ifdef ASSERT
146 void assert_locked_or_safepoint(const Monitor * lock) {
147 // check if this thread owns the lock (common case)
148 if (IgnoreLockingAssertions) return;
149 assert(lock != NULL, "Need non-NULL lock");
150 if (lock->owned_by_self()) return;
151 if (SafepointSynchronize::is_at_safepoint()) return;
152 if (!Universe::is_fully_initialized()) return;
153 // see if invoker of VM operation owns it
154 VM_Operation* op = VMThread::vm_operation();
263
264 def(CompiledIC_lock , Mutex , nonleaf+2, false); // locks VtableStubs_lock, InlineCacheBuffer_lock
265 def(CompileTaskAlloc_lock , Mutex , nonleaf+2, true );
266 def(CompileStatistics_lock , Mutex , nonleaf+2, false);
267 def(MultiArray_lock , Mutex , nonleaf+2, false); // locks SymbolTable_lock
268
269 def(JvmtiThreadState_lock , Mutex , nonleaf+2, false); // Used by JvmtiThreadState/JvmtiEventController
270 def(JvmtiPendingEvent_lock , Monitor, nonleaf, false); // Used by JvmtiCodeBlobEvents
271 def(Management_lock , Mutex , nonleaf+2, false); // used for JVM management
272
273 def(Compile_lock , Mutex , nonleaf+3, true );
274 def(MethodData_lock , Mutex , nonleaf+3, false);
275
276 def(MethodCompileQueue_lock , Monitor, nonleaf+4, true );
277 def(Debug2_lock , Mutex , nonleaf+4, true );
278 def(Debug3_lock , Mutex , nonleaf+4, true );
279 def(ProfileVM_lock , Monitor, special, false); // used for profiling of the VMThread
280 def(CompileThread_lock , Monitor, nonleaf+5, false );
281 def(PeriodicTask_lock , Monitor, nonleaf+5, true);
282
283 #ifdef INCLUDE_TRACE
284 def(JfrMsg_lock , Monitor, leaf, true);
285 def(JfrBuffer_lock , Mutex, leaf, true);
286 def(JfrThreadGroups_lock , Mutex, leaf, true);
287 def(JfrStream_lock , Mutex, nonleaf, true);
288 def(JfrStacktrace_lock , Mutex, special, true);
289 #endif
290
291 #ifndef SUPPORTS_NATIVE_CX8
292 def(UnsafeJlong_lock , Mutex, special, false);
293 #endif
294 }
295
296 GCMutexLocker::GCMutexLocker(Monitor * mutex) {
297 if (SafepointSynchronize::is_at_safepoint()) {
298 _locked = false;
299 } else {
300 _mutex = mutex;
301 _locked = true;
302 _mutex->lock();
303 }
304 }
305
306 // Print all mutexes/monitors that are currently owned by a thread; called
307 // by fatal error handler.
308 void print_owned_locks_on_error(outputStream* st) {
|
109
110 Mutex* tty_lock = NULL;
111
112 Mutex* RawMonitor_lock = NULL;
113 Mutex* PerfDataMemAlloc_lock = NULL;
114 Mutex* PerfDataManager_lock = NULL;
115 Mutex* OopMapCacheAlloc_lock = NULL;
116
117 Mutex* FreeList_lock = NULL;
118 Monitor* SecondaryFreeList_lock = NULL;
119 Mutex* OldSets_lock = NULL;
120 Monitor* RootRegionScan_lock = NULL;
121 Mutex* MMUTracker_lock = NULL;
122
123 Monitor* GCTaskManager_lock = NULL;
124
125 Mutex* Management_lock = NULL;
126 Monitor* Service_lock = NULL;
127 Monitor* PeriodicTask_lock = NULL;
128
129 #ifdef INCLUDE_JFR
130 Mutex* JfrStacktrace_lock = NULL;
131 Monitor* JfrMsg_lock = NULL;
132 Mutex* JfrBuffer_lock = NULL;
133 Mutex* JfrStream_lock = NULL;
134 Mutex* JfrThreadGroups_lock = NULL;
135
136 #ifndef SUPPORTS_NATIVE_CX8
137 Mutex* JfrCounters_lock = NULL;
138 #endif
139 #endif
140
141 #ifndef SUPPORTS_NATIVE_CX8
142 Mutex* UnsafeJlong_lock = NULL;
143 #endif
144
145 #define MAX_NUM_MUTEX 128
146 static Monitor * _mutex_array[MAX_NUM_MUTEX];
147 static int _num_mutex;
148
149 #ifdef ASSERT
150 void assert_locked_or_safepoint(const Monitor * lock) {
151 // check if this thread owns the lock (common case)
152 if (IgnoreLockingAssertions) return;
153 assert(lock != NULL, "Need non-NULL lock");
154 if (lock->owned_by_self()) return;
155 if (SafepointSynchronize::is_at_safepoint()) return;
156 if (!Universe::is_fully_initialized()) return;
157 // see if invoker of VM operation owns it
158 VM_Operation* op = VMThread::vm_operation();
267
268 def(CompiledIC_lock , Mutex , nonleaf+2, false); // locks VtableStubs_lock, InlineCacheBuffer_lock
269 def(CompileTaskAlloc_lock , Mutex , nonleaf+2, true );
270 def(CompileStatistics_lock , Mutex , nonleaf+2, false);
271 def(MultiArray_lock , Mutex , nonleaf+2, false); // locks SymbolTable_lock
272
273 def(JvmtiThreadState_lock , Mutex , nonleaf+2, false); // Used by JvmtiThreadState/JvmtiEventController
274 def(JvmtiPendingEvent_lock , Monitor, nonleaf, false); // Used by JvmtiCodeBlobEvents
275 def(Management_lock , Mutex , nonleaf+2, false); // used for JVM management
276
277 def(Compile_lock , Mutex , nonleaf+3, true );
278 def(MethodData_lock , Mutex , nonleaf+3, false);
279
280 def(MethodCompileQueue_lock , Monitor, nonleaf+4, true );
281 def(Debug2_lock , Mutex , nonleaf+4, true );
282 def(Debug3_lock , Mutex , nonleaf+4, true );
283 def(ProfileVM_lock , Monitor, special, false); // used for profiling of the VMThread
284 def(CompileThread_lock , Monitor, nonleaf+5, false );
285 def(PeriodicTask_lock , Monitor, nonleaf+5, true);
286
287 #ifdef INCLUDE_JFR
288 def(JfrMsg_lock , Monitor, leaf, true);
289 def(JfrBuffer_lock , Mutex, leaf, true);
290 def(JfrThreadGroups_lock , Mutex, leaf, true);
291 def(JfrStream_lock , Mutex, nonleaf, true);
292 def(JfrStacktrace_lock , Mutex, special, true);
293
294 #ifndef SUPPORTS_NATIVE_CX8
295 def(JfrCounters_lock , Mutex, special, false);
296 #endif
297 #endif
298
299 #ifndef SUPPORTS_NATIVE_CX8
300 def(UnsafeJlong_lock , Mutex, special, false);
301 #endif
302 }
303
304 GCMutexLocker::GCMutexLocker(Monitor * mutex) {
305 if (SafepointSynchronize::is_at_safepoint()) {
306 _locked = false;
307 } else {
308 _mutex = mutex;
309 _locked = true;
310 _mutex->lock();
311 }
312 }
313
314 // Print all mutexes/monitors that are currently owned by a thread; called
315 // by fatal error handler.
316 void print_owned_locks_on_error(outputStream* st) {
|