8224751: Shenandoah: Shenandoah Verifier should select proper roots according to current GC cycle

Reviewed-by: rkennke
This commit is contained in:
Zhengyu Gu 2019-05-27 14:34:58 -04:00
parent 5461726dcc
commit a7307e2709
3 changed files with 55 additions and 2 deletions

View File

@ -59,7 +59,7 @@ void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
} }
if (verify(CLDGRoots)) { if (verify(CLDGRoots)) {
CLDToOopClosure clds(oops, ClassLoaderData::_claim_strong); CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
ClassLoaderDataGraph::cld_do(&clds); ClassLoaderDataGraph::cld_do(&clds);
} }
@ -88,3 +88,49 @@ void ShenandoahRootVerifier::oops_do(OopClosure* oops) {
Threads::possibly_parallel_oops_do(false, oops, &blobs); Threads::possibly_parallel_oops_do(false, oops, &blobs);
} }
} }
void ShenandoahRootVerifier::roots_do(OopClosure* oops) {
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
CodeCache::blobs_do(&blobs);
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
ClassLoaderDataGraph::cld_do(&clds);
Universe::oops_do(oops);
Management::oops_do(oops);
JvmtiExport::oops_do(oops);
JNIHandles::oops_do(oops);
ObjectSynchronizer::oops_do(oops);
SystemDictionary::oops_do(oops);
AlwaysTrueClosure always_true;
WeakProcessor::weak_oops_do(&always_true, oops);
if (ShenandoahStringDedup::is_enabled()) {
ShenandoahStringDedup::oops_do_slow(oops);
}
// Do thread roots the last. This allows verification code to find
// any broken objects from those special roots first, not the accidental
// dangling reference from the thread root.
Threads::possibly_parallel_oops_do(false, oops, &blobs);
}
void ShenandoahRootVerifier::strong_roots_do(OopClosure* oops) {
CodeBlobToOopClosure blobs(oops, !CodeBlobToOopClosure::FixRelocations);
CLDToOopClosure clds(oops, ClassLoaderData::_claim_none);
ClassLoaderDataGraph::roots_cld_do(&clds, NULL);
Universe::oops_do(oops);
Management::oops_do(oops);
JvmtiExport::oops_do(oops);
JNIHandles::oops_do(oops);
ObjectSynchronizer::oops_do(oops);
SystemDictionary::oops_do(oops);
// Do thread roots the last. This allows verification code to find
// any broken objects from those special roots first, not the accidental
// dangling reference from the thread root.
Threads::possibly_parallel_oops_do(false, oops, &blobs);
}

View File

@ -48,6 +48,9 @@ public:
void excludes(RootTypes types); void excludes(RootTypes types);
void oops_do(OopClosure* cl); void oops_do(OopClosure* cl);
// Used to seed ShenandoahVerifier, do not honor root type filter
void roots_do(OopClosure* cl);
void strong_roots_do(OopClosure* cl);
private: private:
bool verify(RootTypes type) const; bool verify(RootTypes type) const;
}; };

View File

@ -458,7 +458,11 @@ public:
ShenandoahVerifyOopClosure cl(&stack, _bitmap, _ld, ShenandoahVerifyOopClosure cl(&stack, _bitmap, _ld,
ShenandoahMessageBuffer("%s, Roots", _label), ShenandoahMessageBuffer("%s, Roots", _label),
_options); _options);
_verifier->oops_do(&cl); if (_heap->unload_classes()) {
_verifier->strong_roots_do(&cl);
} else {
_verifier->roots_do(&cl);
}
} }
size_t processed = 0; size_t processed = 0;