47
48 #ifdef ASSERT
49 // This lock count is updated for all operations and is used to
50 // validate the jni_lock_count that is computed during safepoints.
51 static volatile jint _debug_jni_lock_count;
52 #endif
53
54 // At a safepoint, visit all threads and count the number of active
55 // critical sections. This is used to ensure that all active
56 // critical sections are exited before a new one is started.
57 static void verify_critical_count() NOT_DEBUG_RETURN;
58
59 static void jni_lock(JavaThread* thread);
60 static void jni_unlock(JavaThread* thread);
61
62 static bool is_active_internal() {
63 verify_critical_count();
64 return _jni_lock_count > 0;
65 }
66
67 public:
68 // Accessors
69 static bool is_active() {
70 assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
71 return is_active_internal();
72 }
73 static bool needs_gc() { return _needs_gc; }
74
75 // Shorthand
76 static bool is_active_and_needs_gc() {
77 // Use is_active_internal since _needs_gc can change from true to
78 // false outside of a safepoint, triggering the assert in
79 // is_active.
80 return needs_gc() && is_active_internal();
81 }
82
83 // In debug mode track the locking state at all times
84 static void increment_debug_jni_lock_count() NOT_DEBUG_RETURN;
85 static void decrement_debug_jni_lock_count() NOT_DEBUG_RETURN;
86
|
47
48 #ifdef ASSERT
49 // This lock count is updated for all operations and is used to
50 // validate the jni_lock_count that is computed during safepoints.
51 static volatile jint _debug_jni_lock_count;
52 #endif
53
54 // At a safepoint, visit all threads and count the number of active
55 // critical sections. This is used to ensure that all active
56 // critical sections are exited before a new one is started.
57 static void verify_critical_count() NOT_DEBUG_RETURN;
58
59 static void jni_lock(JavaThread* thread);
60 static void jni_unlock(JavaThread* thread);
61
62 static bool is_active_internal() {
63 verify_critical_count();
64 return _jni_lock_count > 0;
65 }
66
67 static void log_debug_jni(const char* msg);
68 public:
69 // Accessors
70 static bool is_active() {
71 assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
72 return is_active_internal();
73 }
74 static bool needs_gc() { return _needs_gc; }
75
76 // Shorthand
77 static bool is_active_and_needs_gc() {
78 // Use is_active_internal since _needs_gc can change from true to
79 // false outside of a safepoint, triggering the assert in
80 // is_active.
81 return needs_gc() && is_active_internal();
82 }
83
84 // In debug mode track the locking state at all times
85 static void increment_debug_jni_lock_count() NOT_DEBUG_RETURN;
86 static void decrement_debug_jni_lock_count() NOT_DEBUG_RETURN;
87
|