7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
authornever
Thu, 16 Feb 2012 11:33:49 -0800
changeset 11793 49aa0b2124b6
parent 11792 fd885d66cb86
child 11794 72249bf6ab83
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint( Reviewed-by: kvn, twisti
hotspot/src/share/vm/memory/gcLocker.hpp
hotspot/src/share/vm/memory/gcLocker.inline.hpp
--- a/hotspot/src/share/vm/memory/gcLocker.hpp	Thu Feb 16 09:20:40 2012 +0100
+++ b/hotspot/src/share/vm/memory/gcLocker.hpp	Thu Feb 16 11:33:49 2012 -0800
@@ -83,13 +83,26 @@
   static void jni_lock(JavaThread* thread);
   static void jni_unlock(JavaThread* thread);
 
+  static bool is_active_internal() {
+    verify_critical_count();
+    return _lock_count > 0 || _jni_lock_count > 0;
+  }
+
  public:
   // Accessors
-  static bool is_active();
+  static bool is_active() {
+    assert(_needs_gc || SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
+    return is_active_internal();
+  }
   static bool needs_gc()       { return _needs_gc;                        }
 
   // Shorthand
-  static bool is_active_and_needs_gc() { return needs_gc() && is_active(); }
+  static bool is_active_and_needs_gc() {
+    // Use is_active_internal since _needs_gc can change from true to
+    // false outside of a safepoint, triggering the assert in
+    // is_active.
+    return needs_gc() && is_active_internal();
+  }
 
   // In debug mode track the locking state at all times
   static void increment_debug_jni_lock_count() {
--- a/hotspot/src/share/vm/memory/gcLocker.inline.hpp	Thu Feb 16 09:20:40 2012 +0100
+++ b/hotspot/src/share/vm/memory/gcLocker.inline.hpp	Thu Feb 16 11:33:49 2012 -0800
@@ -27,12 +27,6 @@
 
 #include "memory/gcLocker.hpp"
 
-inline bool GC_locker::is_active() {
-  assert(_needs_gc || SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
-  verify_critical_count();
-  return _lock_count > 0 || _jni_lock_count > 0;
-}
-
 inline void GC_locker::lock() {
   // cast away volatile
   Atomic::inc(&_lock_count);