src/share/vm/memory/gcLocker.cpp

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

@@ -24,10 +24,11 @@
 
 #include "precompiled.hpp"
 #include "memory/gcLocker.inline.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/sharedHeap.hpp"
+#include "runtime/atomic.inline.hpp"
 #include "runtime/thread.inline.hpp"
 
 volatile jint GC_locker::_jni_lock_count = 0;
 volatile bool GC_locker::_needs_gc       = false;
 volatile bool GC_locker::_doing_gc       = false;

@@ -57,10 +58,21 @@
       }
     }
     assert(_jni_lock_count == count, "must be equal");
   }
 }
+
+// In debug mode track the locking state at all times
+void GC_locker::increment_debug_jni_lock_count() {
+  assert(_debug_jni_lock_count >= 0, "bad value");
+  Atomic::inc(&_debug_jni_lock_count);
+}
+
+void GC_locker::decrement_debug_jni_lock_count() {
+  assert(_debug_jni_lock_count > 0, "bad value");
+  Atomic::dec(&_debug_jni_lock_count);
+}
 #endif
 
 bool GC_locker::check_active_before_gc() {
   assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
   if (is_active() && !_needs_gc) {