8200106: Move NoSafepointVerifier out from gcLocker.hpp

Reviewed-by: coleenp
This commit is contained in:
Stefan Karlsson 2018-03-23 18:54:12 +01:00
parent 7595845e9a
commit 1a1aecd166
69 changed files with 412 additions and 332 deletions

View File

@ -23,6 +23,7 @@
*/
#include "jvm.h"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "utilities/globalDefinitions.hpp"
#include "runtime/frame.inline.hpp"
@ -30,6 +31,7 @@
#include "runtime/os.hpp"
#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/macros.hpp"
#include "utilities/vmError.hpp"

View File

@ -29,8 +29,8 @@
#include "classfile/javaAssertions.hpp"
#include "gc/shared/cardTable.hpp"
#include "gc/shared/cardTableBarrierSet.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/g1/heapRegion.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/abstractInterpreter.hpp"
#include "jvmci/compilerRuntime.hpp"
#include "jvmci/jvmciRuntime.hpp"

View File

@ -32,7 +32,6 @@
#include "compiler/compilerOracle.hpp"
#include "gc/shared/cardTableBarrierSet.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/gcLocker.hpp"
#include "jvmci/compilerRuntime.hpp"
#include "jvmci/jvmciRuntime.hpp"
#include "oops/method.inline.hpp"
@ -40,6 +39,7 @@
#include "runtime/handles.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "utilities/xmlstream.hpp"

View File

@ -25,10 +25,10 @@
#include "precompiled.hpp"
#include "asm/codeBuffer.hpp"
#include "compiler/disassembler.hpp"
#include "gc/shared/gcLocker.hpp"
#include "oops/methodData.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/icache.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/align.hpp"
#include "utilities/copy.hpp"
#include "utilities/xmlstream.hpp"

View File

@ -57,6 +57,7 @@
#include "runtime/init.hpp"
#include "runtime/reflection.hpp"
#include "runtime/jniHandles.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/thread.inline.hpp"
#include "trace/tracing.hpp"

View File

@ -37,7 +37,6 @@
#include "classfile/verificationType.hpp"
#include "classfile/verifier.hpp"
#include "classfile/vmSymbols.hpp"
#include "gc/shared/gcLocker.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/allocation.hpp"
@ -62,6 +61,7 @@
#include "runtime/javaCalls.hpp"
#include "runtime/perfData.hpp"
#include "runtime/reflection.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/signature.hpp"
#include "runtime/timer.hpp"
#include "services/classLoadingService.hpp"

View File

@ -56,7 +56,6 @@
#include "classfile/packageEntry.hpp"
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
#include "gc/shared/gcLocker.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/allocation.inline.hpp"
@ -74,6 +73,7 @@
#include "runtime/mutex.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/synchronizer.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/macros.hpp"

View File

@ -29,7 +29,6 @@
#include "classfile/protectionDomainCache.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/systemDictionaryShared.hpp"
#include "gc/shared/gcLocker.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/iterator.hpp"
@ -38,6 +37,7 @@
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/hashtable.inline.hpp"
// Optimization: if any dictionary needs resizing, we set this flag,

View File

@ -58,6 +58,7 @@
#include "runtime/javaCalls.hpp"
#include "runtime/jniHandles.inline.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/vframe.inline.hpp"
#include "utilities/align.hpp"

View File

@ -29,7 +29,6 @@
#include "classfile/stringTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/filemap.hpp"
@ -41,6 +40,7 @@
#include "runtime/atomic.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "services/diagnosticCommand.hpp"
#include "utilities/hashtable.inline.hpp"
#include "utilities/macros.hpp"

View File

@ -29,7 +29,7 @@
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/filemap.hpp"
#include "memory/metaspaceClosure.hpp"
@ -37,6 +37,7 @@
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "services/diagnosticCommand.hpp"
#include "utilities/hashtable.inline.hpp"

View File

@ -43,7 +43,6 @@
#include "classfile/vmSymbols.hpp"
#include "code/codeCache.hpp"
#include "compiler/compileBroker.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"
#include "interpreter/bytecodeStream.hpp"
#include "interpreter/interpreter.hpp"

View File

@ -27,6 +27,7 @@
#include "classfile/systemDictionaryShared.hpp"
#include "classfile/verificationType.hpp"
#include "classfile/verifier.hpp"
#include "logging/log.hpp"
#include "runtime/handles.inline.hpp"
VerificationType VerificationType::from_tag(u1 tag) {

View File

@ -49,6 +49,7 @@
#include "runtime/jniHandles.inline.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/thread.hpp"
#include "services/threadService.hpp"
#include "utilities/align.hpp"

View File

@ -26,7 +26,6 @@
#define SHARE_VM_CLASSFILE_VERIFIER_HPP
#include "classfile/verificationType.hpp"
#include "gc/shared/gcLocker.hpp"
#include "oops/klass.hpp"
#include "oops/method.hpp"
#include "runtime/handles.hpp"

View File

@ -32,7 +32,6 @@
#include "code/nmethod.hpp"
#include "code/pcDesc.hpp"
#include "compiler/compileBroker.hpp"
#include "gc/shared/gcLocker.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp"
@ -47,6 +46,7 @@
#include "runtime/icache.hpp"
#include "runtime/java.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sweeper.hpp"
#include "services/memoryService.hpp"
#include "trace/tracing.hpp"

View File

@ -32,6 +32,7 @@
#include "code/compressedStream.hpp"
#include "code/nmethod.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/hashtable.hpp"

View File

@ -37,7 +37,6 @@
#include "compiler/compilerDirectives.hpp"
#include "compiler/directivesParser.hpp"
#include "compiler/disassembler.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/bytecode.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
@ -53,6 +52,7 @@
#include "runtime/jniHandles.inline.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/sweeper.hpp"
#include "runtime/vmThread.hpp"

View File

@ -50,6 +50,7 @@
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/os.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/sweeper.hpp"
#include "runtime/timerTrace.hpp"

View File

@ -28,7 +28,7 @@
#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/cardTableRS.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcPolicyCounters.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/generationSpec.hpp"

View File

@ -44,7 +44,7 @@
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/collectorCounters.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcPolicyCounters.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"

View File

@ -27,7 +27,7 @@
#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
#include "gc/cms/concurrentMarkSweepThread.hpp"
#include "gc/cms/vmCMSOperations.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"
#include "gc/shared/isGCActiveMark.hpp"

View File

@ -62,7 +62,7 @@
#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"

View File

@ -27,11 +27,11 @@
#include "gc/g1/g1CollectedHeap.hpp"
#include "gc/g1/g1StringDedup.hpp"
#include "gc/g1/g1StringDedupQueue.hpp"
#include "gc/shared/gcLocker.hpp"
#include "logging/log.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/stack.inline.hpp"
G1StringDedupQueue* G1StringDedupQueue::_queue = NULL;

View File

@ -29,13 +29,13 @@
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/g1/g1StringDedup.hpp"
#include "gc/g1/g1StringDedupTable.hpp"
#include "gc/shared/gcLocker.hpp"
#include "logging/log.hpp"
#include "memory/padded.inline.hpp"
#include "oops/arrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/typeArrayOop.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepointVerifiers.hpp"
//
// List of deduplication table entries. Links table

View File

@ -38,7 +38,7 @@
#include "gc/parallel/psScavenge.hpp"
#include "gc/parallel/vmPSOperations.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcWhen.hpp"
#include "logging/log.hpp"
#include "oops/oop.inline.hpp"

View File

@ -39,7 +39,7 @@
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"

View File

@ -30,7 +30,7 @@
#include "gc/parallel/psMarkSweepDecorator.hpp"
#include "gc/parallel/psOldGen.hpp"
#include "gc/shared/cardTableBarrierSet.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/spaceDecorator.hpp"
#include "logging/log.hpp"
#include "oops/oop.inline.hpp"

View File

@ -44,7 +44,7 @@
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"

View File

@ -36,7 +36,7 @@
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"

View File

@ -27,7 +27,7 @@
#include "gc/parallel/psMarkSweep.hpp"
#include "gc/parallel/psScavenge.hpp"
#include "gc/parallel/vmPSOperations.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "utilities/dtrace.hpp"
// The following methods are used by the parallel scavenge collector

View File

@ -29,7 +29,7 @@
#include "gc/shared/cardTableRS.hpp"
#include "gc/shared/collectorCounters.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcPolicyCounters.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"

View File

@ -26,7 +26,7 @@
#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/cardTableRS.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcPolicyCounters.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/generationSpec.hpp"

View File

@ -24,10 +24,11 @@
#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"
#include "runtime/safepoint.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/threadSMR.hpp"
@ -85,6 +86,10 @@ void GCLocker::log_debug_jni(const char* msg) {
}
}
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 +150,3 @@ void GCLocker::jni_unlock(JavaThread* thread) {
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

View File

@ -25,10 +25,11 @@
#ifndef SHARE_VM_GC_SHARED_GCLOCKER_HPP
#define SHARE_VM_GC_SHARED_GCLOCKER_HPP
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "memory/universe.hpp"
#include "oops/oop.hpp"
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
class JavaThread;
// The direct lock/unlock calls do not force a collection if an unlock
// decrements the count to zero. Avoid calling these if at all possible.
@ -65,10 +66,13 @@ class GCLocker: public AllStatic {
}
static void log_debug_jni(const char* msg);
static bool is_at_safepoint();
public:
// Accessors
static bool is_active() {
assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
assert(GCLocker::is_at_safepoint(), "only read at safepoint");
return is_active_internal();
}
static bool needs_gc() { return _needs_gc; }
@ -135,196 +139,10 @@ class GCLocker: public AllStatic {
// falls into the slow path, or is resumed from the safepoints in
// the method, which only exist in the slow path. So when _needs_gc
// is set, the slow path is always taken, till _needs_gc is cleared.
static void lock_critical(JavaThread* thread);
static void unlock_critical(JavaThread* thread);
inline static void lock_critical(JavaThread* thread);
inline static void unlock_critical(JavaThread* thread);
static address needs_gc_address() { return (address) &_needs_gc; }
};
// A NoGCVerifier object can be placed in methods where one assumes that
// no garbage collection will occur. The destructor will verify this property
// unless the constructor is called with argument false (not verifygc).
//
// The check will only be done in debug mode and if verifygc true.
class NoGCVerifier: public StackObj {
friend class PauseNoGCVerifier;
protected:
bool _verifygc;
unsigned int _old_invocations;
public:
#ifdef ASSERT
NoGCVerifier(bool verifygc = true);
~NoGCVerifier();
#else
NoGCVerifier(bool verifygc = true) {}
~NoGCVerifier() {}
#endif
};
// A PauseNoGCVerifier is used to temporarily pause the behavior
// of a NoGCVerifier object. If we are not in debug mode or if the
// NoGCVerifier object has a _verifygc value of false, then there
// is nothing to do.
class PauseNoGCVerifier: public StackObj {
private:
NoGCVerifier * _ngcv;
public:
#ifdef ASSERT
PauseNoGCVerifier(NoGCVerifier * ngcv);
~PauseNoGCVerifier();
#else
PauseNoGCVerifier(NoGCVerifier * ngcv) {}
~PauseNoGCVerifier() {}
#endif
};
// A NoSafepointVerifier object will throw an assertion failure if
// the current thread passes a possible safepoint while this object is
// instantiated. A safepoint, will either be: an oop allocation, blocking
// on a Mutex or JavaLock, or executing a VM operation.
//
// If StrictSafepointChecks is turned off, it degrades into a NoGCVerifier
//
class NoSafepointVerifier : public NoGCVerifier {
friend class PauseNoSafepointVerifier;
private:
bool _activated;
Thread *_thread;
public:
#ifdef ASSERT
NoSafepointVerifier(bool activated = true, bool verifygc = true ) :
NoGCVerifier(verifygc),
_activated(activated) {
_thread = Thread::current();
if (_activated) {
_thread->_allow_allocation_count++;
_thread->_allow_safepoint_count++;
}
}
~NoSafepointVerifier() {
if (_activated) {
_thread->_allow_allocation_count--;
_thread->_allow_safepoint_count--;
}
}
#else
NoSafepointVerifier(bool activated = true, bool verifygc = true) : NoGCVerifier(verifygc){}
~NoSafepointVerifier() {}
#endif
};
// A PauseNoSafepointVerifier is used to temporarily pause the
// behavior of a NoSafepointVerifier object. If we are not in debug
// mode then there is nothing to do. If the NoSafepointVerifier
// object has an _activated value of false, then there is nothing to
// do for safepoint and allocation checking, but there may still be
// something to do for the underlying NoGCVerifier object.
class PauseNoSafepointVerifier : public PauseNoGCVerifier {
private:
NoSafepointVerifier * _nsv;
public:
#ifdef ASSERT
PauseNoSafepointVerifier(NoSafepointVerifier * nsv)
: PauseNoGCVerifier(nsv) {
_nsv = nsv;
if (_nsv->_activated) {
_nsv->_thread->_allow_allocation_count--;
_nsv->_thread->_allow_safepoint_count--;
}
}
~PauseNoSafepointVerifier() {
if (_nsv->_activated) {
_nsv->_thread->_allow_allocation_count++;
_nsv->_thread->_allow_safepoint_count++;
}
}
#else
PauseNoSafepointVerifier(NoSafepointVerifier * nsv)
: PauseNoGCVerifier(nsv) {}
~PauseNoSafepointVerifier() {}
#endif
};
// A SkipGCALot object is used to elide the usual effect of gc-a-lot
// over a section of execution by a thread. Currently, it's used only to
// prevent re-entrant calls to GC.
class SkipGCALot : public StackObj {
private:
bool _saved;
Thread* _t;
public:
#ifdef ASSERT
SkipGCALot(Thread* t) : _t(t) {
_saved = _t->skip_gcalot();
_t->set_skip_gcalot(true);
}
~SkipGCALot() {
assert(_t->skip_gcalot(), "Save-restore protocol invariant");
_t->set_skip_gcalot(_saved);
}
#else
SkipGCALot(Thread* t) { }
~SkipGCALot() { }
#endif
};
// JRT_LEAF currently can be called from either _thread_in_Java or
// _thread_in_native mode. In _thread_in_native, it is ok
// for another thread to trigger GC. The rest of the JRT_LEAF
// rules apply.
class JRTLeafVerifier : public NoSafepointVerifier {
static bool should_verify_GC();
public:
#ifdef ASSERT
JRTLeafVerifier();
~JRTLeafVerifier();
#else
JRTLeafVerifier() {}
~JRTLeafVerifier() {}
#endif
};
// A NoAllocVerifier object can be placed in methods where one assumes that
// no allocation will occur. The destructor will verify this property
// unless the constructor is called with argument false (not activated).
//
// The check will only be done in debug mode and if activated.
// Note: this only makes sense at safepoints (otherwise, other threads may
// allocate concurrently.)
class NoAllocVerifier : public StackObj {
private:
bool _activated;
public:
#ifdef ASSERT
NoAllocVerifier(bool activated = true) {
_activated = activated;
if (_activated) Thread::current()->_allow_allocation_count++;
}
~NoAllocVerifier() {
if (_activated) Thread::current()->_allow_allocation_count--;
}
#else
NoAllocVerifier(bool activated = true) {}
~NoAllocVerifier() {}
#endif
};
#endif // SHARE_VM_GC_SHARED_GCLOCKER_HPP

View File

@ -26,8 +26,9 @@
#define SHARE_VM_GC_SHARED_GCLOCKER_INLINE_HPP
#include "gc/shared/gcLocker.hpp"
#include "runtime/thread.hpp"
inline void GCLocker::lock_critical(JavaThread* thread) {
void GCLocker::lock_critical(JavaThread* thread) {
if (!thread->in_critical()) {
if (needs_gc()) {
// jni_lock call calls enter_critical under the lock so that the
@ -40,7 +41,7 @@ inline void GCLocker::lock_critical(JavaThread* thread) {
thread->enter_critical();
}
inline void GCLocker::unlock_critical(JavaThread* thread) {
void GCLocker::unlock_critical(JavaThread* thread) {
if (thread->in_last_critical()) {
if (needs_gc()) {
// jni_unlock call calls exit_critical under the lock so that

View File

@ -36,7 +36,7 @@
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/collectorCounters.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcPolicyCounters.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"

View File

@ -27,7 +27,7 @@
#include "gc/shared/blockOffsetTable.inline.hpp"
#include "gc/shared/cardTableRS.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/genCollectedHeap.hpp"

View File

@ -27,7 +27,7 @@
#include "classfile/javaClasses.hpp"
#include "gc/shared/allocTracer.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/vmGCOperations.hpp"
#include "interpreter/oopMapCache.hpp"

View File

@ -32,7 +32,6 @@
#include "classfile/vmSymbols.hpp"
#include "compiler/compileBroker.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/bytecode.hpp"
#include "interpreter/interpreterRuntime.hpp"
#include "interpreter/linkResolver.hpp"
@ -53,6 +52,7 @@
#include "runtime/frame.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/reflection.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/signature.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/vmThread.hpp"

View File

@ -23,7 +23,6 @@
*/
#include "precompiled.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/bytecodes.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/rewriter.hpp"

View File

@ -25,7 +25,6 @@
#include "aot/aotLoader.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/gcLocker.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/allocation.hpp"

View File

@ -35,7 +35,6 @@
#include "classfile/systemDictionary.hpp"
#include "classfile/systemDictionaryShared.hpp"
#include "code/codeCache.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/bytecodeStream.hpp"
#include "interpreter/bytecodes.hpp"
#include "logging/log.hpp"
@ -56,6 +55,7 @@
#include "prims/jvmtiRedefineClasses.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/signature.hpp"
#include "runtime/timerTrace.hpp"
#include "runtime/vmThread.hpp"

View File

@ -35,7 +35,7 @@
#include "gc/shared/cardTableBarrierSet.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcArguments.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/generation.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"
#include "gc/shared/space.hpp"

View File

@ -27,7 +27,6 @@
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "jvmtifiles/jvmti.h"
#include "memory/metaspaceClosure.hpp"
#include "memory/resourceArea.hpp"

View File

@ -23,7 +23,6 @@
*/
#include "precompiled.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/interpreter.hpp"
#include "memory/heapInspection.hpp"
#include "memory/metadataFactory.hpp"
@ -31,6 +30,7 @@
#include "memory/resourceArea.hpp"
#include "oops/constMethod.hpp"
#include "oops/method.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/align.hpp"
// Static initialization

View File

@ -26,7 +26,6 @@
#include "jvm.h"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/linkResolver.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
@ -40,6 +39,7 @@
#include "oops/oop.inline.hpp"
#include "runtime/arguments.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/copy.hpp"
inline InstanceKlass* klassVtable::ik() const {

View File

@ -28,7 +28,6 @@
#include "code/codeCache.hpp"
#include "code/debugInfoRec.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/generation.hpp"
#include "interpreter/bytecodeStream.hpp"
#include "interpreter/bytecodeTracer.hpp"
@ -58,6 +57,7 @@
#include "runtime/init.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "runtime/relocator.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "utilities/align.hpp"

View File

@ -25,7 +25,6 @@
#include "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "compiler/compilerOracle.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/bytecode.hpp"
#include "interpreter/bytecodeStream.hpp"
#include "interpreter/linkResolver.hpp"
@ -39,6 +38,7 @@
#include "runtime/deoptimization.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/align.hpp"
#include "utilities/copy.hpp"

View File

@ -38,7 +38,7 @@
#include "gc/g1/heapRegion.hpp"
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/bytecode.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/linkResolver.hpp"

View File

@ -28,7 +28,6 @@
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "compiler/compileLog.hpp"
#include "gc/shared/gcLocker.hpp"
#include "libadt/dict.hpp"
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"

View File

@ -71,6 +71,7 @@
#include "runtime/jniHandles.inline.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "runtime/reflection.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "runtime/thread.inline.hpp"

View File

@ -54,6 +54,7 @@
#include "runtime/objectMonitor.hpp"
#include "runtime/objectMonitor.inline.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/threadSMR.hpp"
#include "runtime/vframe.inline.hpp"

View File

@ -30,7 +30,6 @@
#include "classfile/verifier.hpp"
#include "code/codeCache.hpp"
#include "compiler/compileBroker.hpp"
#include "gc/shared/gcLocker.hpp"
#include "interpreter/oopMapCache.hpp"
#include "interpreter/rewriter.hpp"
#include "logging/logStream.hpp"
@ -50,6 +49,7 @@
#include "runtime/handles.inline.hpp"
#include "runtime/jniHandles.inline.hpp"
#include "runtime/relocator.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/bitMap.inline.hpp"
#include "utilities/events.hpp"

View File

@ -23,12 +23,12 @@
*/
#include "precompiled.hpp"
#include "gc/shared/gcLocker.hpp"
#include "jvmtifiles/jvmtiEnv.hpp"
#include "memory/resourceArea.hpp"
#include "prims/jvmtiEventController.inline.hpp"
#include "prims/jvmtiImpl.hpp"
#include "prims/jvmtiThreadState.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/vframe.hpp"
// marker for when the stack depth has been reset and is now unknown.

View File

@ -44,6 +44,7 @@
#include "runtime/jniHandles.inline.hpp"
#include "runtime/timerTrace.hpp"
#include "runtime/reflection.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubRoutines.hpp"
#include "utilities/exceptions.hpp"

View File

@ -24,7 +24,6 @@
#include "precompiled.hpp"
#include "classfile/javaClasses.hpp"
#include "gc/shared/gcLocker.hpp"
#include "memory/allocation.hpp"
#include "memory/resourceArea.hpp"
#include "oops/access.inline.hpp"
@ -34,6 +33,7 @@
#include "prims/resolvedMethodTable.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "utilities/hashtable.inline.hpp"
#include "utilities/macros.hpp"

View File

@ -32,6 +32,7 @@
#include "code/codeCache.hpp"
#include "compiler/methodMatcher.hpp"
#include "compiler/directivesParser.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "jvmtifiles/jvmtiEnv.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/metaspaceShared.hpp"

View File

@ -48,6 +48,7 @@
#include "runtime/deoptimization.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubRoutines.hpp"

View File

@ -35,6 +35,7 @@
#include "runtime/orderAccess.inline.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/vframe.hpp"
#include "runtime/vmThread.hpp"
#include "utilities/preserveException.hpp"
@ -298,3 +299,40 @@ void InterfaceSupport_init() {
}
#endif
}
#ifdef ASSERT
// 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 // ASSERT

View File

@ -25,12 +25,12 @@
#ifndef SHARE_VM_RUNTIME_INTERFACESUPPORT_INLINE_HPP
#define SHARE_VM_RUNTIME_INTERFACESUPPORT_INLINE_HPP
#include "gc/shared/gcLocker.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/thread.hpp"
#include "runtime/vm_operations.hpp"
#include "utilities/globalDefinitions.hpp"
@ -356,6 +356,24 @@ class VMNativeEntryWrapper {
// VM-internal runtime interface support
// Definitions for JRT (Java (Compiler/Shared) Runtime)
// JRT_LEAF currently can be called from either _thread_in_Java or
// _thread_in_native mode. In _thread_in_native, it is ok
// for another thread to trigger GC. The rest of the JRT_LEAF
// rules apply.
class JRTLeafVerifier : public NoSafepointVerifier {
static bool should_verify_GC();
public:
#ifdef ASSERT
JRTLeafVerifier();
~JRTLeafVerifier();
#else
JRTLeafVerifier() {}
~JRTLeafVerifier() {}
#endif
};
#ifdef ASSERT
class RuntimeHistogramElement : public HistogramElement {
@ -436,9 +454,6 @@ class RuntimeHistogramElement : public HistogramElement {
#define IRT_END }
// Definitions for JRT (Java (Compiler/Shared) Runtime)
#define JRT_ENTRY(result_type, header) \
result_type header { \
ThreadInVMfromJava __tiv(thread); \

View File

@ -33,7 +33,7 @@
#include "code/pcDesc.hpp"
#include "code/scopeDesc.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/strongRootsScope.hpp"
#include "gc/shared/workgroup.hpp"
#include "interpreter/interpreter.hpp"

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "memory/universe.hpp"
#include "utilities/debug.hpp"
// 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();
}
}
#endif

View File

@ -0,0 +1,175 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_RUNTIME_SAFEPOINTVERIFIERS_HPP
#define SHARE_VM_RUNTIME_SAFEPOINTVERIFIERS_HPP
#include "memory/allocation.hpp"
#include "runtime/thread.hpp"
// A NoGCVerifier object can be placed in methods where one assumes that
// no garbage collection will occur. The destructor will verify this property
// unless the constructor is called with argument false (not verifygc).
//
// The check will only be done in debug mode and if verifygc true.
class NoGCVerifier: public StackObj {
friend class PauseNoGCVerifier;
protected:
bool _verifygc;
unsigned int _old_invocations;
public:
#ifdef ASSERT
NoGCVerifier(bool verifygc = true);
~NoGCVerifier();
#else
NoGCVerifier(bool verifygc = true) {}
~NoGCVerifier() {}
#endif
};
// A PauseNoGCVerifier is used to temporarily pause the behavior
// of a NoGCVerifier object. If we are not in debug mode or if the
// NoGCVerifier object has a _verifygc value of false, then there
// is nothing to do.
class PauseNoGCVerifier: public StackObj {
private:
NoGCVerifier * _ngcv;
public:
#ifdef ASSERT
PauseNoGCVerifier(NoGCVerifier * ngcv);
~PauseNoGCVerifier();
#else
PauseNoGCVerifier(NoGCVerifier * ngcv) {}
~PauseNoGCVerifier() {}
#endif
};
// A NoSafepointVerifier object will throw an assertion failure if
// the current thread passes a possible safepoint while this object is
// instantiated. A safepoint, will either be: an oop allocation, blocking
// on a Mutex or JavaLock, or executing a VM operation.
//
// If StrictSafepointChecks is turned off, it degrades into a NoGCVerifier
//
class NoSafepointVerifier : public NoGCVerifier {
friend class PauseNoSafepointVerifier;
private:
bool _activated;
Thread *_thread;
public:
#ifdef ASSERT
NoSafepointVerifier(bool activated = true, bool verifygc = true ) :
NoGCVerifier(verifygc),
_activated(activated) {
_thread = Thread::current();
if (_activated) {
_thread->_allow_allocation_count++;
_thread->_allow_safepoint_count++;
}
}
~NoSafepointVerifier() {
if (_activated) {
_thread->_allow_allocation_count--;
_thread->_allow_safepoint_count--;
}
}
#else
NoSafepointVerifier(bool activated = true, bool verifygc = true) : NoGCVerifier(verifygc){}
~NoSafepointVerifier() {}
#endif
};
// A PauseNoSafepointVerifier is used to temporarily pause the
// behavior of a NoSafepointVerifier object. If we are not in debug
// mode then there is nothing to do. If the NoSafepointVerifier
// object has an _activated value of false, then there is nothing to
// do for safepoint and allocation checking, but there may still be
// something to do for the underlying NoGCVerifier object.
class PauseNoSafepointVerifier : public PauseNoGCVerifier {
private:
NoSafepointVerifier * _nsv;
public:
#ifdef ASSERT
PauseNoSafepointVerifier(NoSafepointVerifier * nsv)
: PauseNoGCVerifier(nsv) {
_nsv = nsv;
if (_nsv->_activated) {
_nsv->_thread->_allow_allocation_count--;
_nsv->_thread->_allow_safepoint_count--;
}
}
~PauseNoSafepointVerifier() {
if (_nsv->_activated) {
_nsv->_thread->_allow_allocation_count++;
_nsv->_thread->_allow_safepoint_count++;
}
}
#else
PauseNoSafepointVerifier(NoSafepointVerifier * nsv)
: PauseNoGCVerifier(nsv) {}
~PauseNoSafepointVerifier() {}
#endif
};
// A NoAllocVerifier object can be placed in methods where one assumes that
// no allocation will occur. The destructor will verify this property
// unless the constructor is called with argument false (not activated).
//
// The check will only be done in debug mode and if activated.
// Note: this only makes sense at safepoints (otherwise, other threads may
// allocate concurrently.)
class NoAllocVerifier : public StackObj {
private:
bool _activated;
public:
#ifdef ASSERT
NoAllocVerifier(bool activated = true) {
_activated = activated;
if (_activated) Thread::current()->_allow_allocation_count++;
}
~NoAllocVerifier() {
if (_activated) Thread::current()->_allow_allocation_count--;
}
#else
NoAllocVerifier(bool activated = true) {}
~NoAllocVerifier() {}
#endif
};
#endif // SHARE_VM_RUNTIME_SAFEPOINTVERIFIERS_HPP

View File

@ -24,10 +24,10 @@
#include "precompiled.hpp"
#include "compiler/compileBroker.hpp"
#include "gc/shared/gcLocker.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/arguments.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/simpleThresholdPolicy.hpp"
#include "runtime/simpleThresholdPolicy.inline.hpp"
#include "code/scopeDesc.hpp"

View File

@ -39,6 +39,7 @@
#include "runtime/objectMonitor.hpp"
#include "runtime/objectMonitor.inline.hpp"
#include "runtime/osThread.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/synchronizer.hpp"

View File

@ -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/universe.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/thread.hpp"

View File

@ -576,6 +576,31 @@ void VMThread::loop() {
}
}
// A SkipGCALot object is used to elide the usual effect of gc-a-lot
// over a section of execution by a thread. Currently, it's used only to
// prevent re-entrant calls to GC.
class SkipGCALot : public StackObj {
private:
bool _saved;
Thread* _t;
public:
#ifdef ASSERT
SkipGCALot(Thread* t) : _t(t) {
_saved = _t->skip_gcalot();
_t->set_skip_gcalot(true);
}
~SkipGCALot() {
assert(_t->skip_gcalot(), "Save-restore protocol invariant");
_t->set_skip_gcalot(_saved);
}
#else
SkipGCALot(Thread* t) { }
~SkipGCALot() { }
#endif
};
void VMThread::execute(VM_Operation* op) {
Thread* t = Thread::current();

View File

@ -27,7 +27,7 @@
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/vmGCOperations.hpp"
#include "memory/allocation.inline.hpp"