--- old/src/hotspot/share/gc/shared/gcLocker.cpp 2018-03-22 17:04:06.992830343 +0100 +++ new/src/hotspot/share/gc/shared/gcLocker.cpp 2018-03-22 17:04:06.796830350 +0100 @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "gc/shared/collectedHeap.hpp" -#include "gc/shared/gcLocker.inline.hpp" +#include "gc/shared/gcLocker.hpp" #include "memory/resourceArea.hpp" #include "logging/log.hpp" #include "runtime/atomic.hpp" @@ -85,6 +85,10 @@ } } +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) { @@ -145,87 +149,3 @@ 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