8286297: G1: Simplify parallel and serial verification code paths

Reviewed-by: ayang, lkorinth
This commit is contained in:
Thomas Schatzl 2022-05-16 11:08:43 +00:00
parent 0155e4b76b
commit 652044d82b

View File

@ -352,15 +352,13 @@ void G1HeapVerifier::verify_archive_regions() {
class VerifyRegionClosure: public HeapRegionClosure { class VerifyRegionClosure: public HeapRegionClosure {
private: private:
bool _par;
VerifyOption _vo; VerifyOption _vo;
bool _failures; bool _failures;
public: public:
// _vo == UsePrevMarking -> use "prev" marking information, // _vo == UsePrevMarking -> use "prev" marking information,
// _vo == UseFullMarking -> use "next" marking bitmap but no TAMS // _vo == UseFullMarking -> use "next" marking bitmap but no TAMS
VerifyRegionClosure(bool par, VerifyOption vo) VerifyRegionClosure(VerifyOption vo)
: _par(par), : _vo(vo),
_vo(vo),
_failures(false) {} _failures(false) {}
bool failures() { bool failures() {
@ -415,9 +413,9 @@ public:
} }
}; };
// This is the task used for parallel verification of the heap regions // This is the task used for verification of the heap regions
class G1ParVerifyTask: public WorkerTask { class G1VerifyTask: public WorkerTask {
private: private:
G1CollectedHeap* _g1h; G1CollectedHeap* _g1h;
VerifyOption _vo; VerifyOption _vo;
@ -427,8 +425,8 @@ private:
public: public:
// _vo == UsePrevMarking -> use "prev" marking information, // _vo == UsePrevMarking -> use "prev" marking information,
// _vo == UseFullMarking -> use "next" marking bitmap but no TAMS // _vo == UseFullMarking -> use "next" marking bitmap but no TAMS
G1ParVerifyTask(G1CollectedHeap* g1h, VerifyOption vo) : G1VerifyTask(G1CollectedHeap* g1h, VerifyOption vo) :
WorkerTask("Parallel verify task"), WorkerTask("Verify task"),
_g1h(g1h), _g1h(g1h),
_vo(vo), _vo(vo),
_failures(false), _failures(false),
@ -439,7 +437,7 @@ public:
} }
void work(uint worker_id) { void work(uint worker_id) {
VerifyRegionClosure blk(true, _vo); VerifyRegionClosure blk(_vo);
_g1h->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id); _g1h->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id);
if (blk.failures()) { if (blk.failures()) {
_failures = true; _failures = true;
@ -491,22 +489,14 @@ void G1HeapVerifier::verify(VerifyOption vo) {
} }
log_debug(gc, verify)("HeapRegions"); log_debug(gc, verify)("HeapRegions");
if (GCParallelVerificationEnabled && ParallelGCThreads > 1) {
G1ParVerifyTask task(_g1h, vo); uint num_workers = GCParallelVerificationEnabled ? _g1h->workers()->active_workers() : 1u;
_g1h->workers()->run_task(&task); G1VerifyTask task(_g1h, vo);
_g1h->workers()->run_task(&task, num_workers);
if (task.failures()) { if (task.failures()) {
failures = true; failures = true;
} }
} else {
VerifyRegionClosure blk(false, vo);
_g1h->heap_region_iterate(&blk);
if (blk.failures()) {
failures = true;
}
}
if (failures) { if (failures) {
log_error(gc, verify)("Heap after failed verification (kind %d):", vo); log_error(gc, verify)("Heap after failed verification (kind %d):", vo);
// It helps to have the per-region information in the output to // It helps to have the per-region information in the output to