8224978: Shenandoah: Allows root verifier to verify some roots outside safepoints with proper locks
Reviewed-by: shade
This commit is contained in:
parent
bcd13b790f
commit
c73e5b1401
@ -362,3 +362,16 @@ void ShenandoahAsserts::assert_rp_isalive_installed(const char *file, int line)
|
|||||||
file, line);
|
file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShenandoahAsserts::assert_locked_or_shenandoah_safepoint(const Monitor* lock, const char* file, int line) {
|
||||||
|
if (ShenandoahSafepoint::is_at_shenandoah_safepoint()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lock->owned_by_self()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShenandoahMessageBuffer msg("Must ba at a Shenandoah safepoint or held %s lock", lock->name());
|
||||||
|
report_vm_error(file, line, msg.buffer());
|
||||||
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#define SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
|
#define SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
|
||||||
|
|
||||||
#include "memory/iterator.hpp"
|
#include "memory/iterator.hpp"
|
||||||
|
#include "runtime/mutex.hpp"
|
||||||
#include "utilities/formatBuffer.hpp"
|
#include "utilities/formatBuffer.hpp"
|
||||||
|
|
||||||
typedef FormatBuffer<8192> ShenandoahMessageBuffer;
|
typedef FormatBuffer<8192> ShenandoahMessageBuffer;
|
||||||
@ -65,6 +66,8 @@ public:
|
|||||||
static void assert_rp_isalive_not_installed(const char *file, int line);
|
static void assert_rp_isalive_not_installed(const char *file, int line);
|
||||||
static void assert_rp_isalive_installed(const char *file, int line);
|
static void assert_rp_isalive_installed(const char *file, int line);
|
||||||
|
|
||||||
|
static void assert_locked_or_shenandoah_safepoint(const Monitor* lock, const char*file, int line);
|
||||||
|
|
||||||
#ifdef ASSERT
|
#ifdef ASSERT
|
||||||
#define shenandoah_assert_in_heap(interior_loc, obj) \
|
#define shenandoah_assert_in_heap(interior_loc, obj) \
|
||||||
ShenandoahAsserts::assert_in_heap(interior_loc, obj, __FILE__, __LINE__);
|
ShenandoahAsserts::assert_in_heap(interior_loc, obj, __FILE__, __LINE__);
|
||||||
@ -124,6 +127,12 @@ public:
|
|||||||
ShenandoahAsserts::assert_rp_isalive_installed(__FILE__, __LINE__);
|
ShenandoahAsserts::assert_rp_isalive_installed(__FILE__, __LINE__);
|
||||||
#define shenandoah_assert_rp_isalive_not_installed() \
|
#define shenandoah_assert_rp_isalive_not_installed() \
|
||||||
ShenandoahAsserts::assert_rp_isalive_not_installed(__FILE__, __LINE__);
|
ShenandoahAsserts::assert_rp_isalive_not_installed(__FILE__, __LINE__);
|
||||||
|
|
||||||
|
#define shenandoah_assert_safepoint() \
|
||||||
|
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Should be at Shenandoah Safepoints");
|
||||||
|
|
||||||
|
#define shenandoah_assert_locked_or_safepoint(lock) \
|
||||||
|
ShenandoahAsserts::assert_locked_or_shenandoah_safepoint(lock, __FILE__, __LINE__);
|
||||||
#else
|
#else
|
||||||
#define shenandoah_assert_in_heap(interior_loc, obj)
|
#define shenandoah_assert_in_heap(interior_loc, obj)
|
||||||
#define shenandoah_assert_in_correct_region(interior_loc, obj)
|
#define shenandoah_assert_in_correct_region(interior_loc, obj)
|
||||||
@ -158,6 +167,10 @@ public:
|
|||||||
|
|
||||||
#define shenandoah_assert_rp_isalive_installed()
|
#define shenandoah_assert_rp_isalive_installed()
|
||||||
#define shenandoah_assert_rp_isalive_not_installed()
|
#define shenandoah_assert_rp_isalive_not_installed()
|
||||||
|
|
||||||
|
#define shenandoah_assert_safepoint()
|
||||||
|
#define shenandoah_assert_locked_or_safepoint(lock)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define shenandoah_not_implemented \
|
#define shenandoah_not_implemented \
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
|
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
|
||||||
#include "gc/shenandoah/shenandoahStringDedup.hpp"
|
#include "gc/shenandoah/shenandoahStringDedup.hpp"
|
||||||
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
|
#include "gc/shenandoah/shenandoahTimingTracker.hpp"
|
||||||
#include "gc/shenandoah/shenandoahUtils.hpp"
|
|
||||||
#include "gc/shenandoah/shenandoahVMOperations.hpp"
|
#include "gc/shenandoah/shenandoahVMOperations.hpp"
|
||||||
#include "gc/shared/weakProcessor.inline.hpp"
|
#include "gc/shared/weakProcessor.inline.hpp"
|
||||||
#include "memory/allocation.inline.hpp"
|
#include "memory/allocation.inline.hpp"
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
#include "classfile/classLoaderDataGraph.hpp"
|
#include "classfile/classLoaderDataGraph.hpp"
|
||||||
#include "classfile/systemDictionary.hpp"
|
#include "classfile/systemDictionary.hpp"
|
||||||
#include "code/codeCache.hpp"
|
#include "code/codeCache.hpp"
|
||||||
|
#include "gc/shenandoah/shenandoahAsserts.hpp"
|
||||||
#include "gc/shenandoah/shenandoahHeap.hpp"
|
#include "gc/shenandoah/shenandoahHeap.hpp"
|
||||||
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
|
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
|
||||||
#include "gc/shenandoah/shenandoahRootVerifier.hpp"
|
#include "gc/shenandoah/shenandoahRootVerifier.hpp"
|
||||||
#include "gc/shenandoah/shenandoahStringDedup.hpp"
|
#include "gc/shenandoah/shenandoahStringDedup.hpp"
|
||||||
|
#include "gc/shenandoah/shenandoahUtils.hpp"
|
||||||
#include "gc/shared/weakProcessor.inline.hpp"
|
#include "gc/shared/weakProcessor.inline.hpp"
|
||||||
#include "memory/universe.hpp"
|
#include "memory/universe.hpp"
|
||||||
#include "runtime/thread.hpp"
|
#include "runtime/thread.hpp"
|
||||||
@ -55,15 +57,19 @@ bool ShenandoahRootVerifier::verify(RootTypes type) const {
|
|||||||
void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
|
void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
|
||||||
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
|
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
|
||||||
if (verify(CodeRoots)) {
|
if (verify(CodeRoots)) {
|
||||||
|
shenandoah_assert_locked_or_safepoint(CodeCache_lock);
|
||||||
CodeCache::blobs_do(&blobs);
|
CodeCache::blobs_do(&blobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verify(CLDGRoots)) {
|
if (verify(CLDGRoots)) {
|
||||||
|
shenandoah_assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
|
||||||
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
|
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
|
||||||
ClassLoaderDataGraph::cld_do(&clds);
|
ClassLoaderDataGraph::cld_do(&clds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verify(SerialRoots)) {
|
if (verify(SerialRoots)) {
|
||||||
|
shenandoah_assert_safepoint();
|
||||||
|
|
||||||
Universe::oops_do(oops);
|
Universe::oops_do(oops);
|
||||||
Management::oops_do(oops);
|
Management::oops_do(oops);
|
||||||
JvmtiExport::oops_do(oops);
|
JvmtiExport::oops_do(oops);
|
||||||
@ -73,15 +79,18 @@ void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (verify(WeakRoots)) {
|
if (verify(WeakRoots)) {
|
||||||
|
shenandoah_assert_safepoint();
|
||||||
AlwaysTrueClosure always_true;
|
AlwaysTrueClosure always_true;
|
||||||
WeakProcessor::weak_oops_do(&always_true, oops);
|
WeakProcessor::weak_oops_do(&always_true, oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShenandoahStringDedup::is_enabled() && verify(StringDedupRoots)) {
|
if (ShenandoahStringDedup::is_enabled() && verify(StringDedupRoots)) {
|
||||||
|
shenandoah_assert_safepoint();
|
||||||
ShenandoahStringDedup::oops_do_slow(oops);
|
ShenandoahStringDedup::oops_do_slow(oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verify(ThreadRoots)) {
|
if (verify(ThreadRoots)) {
|
||||||
|
shenandoah_assert_safepoint();
|
||||||
// Do thread roots the last. This allows verification code to find
|
// Do thread roots the last. This allows verification code to find
|
||||||
// any broken objects from those special roots first, not the accidental
|
// any broken objects from those special roots first, not the accidental
|
||||||
// dangling reference from the thread root.
|
// dangling reference from the thread root.
|
||||||
@ -90,6 +99,8 @@ void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ShenandoahRootVerifier::roots_do(OopClosure* oops) {
|
void ShenandoahRootVerifier::roots_do(OopClosure* oops) {
|
||||||
|
shenandoah_assert_safepoint();
|
||||||
|
|
||||||
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
|
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
|
||||||
CodeCache::blobs_do(&blobs);
|
CodeCache::blobs_do(&blobs);
|
||||||
|
|
||||||
@ -117,6 +128,8 @@ void ShenandoahRootVerifier::roots_do(OopClosure* oops) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {
|
void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {
|
||||||
|
shenandoah_assert_safepoint();
|
||||||
|
|
||||||
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
|
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
|
||||||
|
|
||||||
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
|
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
|
||||||
|
@ -965,14 +965,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void ShenandoahVerifier::verify_roots_no_forwarded() {
|
void ShenandoahVerifier::verify_roots_no_forwarded() {
|
||||||
guarantee(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "only when nothing else happens");
|
|
||||||
ShenandoahRootVerifier verifier;
|
ShenandoahRootVerifier verifier;
|
||||||
ShenandoahVerifyNoForwared cl;
|
ShenandoahVerifyNoForwared cl;
|
||||||
verifier.oops_do(&cl);
|
verifier.oops_do(&cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShenandoahVerifier::verify_roots_no_forwarded_except(ShenandoahRootVerifier::RootTypes types) {
|
void ShenandoahVerifier::verify_roots_no_forwarded_except(ShenandoahRootVerifier::RootTypes types) {
|
||||||
guarantee(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "only when nothing else happens");
|
|
||||||
ShenandoahRootVerifier verifier;
|
ShenandoahRootVerifier verifier;
|
||||||
verifier.excludes(types);
|
verifier.excludes(types);
|
||||||
ShenandoahVerifyNoForwared cl;
|
ShenandoahVerifyNoForwared cl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user