75 // At a safepoint, visit all threads and count the number of active
76 // critical sections. This is used to ensure that all active
77 // critical sections are exited before a new one is started.
78 static void verify_critical_count() NOT_DEBUG_RETURN;
79
80 static void jni_lock(JavaThread* thread);
81 static void jni_unlock(JavaThread* thread);
82
83 static bool is_active_internal() {
84 verify_critical_count();
85 return _lock_count > 0 || _jni_lock_count > 0;
86 }
87
88 public:
89 // Accessors
90 static bool is_active() {
91 assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
92 return is_active_internal();
93 }
94 static bool needs_gc() { return _needs_gc; }
95
96 // Shorthand
97 static bool is_active_and_needs_gc() {
98 // Use is_active_internal since _needs_gc can change from true to
99 // false outside of a safepoint, triggering the assert in
100 // is_active.
101 return needs_gc() && is_active_internal();
102 }
103
104 // In debug mode track the locking state at all times
105 static void increment_debug_jni_lock_count() {
106 #ifdef ASSERT
107 assert(_debug_jni_lock_count >= 0, "bad value");
108 Atomic::inc(&_debug_jni_lock_count);
109 #endif
110 }
111 static void decrement_debug_jni_lock_count() {
112 #ifdef ASSERT
113 assert(_debug_jni_lock_count > 0, "bad value");
114 Atomic::dec(&_debug_jni_lock_count);
|
75 // At a safepoint, visit all threads and count the number of active
76 // critical sections. This is used to ensure that all active
77 // critical sections are exited before a new one is started.
78 static void verify_critical_count() NOT_DEBUG_RETURN;
79
80 static void jni_lock(JavaThread* thread);
81 static void jni_unlock(JavaThread* thread);
82
83 static bool is_active_internal() {
84 verify_critical_count();
85 return _lock_count > 0 || _jni_lock_count > 0;
86 }
87
88 public:
89 // Accessors
90 static bool is_active() {
91 assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
92 return is_active_internal();
93 }
94 static bool needs_gc() { return _needs_gc; }
95 static bool fail_on_gc() { return _lock_count > 0; }
96
97 // Shorthand
98 static bool is_active_and_needs_gc() {
99 // Use is_active_internal since _needs_gc can change from true to
100 // false outside of a safepoint, triggering the assert in
101 // is_active.
102 return needs_gc() && is_active_internal();
103 }
104
105 // In debug mode track the locking state at all times
106 static void increment_debug_jni_lock_count() {
107 #ifdef ASSERT
108 assert(_debug_jni_lock_count >= 0, "bad value");
109 Atomic::inc(&_debug_jni_lock_count);
110 #endif
111 }
112 static void decrement_debug_jni_lock_count() {
113 #ifdef ASSERT
114 assert(_debug_jni_lock_count > 0, "bad value");
115 Atomic::dec(&_debug_jni_lock_count);
|