annotate src/hotspot/share/runtime/mutexLocker.cpp @ 52291:35a6956f4243

8209976: Improve iteration over non-JavaThreads Summary: Add NonJavaThread and move NamedThread iteration to new class. Reviewed-by: eosterlund, coleenp, rkennke
author kbarrett
date Tue, 28 Aug 2018 16:04:54 -0400
parents 1f0b605bdc28
children 625a5bdde0c5
rev   line source
duke@1 1 /*
kbarrett@49171 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #include "precompiled.hpp"
stefank@7397 26 #include "runtime/mutexLocker.hpp"
goetz@25468 27 #include "runtime/os.inline.hpp"
stefank@7397 28 #include "runtime/safepoint.hpp"
stefank@14583 29 #include "runtime/thread.inline.hpp"
stefank@7397 30 #include "runtime/vmThread.hpp"
duke@1 31
duke@1 32 // Mutexes used in the VM (see comment in mutexLocker.hpp):
duke@1 33 //
duke@1 34 // Note that the following pointers are effectively final -- after having been
duke@1 35 // set at JVM startup-time, they should never be subsequently mutated.
duke@1 36 // Instead of using pointers to malloc()ed monitors and mutexes we should consider
duke@1 37 // eliminating the indirection and using instances instead.
duke@1 38 // Consider using GCC's __read_mostly.
duke@1 39
duke@1 40 Mutex* Patching_lock = NULL;
duke@1 41 Monitor* SystemDictionary_lock = NULL;
iklam@50701 42 Mutex* SharedDictionary_lock = NULL;
alanb@36508 43 Mutex* Module_lock = NULL;
duke@1 44 Mutex* CompiledIC_lock = NULL;
duke@1 45 Mutex* InlineCacheBuffer_lock = NULL;
duke@1 46 Mutex* VMStatistic_lock = NULL;
kbarrett@49171 47 Mutex* JNIGlobalAlloc_lock = NULL;
kbarrett@49171 48 Mutex* JNIGlobalActive_lock = NULL;
kbarrett@49171 49 Mutex* JNIWeakAlloc_lock = NULL;
kbarrett@49171 50 Mutex* JNIWeakActive_lock = NULL;
rehn@51049 51 Mutex* StringTableWeakAlloc_lock = NULL;
rehn@51049 52 Mutex* StringTableWeakActive_lock = NULL;
duke@1 53 Mutex* JNIHandleBlockFreeList_lock = NULL;
coleenp@50233 54 Mutex* VMWeakAlloc_lock = NULL;
coleenp@50233 55 Mutex* VMWeakActive_lock = NULL;
coleenp@46505 56 Mutex* ResolvedMethodTable_lock = NULL;
duke@1 57 Mutex* JmethodIdCreation_lock = NULL;
duke@1 58 Mutex* JfieldIdCreation_lock = NULL;
duke@1 59 Monitor* JNICritical_lock = NULL;
duke@1 60 Mutex* JvmtiThreadState_lock = NULL;
ysr@1374 61 Monitor* Heap_lock = NULL;
duke@1 62 Mutex* ExpandHeap_lock = NULL;
duke@1 63 Mutex* AdapterHandlerLibrary_lock = NULL;
duke@1 64 Mutex* SignatureHandlerLibrary_lock = NULL;
duke@1 65 Mutex* VtableStubs_lock = NULL;
gziemski@52263 66 Mutex* SymbolArena_lock = NULL;
duke@1 67 Mutex* StringTable_lock = NULL;
pliden@23472 68 Monitor* StringDedupQueue_lock = NULL;
pliden@23472 69 Mutex* StringDedupTable_lock = NULL;
anoll@27420 70 Monitor* CodeCache_lock = NULL;
duke@1 71 Mutex* MethodData_lock = NULL;
minqi@31790 72 Mutex* TouchedMethodLog_lock = NULL;
duke@1 73 Mutex* RetData_lock = NULL;
duke@1 74 Monitor* VMOperationQueue_lock = NULL;
duke@1 75 Monitor* VMOperationRequest_lock = NULL;
duke@1 76 Monitor* Safepoint_lock = NULL;
duke@1 77 Monitor* SerializePage_lock = NULL;
duke@1 78 Monitor* Threads_lock = NULL;
kbarrett@52291 79 Mutex* NonJavaThreadsList_lock = NULL;
duke@1 80 Monitor* CGC_lock = NULL;
pliden@24094 81 Monitor* STS_lock = NULL;
duke@1 82 Monitor* FullGCCount_lock = NULL;
ysr@1374 83 Mutex* SATB_Q_FL_lock = NULL;
ysr@1374 84 Monitor* SATB_Q_CBL_mon = NULL;
ysr@1374 85 Mutex* Shared_SATB_Q_lock = NULL;
ysr@1374 86 Mutex* DirtyCardQ_FL_lock = NULL;
ysr@1374 87 Monitor* DirtyCardQ_CBL_mon = NULL;
ysr@1374 88 Mutex* Shared_DirtyCardQ_lock = NULL;
tschatzl@41176 89 Mutex* MarkStackFreeList_lock = NULL;
tschatzl@41176 90 Mutex* MarkStackChunkList_lock = NULL;
duke@1 91 Mutex* ParGCRareEvent_lock = NULL;
duke@1 92 Mutex* DerivedPointerTableGC_lock = NULL;
kbarrett@46384 93 Monitor* CGCPhaseManager_lock = NULL;
duke@1 94 Mutex* Compile_lock = NULL;
duke@1 95 Monitor* MethodCompileQueue_lock = NULL;
duke@1 96 Monitor* CompileThread_lock = NULL;
iignatyev@27642 97 Monitor* Compilation_lock = NULL;
duke@1 98 Mutex* CompileTaskAlloc_lock = NULL;
duke@1 99 Mutex* CompileStatistics_lock = NULL;
neliasso@33451 100 Mutex* DirectivesStack_lock = NULL;
duke@1 101 Mutex* MultiArray_lock = NULL;
duke@1 102 Monitor* Terminator_lock = NULL;
duke@1 103 Monitor* BeforeExit_lock = NULL;
duke@1 104 Monitor* Notify_lock = NULL;
duke@1 105 Mutex* ProfilePrint_lock = NULL;
duke@1 106 Mutex* ExceptionCache_lock = NULL;
duke@1 107 Mutex* OsrList_lock = NULL;
jfdenise@31608 108
duke@1 109 #ifndef PRODUCT
duke@1 110 Mutex* FullGCALot_lock = NULL;
duke@1 111 #endif
duke@1 112
duke@1 113 Mutex* Debug1_lock = NULL;
duke@1 114 Mutex* Debug2_lock = NULL;
duke@1 115 Mutex* Debug3_lock = NULL;
duke@1 116
duke@1 117 Mutex* tty_lock = NULL;
duke@1 118
duke@1 119 Mutex* RawMonitor_lock = NULL;
duke@1 120 Mutex* PerfDataMemAlloc_lock = NULL;
duke@1 121 Mutex* PerfDataManager_lock = NULL;
duke@1 122 Mutex* OopMapCacheAlloc_lock = NULL;
duke@1 123
tonyp@7923 124 Mutex* FreeList_lock = NULL;
tonyp@7923 125 Mutex* OldSets_lock = NULL;
tonyp@11584 126 Monitor* RootRegionScan_lock = NULL;
ysr@1374 127
duke@1 128 Monitor* GCTaskManager_lock = NULL;
duke@1 129
duke@1 130 Mutex* Management_lock = NULL;
phh@11480 131 Monitor* Service_lock = NULL;
mgronlun@19542 132 Monitor* PeriodicTask_lock = NULL;
coleenp@38309 133 Monitor* RedefineClasses_lock = NULL;
phh@11480 134
jcbeyler@51212 135 Mutex* ThreadHeapSampler_lock = NULL;
jcbeyler@51212 136
egahlin@50662 137 #if INCLUDE_JFR
mgronlun@19542 138 Mutex* JfrStacktrace_lock = NULL;
phh@11480 139 Monitor* JfrMsg_lock = NULL;
phh@11480 140 Mutex* JfrBuffer_lock = NULL;
phh@11480 141 Mutex* JfrStream_lock = NULL;
mgronlun@19542 142 #endif
duke@1 143
dholmes@27874 144 #ifndef SUPPORTS_NATIVE_CX8
dholmes@27874 145 Mutex* UnsafeJlong_lock = NULL;
dholmes@27874 146 #endif
lucy@50106 147 Monitor* CodeHeapStateAnalytics_lock = NULL;
dholmes@27874 148
coleenp@50096 149 Mutex* MetaspaceExpand_lock = NULL;
coleenp@50096 150
duke@1 151 #define MAX_NUM_MUTEX 128
duke@1 152 static Monitor * _mutex_array[MAX_NUM_MUTEX];
duke@1 153 static int _num_mutex;
duke@1 154
duke@1 155 #ifdef ASSERT
duke@1 156 void assert_locked_or_safepoint(const Monitor * lock) {
duke@1 157 // check if this thread owns the lock (common case)
duke@1 158 if (IgnoreLockingAssertions) return;
duke@1 159 assert(lock != NULL, "Need non-NULL lock");
duke@1 160 if (lock->owned_by_self()) return;
duke@1 161 if (SafepointSynchronize::is_at_safepoint()) return;
duke@1 162 if (!Universe::is_fully_initialized()) return;
duke@1 163 // see if invoker of VM operation owns it
duke@1 164 VM_Operation* op = VMThread::vm_operation();
duke@1 165 if (op != NULL && op->calling_thread() == lock->owner()) return;
david@33105 166 fatal("must own lock %s", lock->name());
duke@1 167 }
duke@1 168
duke@1 169 // a stronger assertion than the above
duke@1 170 void assert_lock_strong(const Monitor * lock) {
duke@1 171 if (IgnoreLockingAssertions) return;
duke@1 172 assert(lock != NULL, "Need non-NULL lock");
duke@1 173 if (lock->owned_by_self()) return;
david@33105 174 fatal("must own lock %s", lock->name());
duke@1 175 }
duke@1 176 #endif
duke@1 177
coleenp@28163 178 #define def(var, type, pri, vm_block, safepoint_check_allowed ) { \
coleenp@28163 179 var = new type(Mutex::pri, #var, vm_block, safepoint_check_allowed); \
coleenp@28163 180 assert(_num_mutex < MAX_NUM_MUTEX, "increase MAX_NUM_MUTEX"); \
mockner@30108 181 _mutex_array[_num_mutex++] = var; \
duke@1 182 }
duke@1 183
mdoerr@41710 184 // Using Padded subclasses to prevent false sharing of these global monitors and mutexes.
duke@1 185 void mutex_init() {
mdoerr@41710 186 def(tty_lock , PaddedMutex , event, true, Monitor::_safepoint_check_never); // allow to lock in VM
duke@1 187
mdoerr@41710 188 def(CGC_lock , PaddedMonitor, special, true, Monitor::_safepoint_check_never); // coordinate between fore- and background GC
mdoerr@41710 189 def(STS_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never);
coleenp@28163 190
coleenp@50313 191 def(VMWeakAlloc_lock , PaddedMutex , vmweak, true, Monitor::_safepoint_check_never);
coleenp@50313 192 def(VMWeakActive_lock , PaddedMutex , vmweak-1, true, Monitor::_safepoint_check_never);
coleenp@50313 193
rehn@51049 194 def(StringTableWeakAlloc_lock , PaddedMutex , vmweak, true, Monitor::_safepoint_check_never);
rehn@51049 195 def(StringTableWeakActive_lock , PaddedMutex , vmweak-1, true, Monitor::_safepoint_check_never);
rehn@51049 196
tonyp@6058 197 if (UseConcMarkSweepGC || UseG1GC) {
mdoerr@41710 198 def(FullGCCount_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never); // in support of ExplicitGCInvokesConcurrent
duke@1 199 }
ysr@1374 200 if (UseG1GC) {
eosterlund@46685 201 def(SATB_Q_FL_lock , PaddedMutex , access, true, Monitor::_safepoint_check_never);
eosterlund@46685 202 def(SATB_Q_CBL_mon , PaddedMonitor, access, true, Monitor::_safepoint_check_never);
eosterlund@46685 203 def(Shared_SATB_Q_lock , PaddedMutex , access + 1, true, Monitor::_safepoint_check_never);
ysr@1374 204
eosterlund@46685 205 def(DirtyCardQ_FL_lock , PaddedMutex , access, true, Monitor::_safepoint_check_never);
eosterlund@46685 206 def(DirtyCardQ_CBL_mon , PaddedMonitor, access, true, Monitor::_safepoint_check_never);
eosterlund@46685 207 def(Shared_DirtyCardQ_lock , PaddedMutex , access + 1, true, Monitor::_safepoint_check_never);
pliden@23472 208
mdoerr@41710 209 def(FreeList_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
mdoerr@41710 210 def(OldSets_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
mdoerr@41710 211 def(RootRegionScan_lock , PaddedMonitor, leaf , true, Monitor::_safepoint_check_never);
coleenp@28163 212
mdoerr@41710 213 def(StringDedupQueue_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never);
mdoerr@41710 214 def(StringDedupTable_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
tschatzl@41176 215
mdoerr@41710 216 def(MarkStackFreeList_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
mdoerr@41710 217 def(MarkStackChunkList_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_never);
ysr@1374 218 }
mdoerr@41710 219 def(ParGCRareEvent_lock , PaddedMutex , leaf , true, Monitor::_safepoint_check_sometimes);
mdoerr@41710 220 def(DerivedPointerTableGC_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
kbarrett@46384 221 def(CGCPhaseManager_lock , PaddedMonitor, leaf, false, Monitor::_safepoint_check_sometimes);
mdoerr@41710 222 def(CodeCache_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never);
mdoerr@41710 223 def(RawMonitor_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never);
mdoerr@41710 224 def(OopMapCacheAlloc_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for oop_map_cache allocation.
duke@1 225
coleenp@50096 226 def(MetaspaceExpand_lock , PaddedMutex , leaf-1, true, Monitor::_safepoint_check_never);
coleenp@50096 227
mdoerr@41710 228 def(Patching_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never); // used for safepointing and code patching.
mdoerr@41710 229 def(Service_lock , PaddedMonitor, special, true, Monitor::_safepoint_check_never); // used for service thread operations
mdoerr@41710 230 def(JmethodIdCreation_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for creating jmethodIDs.
duke@1 231
mdoerr@41710 232 def(SystemDictionary_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
iklam@50701 233 def(SharedDictionary_lock , PaddedMutex, leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
mdoerr@41710 234 def(Module_lock , PaddedMutex , leaf+2, true, Monitor::_safepoint_check_always);
mdoerr@41710 235 def(InlineCacheBuffer_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always);
mdoerr@41710 236 def(VMStatistic_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always);
mdoerr@41710 237 def(ExpandHeap_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // Used during compilation by VM thread
coleenp@52273 238 def(JNIHandleBlockFreeList_lock , PaddedMutex , leaf-1, true, Monitor::_safepoint_check_never); // handles are used by VM thread
mdoerr@41710 239 def(SignatureHandlerLibrary_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always);
gziemski@52263 240 def(SymbolArena_lock , PaddedMutex , leaf+2, true, Monitor::_safepoint_check_never);
mdoerr@41710 241 def(StringTable_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always);
mdoerr@41710 242 def(ProfilePrint_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always); // serial profile printing
mdoerr@41710 243 def(ExceptionCache_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always); // serial profile printing
mdoerr@41710 244 def(OsrList_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
mdoerr@41710 245 def(Debug1_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
duke@1 246 #ifndef PRODUCT
mdoerr@41710 247 def(FullGCALot_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always); // a lock to make FullGCALot MT safe
duke@1 248 #endif
mdoerr@41710 249 def(BeforeExit_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_always);
mdoerr@41710 250 def(PerfDataMemAlloc_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for allocating PerfData memory for performance data
mdoerr@41710 251 def(PerfDataManager_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for synchronized access to PerfDataManager resources
duke@1 252
duke@1 253 // CMS_modUnionTable_lock leaf
coleenp@28163 254 // CMS_bitMap_lock leaf 1
coleenp@28163 255 // CMS_freeList_lock leaf 2
duke@1 256
mdoerr@41710 257 def(Safepoint_lock , PaddedMonitor, safepoint, true, Monitor::_safepoint_check_sometimes); // locks SnippetCache_lock/Threads_lock
duke@1 258
mdoerr@41710 259 def(Threads_lock , PaddedMonitor, barrier, true, Monitor::_safepoint_check_sometimes);
kbarrett@52291 260 def(NonJavaThreadsList_lock , PaddedMutex, leaf, true, Monitor::_safepoint_check_never);
duke@1 261
mdoerr@41710 262 def(VMOperationQueue_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_sometimes); // VM_thread allowed to block on these
mdoerr@41710 263 def(VMOperationRequest_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_sometimes);
mdoerr@41710 264 def(RetData_lock , PaddedMutex , nonleaf, false, Monitor::_safepoint_check_always);
mdoerr@41710 265 def(Terminator_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_sometimes);
mdoerr@41710 266 def(VtableStubs_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_always);
mdoerr@41710 267 def(Notify_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_always);
kbarrett@49270 268 def(JNIGlobalAlloc_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_never);
kbarrett@49270 269 def(JNIGlobalActive_lock , PaddedMutex , nonleaf-1, true, Monitor::_safepoint_check_never);
kbarrett@49270 270 def(JNIWeakAlloc_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_never);
kbarrett@49270 271 def(JNIWeakActive_lock , PaddedMutex , nonleaf-1, true, Monitor::_safepoint_check_never);
mdoerr@41710 272 def(JNICritical_lock , PaddedMonitor, nonleaf, true, Monitor::_safepoint_check_always); // used for JNI critical regions
mdoerr@41710 273 def(AdapterHandlerLibrary_lock , PaddedMutex , nonleaf, true, Monitor::_safepoint_check_always);
duke@1 274
mdoerr@41710 275 def(Heap_lock , PaddedMonitor, nonleaf+1, false, Monitor::_safepoint_check_sometimes);
mdoerr@41710 276 def(JfieldIdCreation_lock , PaddedMutex , nonleaf+1, true, Monitor::_safepoint_check_always); // jfieldID, Used in VM_Operation
coleenp@46505 277 def(ResolvedMethodTable_lock , PaddedMutex , nonleaf+1, false, Monitor::_safepoint_check_always); // Used to protect ResolvedMethodTable
duke@1 278
mdoerr@41710 279 def(CompiledIC_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always); // locks VtableStubs_lock, InlineCacheBuffer_lock
mdoerr@41710 280 def(CompileTaskAlloc_lock , PaddedMutex , nonleaf+2, true, Monitor::_safepoint_check_always);
mdoerr@41710 281 def(CompileStatistics_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always);
mdoerr@41710 282 def(DirectivesStack_lock , PaddedMutex , special, true, Monitor::_safepoint_check_never);
gziemski@52263 283 def(MultiArray_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always);
duke@1 284
mdoerr@41710 285 def(JvmtiThreadState_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always); // Used by JvmtiThreadState/JvmtiEventController
mdoerr@41710 286 def(Management_lock , PaddedMutex , nonleaf+2, false, Monitor::_safepoint_check_always); // used for JVM management
duke@1 287
mdoerr@41710 288 def(Compile_lock , PaddedMutex , nonleaf+3, true, Monitor::_safepoint_check_sometimes);
mdoerr@41710 289 def(MethodData_lock , PaddedMutex , nonleaf+3, false, Monitor::_safepoint_check_always);
mdoerr@41710 290 def(TouchedMethodLog_lock , PaddedMutex , nonleaf+3, false, Monitor::_safepoint_check_always);
coleenp@28163 291
mdoerr@41710 292 def(MethodCompileQueue_lock , PaddedMonitor, nonleaf+4, true, Monitor::_safepoint_check_always);
mdoerr@41710 293 def(Debug2_lock , PaddedMutex , nonleaf+4, true, Monitor::_safepoint_check_never);
mdoerr@41710 294 def(Debug3_lock , PaddedMutex , nonleaf+4, true, Monitor::_safepoint_check_never);
mdoerr@41710 295 def(CompileThread_lock , PaddedMonitor, nonleaf+5, false, Monitor::_safepoint_check_always);
mdoerr@41710 296 def(PeriodicTask_lock , PaddedMonitor, nonleaf+5, true, Monitor::_safepoint_check_sometimes);
mdoerr@41710 297 def(RedefineClasses_lock , PaddedMonitor, nonleaf+5, true, Monitor::_safepoint_check_always);
jcbeyler@51212 298
jcbeyler@51212 299 def(ThreadHeapSampler_lock , PaddedMutex, nonleaf, false, Monitor::_safepoint_check_never);
jcbeyler@51212 300
iignatyev@27642 301 if (WhiteBoxAPI) {
mdoerr@41710 302 def(Compilation_lock , PaddedMonitor, leaf, false, Monitor::_safepoint_check_never);
iignatyev@27642 303 }
coleenp@28163 304
egahlin@50662 305 #if INCLUDE_JFR
mdoerr@41710 306 def(JfrMsg_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_always);
mdoerr@41710 307 def(JfrBuffer_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
mdoerr@41710 308 def(JfrStream_lock , PaddedMutex , leaf+1, true, Monitor::_safepoint_check_never); // ensure to rank lower than 'safepoint'
mdoerr@41710 309 def(JfrStacktrace_lock , PaddedMutex , special, true, Monitor::_safepoint_check_sometimes);
mgronlun@19542 310 #endif
mgronlun@19542 311
dholmes@27874 312 #ifndef SUPPORTS_NATIVE_CX8
mdoerr@41710 313 def(UnsafeJlong_lock , PaddedMutex , special, false, Monitor::_safepoint_check_never);
dholmes@27874 314 #endif
lucy@50106 315
lucy@50106 316 def(CodeHeapStateAnalytics_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
duke@1 317 }
duke@1 318
duke@1 319 GCMutexLocker::GCMutexLocker(Monitor * mutex) {
duke@1 320 if (SafepointSynchronize::is_at_safepoint()) {
duke@1 321 _locked = false;
duke@1 322 } else {
duke@1 323 _mutex = mutex;
duke@1 324 _locked = true;
duke@1 325 _mutex->lock();
duke@1 326 }
duke@1 327 }
duke@1 328
duke@1 329 // Print all mutexes/monitors that are currently owned by a thread; called
duke@1 330 // by fatal error handler.
duke@1 331 void print_owned_locks_on_error(outputStream* st) {
duke@1 332 st->print("VM Mutex/Monitor currently owned by a thread: ");
duke@1 333 bool none = true;
duke@1 334 for (int i = 0; i < _num_mutex; i++) {
duke@1 335 // see if it has an owner
duke@1 336 if (_mutex_array[i]->owner() != NULL) {
duke@1 337 if (none) {
duke@1 338 // print format used by Mutex::print_on_error()
duke@1 339 st->print_cr(" ([mutex/lock_event])");
duke@1 340 none = false;
duke@1 341 }
duke@1 342 _mutex_array[i]->print_on_error(st);
duke@1 343 st->cr();
duke@1 344 }
duke@1 345 }
duke@1 346 if (none) st->print_cr("None");
duke@1 347 }