< prev index next >

src/share/vm/runtime/mutexLocker.cpp

Print this page




 138 
 139 #ifndef SUPPORTS_NATIVE_CX8
 140 Mutex*   UnsafeJlong_lock             = NULL;
 141 #endif
 142 
 143 #define MAX_NUM_MUTEX 128
 144 static Monitor * _mutex_array[MAX_NUM_MUTEX];
 145 static int _num_mutex;
 146 
 147 #ifdef ASSERT
 148 void assert_locked_or_safepoint(const Monitor * lock) {
 149   // check if this thread owns the lock (common case)
 150   if (IgnoreLockingAssertions) return;
 151   assert(lock != NULL, "Need non-NULL lock");
 152   if (lock->owned_by_self()) return;
 153   if (SafepointSynchronize::is_at_safepoint()) return;
 154   if (!Universe::is_fully_initialized()) return;
 155   // see if invoker of VM operation owns it
 156   VM_Operation* op = VMThread::vm_operation();
 157   if (op != NULL && op->calling_thread() == lock->owner()) return;
 158   fatal(err_msg("must own lock %s", lock->name()));
 159 }
 160 
 161 // a stronger assertion than the above
 162 void assert_lock_strong(const Monitor * lock) {
 163   if (IgnoreLockingAssertions) return;
 164   assert(lock != NULL, "Need non-NULL lock");
 165   if (lock->owned_by_self()) return;
 166   fatal(err_msg("must own lock %s", lock->name()));
 167 }
 168 #endif
 169 
 170 #define def(var, type, pri, vm_block, safepoint_check_allowed ) {      \
 171   var = new type(Mutex::pri, #var, vm_block, safepoint_check_allowed); \
 172   assert(_num_mutex < MAX_NUM_MUTEX, "increase MAX_NUM_MUTEX");        \
 173   _mutex_array[_num_mutex++] = var;                                      \
 174 }
 175 
 176 void mutex_init() {
 177   def(tty_lock                     , Mutex  , event,       true,  Monitor::_safepoint_check_never);      // allow to lock in VM
 178 
 179   def(CGC_lock                     , Monitor, special,     true,  Monitor::_safepoint_check_never);      // coordinate between fore- and background GC
 180   def(STS_lock                     , Monitor, leaf,        true,  Monitor::_safepoint_check_never);
 181 
 182   if (UseConcMarkSweepGC || UseG1GC) {
 183     def(FullGCCount_lock           , Monitor, leaf,        true,  Monitor::_safepoint_check_never);      // in support of ExplicitGCInvokesConcurrent
 184   }
 185   if (UseG1GC) {
 186 




 138 
 139 #ifndef SUPPORTS_NATIVE_CX8
 140 Mutex*   UnsafeJlong_lock             = NULL;
 141 #endif
 142 
 143 #define MAX_NUM_MUTEX 128
 144 static Monitor * _mutex_array[MAX_NUM_MUTEX];
 145 static int _num_mutex;
 146 
 147 #ifdef ASSERT
 148 void assert_locked_or_safepoint(const Monitor * lock) {
 149   // check if this thread owns the lock (common case)
 150   if (IgnoreLockingAssertions) return;
 151   assert(lock != NULL, "Need non-NULL lock");
 152   if (lock->owned_by_self()) return;
 153   if (SafepointSynchronize::is_at_safepoint()) return;
 154   if (!Universe::is_fully_initialized()) return;
 155   // see if invoker of VM operation owns it
 156   VM_Operation* op = VMThread::vm_operation();
 157   if (op != NULL && op->calling_thread() == lock->owner()) return;
 158   fatal("must own lock %s", lock->name());
 159 }
 160 
 161 // a stronger assertion than the above
 162 void assert_lock_strong(const Monitor * lock) {
 163   if (IgnoreLockingAssertions) return;
 164   assert(lock != NULL, "Need non-NULL lock");
 165   if (lock->owned_by_self()) return;
 166   fatal("must own lock %s", lock->name());
 167 }
 168 #endif
 169 
 170 #define def(var, type, pri, vm_block, safepoint_check_allowed ) {      \
 171   var = new type(Mutex::pri, #var, vm_block, safepoint_check_allowed); \
 172   assert(_num_mutex < MAX_NUM_MUTEX, "increase MAX_NUM_MUTEX");        \
 173   _mutex_array[_num_mutex++] = var;                                      \
 174 }
 175 
 176 void mutex_init() {
 177   def(tty_lock                     , Mutex  , event,       true,  Monitor::_safepoint_check_never);      // allow to lock in VM
 178 
 179   def(CGC_lock                     , Monitor, special,     true,  Monitor::_safepoint_check_never);      // coordinate between fore- and background GC
 180   def(STS_lock                     , Monitor, leaf,        true,  Monitor::_safepoint_check_never);
 181 
 182   if (UseConcMarkSweepGC || UseG1GC) {
 183     def(FullGCCount_lock           , Monitor, leaf,        true,  Monitor::_safepoint_check_never);      // in support of ExplicitGCInvokesConcurrent
 184   }
 185   if (UseG1GC) {
 186 


< prev index next >