Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8257151: ZGC: Simplify ZVerify
Reviewed-by: pliden, eosterlund
  • Loading branch information
stefank committed Nov 26, 2020
1 parent bf66d73 commit 0a5de50
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
58 changes: 29 additions & 29 deletions src/hotspot/share/gc/z/zVerify.cpp
Expand Up @@ -252,6 +252,9 @@ class ZVerifyNMethodClosure : public NMethodClosure {
};

void ZVerify::roots_strong(bool verify_fixed) {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
assert(!ZResurrection::is_blocked(), "Invalid phase");

ZVerifyRootClosure cl(verify_fixed);
ZVerifyCLDClosure cld_cl(&cl);
ZVerifyThreadClosure thread_cl(&cl);
Expand All @@ -265,56 +268,53 @@ void ZVerify::roots_strong(bool verify_fixed) {
}

void ZVerify::roots_weak() {
ZVerifyRootClosure cl(true /* verify_fixed */);
ZWeakRootsIterator iter;
iter.apply(&cl);
}

void ZVerify::roots(bool verify_strong, bool verify_weaks) {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
assert(!ZResurrection::is_blocked(), "Invalid phase");

if (ZVerifyRoots) {
roots_strong(verify_strong);
if (verify_weaks) {
roots_weak();
}
}
ZVerifyRootClosure cl(true /* verify_fixed */);
ZWeakRootsIterator iter;
iter.apply(&cl);
}

void ZVerify::objects(bool verify_weaks) {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
assert(ZGlobalPhase == ZPhaseMarkCompleted, "Invalid phase");
assert(!ZResurrection::is_blocked(), "Invalid phase");

if (ZVerifyObjects) {
ZVerifyOopClosure cl(verify_weaks);
ObjectToOopClosure object_cl(&cl);
ZHeap::heap()->object_iterate(&object_cl, verify_weaks);
}
}

void ZVerify::roots_and_objects(bool verify_strong, bool verify_weaks) {
roots(verify_strong, verify_weaks);
objects(verify_weaks);
ZVerifyOopClosure cl(verify_weaks);
ObjectToOopClosure object_cl(&cl);
ZHeap::heap()->object_iterate(&object_cl, verify_weaks);
}

void ZVerify::before_zoperation() {
// Verify strong roots
ZStatTimerDisable disable;
roots(false /* verify_strong */, false /* verify_weaks */);
if (ZVerifyRoots) {
roots_strong(false /* verify_fixed */);
}
}

void ZVerify::after_mark() {
// Verify all strong roots and strong references
ZStatTimerDisable disable;
roots_and_objects(true /* verify_strong */, false /* verify_weaks */);
if (ZVerifyRoots) {
roots_strong(true /* verify_fixed */);
}
if (ZVerifyObjects) {
objects(false /* verify_weaks */);
}
}

void ZVerify::after_weak_processing() {
// Verify all roots and all references
ZStatTimerDisable disable;
roots_and_objects(true /* verify_strong */, true /* verify_weaks */);
if (ZVerifyRoots) {
roots_strong(true /* verify_fixed */);
roots_weak();
}
if (ZVerifyObjects) {
objects(true /* verify_weaks */);
}
}

template <bool Map>
Expand Down Expand Up @@ -379,10 +379,10 @@ class StackWatermarkProcessingMark {

public:
StackWatermarkProcessingMark(Thread* thread) :
_rnhm(),
_hm(thread),
_pem(thread),
_rm(thread) { }
_rnhm(),
_hm(thread),
_pem(thread),
_rm(thread) {}
};

void ZVerify::verify_frame_bad(const frame& fr, RegisterMap& register_map) {
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/z/zVerify.hpp
Expand Up @@ -34,9 +34,7 @@ class ZVerify : public AllStatic {
static void roots_strong(bool verify_fixed);
static void roots_weak();

static void roots(bool verify_strong, bool verify_weaks);
static void objects(bool verify_weaks);
static void roots_and_objects(bool verify_strong, bool verify_weaks);

public:
static void before_zoperation();
Expand Down

1 comment on commit 0a5de50

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.