src/share/vm/memory/gcLocker.hpp

changeset 3576
ad3b47344802
parent 3571
09d00c18e323
child 4299
f34d701e952e
     1.1 --- a/src/share/vm/memory/gcLocker.hpp	Thu Feb 16 09:20:40 2012 +0100
     1.2 +++ b/src/share/vm/memory/gcLocker.hpp	Thu Feb 16 11:33:49 2012 -0800
     1.3 @@ -83,13 +83,26 @@
     1.4    static void jni_lock(JavaThread* thread);
     1.5    static void jni_unlock(JavaThread* thread);
     1.6  
     1.7 +  static bool is_active_internal() {
     1.8 +    verify_critical_count();
     1.9 +    return _lock_count > 0 || _jni_lock_count > 0;
    1.10 +  }
    1.11 +
    1.12   public:
    1.13    // Accessors
    1.14 -  static bool is_active();
    1.15 +  static bool is_active() {
    1.16 +    assert(_needs_gc || SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
    1.17 +    return is_active_internal();
    1.18 +  }
    1.19    static bool needs_gc()       { return _needs_gc;                        }
    1.20  
    1.21    // Shorthand
    1.22 -  static bool is_active_and_needs_gc() { return needs_gc() && is_active(); }
    1.23 +  static bool is_active_and_needs_gc() {
    1.24 +    // Use is_active_internal since _needs_gc can change from true to
    1.25 +    // false outside of a safepoint, triggering the assert in
    1.26 +    // is_active.
    1.27 +    return needs_gc() && is_active_internal();
    1.28 +  }
    1.29  
    1.30    // In debug mode track the locking state at all times
    1.31    static void increment_debug_jni_lock_count() {

mercurial