src/share/vm/memory/gcLocker.hpp

Print this page
rev 6676 : 8044775: Improve usage of umbrella header atomic.inline.hpp.
Reviewed-by: stefank, kvn


  77     return _jni_lock_count > 0;
  78   }
  79 
  80  public:
  81   // Accessors
  82   static bool is_active() {
  83     assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
  84     return is_active_internal();
  85   }
  86   static bool needs_gc()       { return _needs_gc;                        }
  87 
  88   // Shorthand
  89   static bool is_active_and_needs_gc() {
  90     // Use is_active_internal since _needs_gc can change from true to
  91     // false outside of a safepoint, triggering the assert in
  92     // is_active.
  93     return needs_gc() && is_active_internal();
  94   }
  95 
  96   // In debug mode track the locking state at all times
  97   static void increment_debug_jni_lock_count() {
  98 #ifdef ASSERT
  99     assert(_debug_jni_lock_count >= 0, "bad value");
 100     Atomic::inc(&_debug_jni_lock_count);
 101 #endif
 102   }
 103   static void decrement_debug_jni_lock_count() {
 104 #ifdef ASSERT
 105     assert(_debug_jni_lock_count > 0, "bad value");
 106     Atomic::dec(&_debug_jni_lock_count);
 107 #endif
 108   }
 109 
 110   // Set the current lock count
 111   static void set_jni_lock_count(int count) {
 112     _jni_lock_count = count;
 113     verify_critical_count();
 114   }
 115 
 116   // Sets _needs_gc if is_active() is true. Returns is_active().
 117   static bool check_active_before_gc();
 118 
 119   // Stalls the caller (who should not be in a jni critical section)
 120   // until needs_gc() clears. Note however that needs_gc() may be
 121   // set at a subsequent safepoint and/or cleared under the
 122   // JNICritical_lock, so the caller may not safely assert upon
 123   // return from this method that "!needs_gc()" since that is
 124   // not a stable predicate.
 125   static void stall_until_clear();
 126 
 127   // The following two methods are used for JNI critical regions.
 128   // If we find that we failed to perform a GC because the GC_locker




  77     return _jni_lock_count > 0;
  78   }
  79 
  80  public:
  81   // Accessors
  82   static bool is_active() {
  83     assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
  84     return is_active_internal();
  85   }
  86   static bool needs_gc()       { return _needs_gc;                        }
  87 
  88   // Shorthand
  89   static bool is_active_and_needs_gc() {
  90     // Use is_active_internal since _needs_gc can change from true to
  91     // false outside of a safepoint, triggering the assert in
  92     // is_active.
  93     return needs_gc() && is_active_internal();
  94   }
  95 
  96   // In debug mode track the locking state at all times
  97   static void increment_debug_jni_lock_count() NOT_DEBUG_RETURN;
  98   static void decrement_debug_jni_lock_count() NOT_DEBUG_RETURN;










  99 
 100   // Set the current lock count
 101   static void set_jni_lock_count(int count) {
 102     _jni_lock_count = count;
 103     verify_critical_count();
 104   }
 105 
 106   // Sets _needs_gc if is_active() is true. Returns is_active().
 107   static bool check_active_before_gc();
 108 
 109   // Stalls the caller (who should not be in a jni critical section)
 110   // until needs_gc() clears. Note however that needs_gc() may be
 111   // set at a subsequent safepoint and/or cleared under the
 112   // JNICritical_lock, so the caller may not safely assert upon
 113   // return from this method that "!needs_gc()" since that is
 114   // not a stable predicate.
 115   static void stall_until_clear();
 116 
 117   // The following two methods are used for JNI critical regions.
 118   // If we find that we failed to perform a GC because the GC_locker