src/share/vm/memory/gcLocker.cpp
Print this page
*** 26,36 ****
#include "memory/gcLocker.inline.hpp"
#include "memory/resourceArea.hpp"
#include "memory/sharedHeap.hpp"
volatile jint GC_locker::_jni_lock_count = 0;
- volatile jint GC_locker::_lock_count = 0;
volatile bool GC_locker::_needs_gc = false;
volatile bool GC_locker::_doing_gc = false;
#ifdef ASSERT
volatile jint GC_locker::_debug_jni_lock_count = 0;
--- 26,35 ----
*** 100,110 ****
// Block entering threads if we know at least one thread is in a
// JNI critical region and we need a GC.
// We check that at least one thread is in a critical region before
// blocking because blocked threads are woken up by a thread exiting
// a JNI critical region.
! while ((needs_gc() && is_jni_active()) || _doing_gc) {
JNICritical_lock->wait();
}
thread->enter_critical();
_jni_lock_count++;
increment_debug_jni_lock_count();
--- 99,109 ----
// Block entering threads if we know at least one thread is in a
// JNI critical region and we need a GC.
// We check that at least one thread is in a critical region before
// blocking because blocked threads are woken up by a thread exiting
// a JNI critical region.
! while (is_active_and_needs_gc() || _doing_gc) {
JNICritical_lock->wait();
}
thread->enter_critical();
_jni_lock_count++;
increment_debug_jni_lock_count();
*** 114,130 ****
assert(thread->in_last_critical(), "should be exiting critical region");
MutexLocker mu(JNICritical_lock);
_jni_lock_count--;
decrement_debug_jni_lock_count();
thread->exit_critical();
! if (needs_gc() && !is_jni_active()) {
// We're the last thread out. Cause a GC to occur.
- // GC will also check is_active, so this check is not
- // strictly needed. It's added here to make it clear that
- // the GC will NOT be performed if any other caller
- // of GC_locker::lock() still needs GC locked.
- if (!is_active_internal()) {
_doing_gc = true;
{
// Must give up the lock while at a safepoint
MutexUnlocker munlock(JNICritical_lock);
if (PrintJNIGCStalls && PrintGCDetails) {
--- 113,124 ----
assert(thread->in_last_critical(), "should be exiting critical region");
MutexLocker mu(JNICritical_lock);
_jni_lock_count--;
decrement_debug_jni_lock_count();
thread->exit_critical();
! if (needs_gc() && !is_active_internal()) {
// We're the last thread out. Cause a GC to occur.
_doing_gc = true;
{
// Must give up the lock while at a safepoint
MutexUnlocker munlock(JNICritical_lock);
if (PrintJNIGCStalls && PrintGCDetails) {
*** 133,144 ****
gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count);
}
Universe::heap()->collect(GCCause::_gc_locker);
}
_doing_gc = false;
- }
-
_needs_gc = false;
JNICritical_lock->notify_all();
}
}
--- 127,136 ----