< prev index next >

src/hotspot/share/gc/shared/gcLocker.cpp

Print this page

        

*** 22,32 **** * */ #include "precompiled.hpp" #include "gc/shared/collectedHeap.hpp" ! #include "gc/shared/gcLocker.inline.hpp" #include "memory/resourceArea.hpp" #include "logging/log.hpp" #include "runtime/atomic.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadSMR.hpp" --- 22,32 ---- * */ #include "precompiled.hpp" #include "gc/shared/collectedHeap.hpp" ! #include "gc/shared/gcLocker.hpp" #include "memory/resourceArea.hpp" #include "logging/log.hpp" #include "runtime/atomic.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadSMR.hpp"
*** 83,92 **** --- 83,96 ---- ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 log.debug("%s Thread \"%s\" %d locked.", msg, Thread::current()->name(), _jni_lock_count); } } + bool GCLocker::is_at_safepoint() { + return SafepointSynchronize::is_at_safepoint(); + } + bool GCLocker::check_active_before_gc() { assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint"); if (is_active() && !_needs_gc) { verify_critical_count(); _needs_gc = true;
*** 143,231 **** _doing_gc = false; _needs_gc = false; JNICritical_lock->notify_all(); } } - - // Implementation of NoGCVerifier - - #ifdef ASSERT - - NoGCVerifier::NoGCVerifier(bool verifygc) { - _verifygc = verifygc; - if (_verifygc) { - CollectedHeap* h = Universe::heap(); - assert(!h->is_gc_active(), "GC active during NoGCVerifier"); - _old_invocations = h->total_collections(); - } - } - - - NoGCVerifier::~NoGCVerifier() { - if (_verifygc) { - CollectedHeap* h = Universe::heap(); - assert(!h->is_gc_active(), "GC active during NoGCVerifier"); - if (_old_invocations != h->total_collections()) { - fatal("collection in a NoGCVerifier secured function"); - } - } - } - - PauseNoGCVerifier::PauseNoGCVerifier(NoGCVerifier * ngcv) { - _ngcv = ngcv; - if (_ngcv->_verifygc) { - // if we were verifying, then make sure that nothing is - // wrong before we "pause" verification - CollectedHeap* h = Universe::heap(); - assert(!h->is_gc_active(), "GC active during NoGCVerifier"); - if (_ngcv->_old_invocations != h->total_collections()) { - fatal("collection in a NoGCVerifier secured function"); - } - } - } - - - PauseNoGCVerifier::~PauseNoGCVerifier() { - if (_ngcv->_verifygc) { - // if we were verifying before, then reenable verification - CollectedHeap* h = Universe::heap(); - assert(!h->is_gc_active(), "GC active during NoGCVerifier"); - _ngcv->_old_invocations = h->total_collections(); - } - } - - - // JRT_LEAF rules: - // A JRT_LEAF method may not interfere with safepointing by - // 1) acquiring or blocking on a Mutex or JavaLock - checked - // 2) allocating heap memory - checked - // 3) executing a VM operation - checked - // 4) executing a system call (including malloc) that could block or grab a lock - // 5) invoking GC - // 6) reaching a safepoint - // 7) running too long - // Nor may any method it calls. - JRTLeafVerifier::JRTLeafVerifier() - : NoSafepointVerifier(true, JRTLeafVerifier::should_verify_GC()) - { - } - - JRTLeafVerifier::~JRTLeafVerifier() - { - } - - bool JRTLeafVerifier::should_verify_GC() { - switch (JavaThread::current()->thread_state()) { - case _thread_in_Java: - // is in a leaf routine, there must be no safepoint. - return true; - case _thread_in_native: - // A native thread is not subject to safepoints. - // Even while it is in a leaf routine, GC is ok - return false; - default: - // Leaf routines cannot be called from other contexts. - ShouldNotReachHere(); - return false; - } - } - #endif --- 147,151 ----
< prev index next >