34 volatile bool GCLocker::_needs_gc = false; 35 volatile bool GCLocker::_doing_gc = false; 36 37 #ifdef ASSERT 38 volatile jint GCLocker::_debug_jni_lock_count = 0; 39 #endif 40 41 42 #ifdef ASSERT 43 void GCLocker::verify_critical_count() { 44 if (SafepointSynchronize::is_at_safepoint()) { 45 assert(!needs_gc() || _debug_jni_lock_count == _jni_lock_count, "must agree"); 46 int count = 0; 47 // Count the number of threads with critical operations in progress 48 for (JavaThread* thr = Threads::first(); thr; thr = thr->next()) { 49 if (thr->in_critical()) { 50 count++; 51 } 52 } 53 if (_jni_lock_count != count) { 54 tty->print_cr("critical counts don't match: %d != %d", _jni_lock_count, count); 55 for (JavaThread* thr = Threads::first(); thr; thr = thr->next()) { 56 if (thr->in_critical()) { 57 tty->print_cr(INTPTR_FORMAT " in_critical %d", p2i(thr), thr->in_critical()); 58 } 59 } 60 } 61 assert(_jni_lock_count == count, "must be equal"); 62 } 63 } 64 65 // In debug mode track the locking state at all times 66 void GCLocker::increment_debug_jni_lock_count() { 67 assert(_debug_jni_lock_count >= 0, "bad value"); 68 Atomic::inc(&_debug_jni_lock_count); 69 } 70 71 void GCLocker::decrement_debug_jni_lock_count() { 72 assert(_debug_jni_lock_count > 0, "bad value"); 73 Atomic::dec(&_debug_jni_lock_count); 74 } 75 #endif 76 77 void GCLocker::log_debug_jni(const char* msg) { | 34 volatile bool GCLocker::_needs_gc = false; 35 volatile bool GCLocker::_doing_gc = false; 36 37 #ifdef ASSERT 38 volatile jint GCLocker::_debug_jni_lock_count = 0; 39 #endif 40 41 42 #ifdef ASSERT 43 void GCLocker::verify_critical_count() { 44 if (SafepointSynchronize::is_at_safepoint()) { 45 assert(!needs_gc() || _debug_jni_lock_count == _jni_lock_count, "must agree"); 46 int count = 0; 47 // Count the number of threads with critical operations in progress 48 for (JavaThread* thr = Threads::first(); thr; thr = thr->next()) { 49 if (thr->in_critical()) { 50 count++; 51 } 52 } 53 if (_jni_lock_count != count) { 54 log_error(gc, verify)("critical counts don't match: %d != %d", _jni_lock_count, count); 55 for (JavaThread* thr = Threads::first(); thr; thr = thr->next()) { 56 if (thr->in_critical()) { 57 log_error(gc, verify)(INTPTR_FORMAT " in_critical %d", p2i(thr), thr->in_critical()); 58 } 59 } 60 } 61 assert(_jni_lock_count == count, "must be equal"); 62 } 63 } 64 65 // In debug mode track the locking state at all times 66 void GCLocker::increment_debug_jni_lock_count() { 67 assert(_debug_jni_lock_count >= 0, "bad value"); 68 Atomic::inc(&_debug_jni_lock_count); 69 } 70 71 void GCLocker::decrement_debug_jni_lock_count() { 72 assert(_debug_jni_lock_count > 0, "bad value"); 73 Atomic::dec(&_debug_jni_lock_count); 74 } 75 #endif 76 77 void GCLocker::log_debug_jni(const char* msg) { |