--- old/src/hotspot/share/gc/g1/g1HeapVerifier.cpp 2017-11-28 16:24:50.665019284 +0100 +++ new/src/hotspot/share/gc/g1/g1HeapVerifier.cpp 2017-11-28 16:24:50.433010140 +0100 @@ -376,6 +376,34 @@ } }; +void G1HeapVerifier::parse_verification_type(const char* type) { + if (strcmp(type, "young") == 0) { + enable_verification_type(G1VerifyYoung); + } else if (strcmp(type, "mixed") == 0) { + enable_verification_type(G1VerifyMixed); + } else if (strcmp(type, "remark") == 0) { + enable_verification_type(G1VerifyRemark); + } else if (strcmp(type, "cleanup") == 0) { + enable_verification_type(G1VerifyCleanup); + } else if (strcmp(type, "full") == 0) { + enable_verification_type(G1VerifyFull); + } else { + log_warning(gc, verify)("VerifyGCType: '%s' is unknown. Available are: young, mixed, remark, cleanup and full ", type); + } +} + +void G1HeapVerifier::enable_verification_type(G1VerifyType type) { + // First enable will clear _types. + if (_enabled_verification_types == G1VerifyAll) { + _enabled_verification_types = type; + } else { + _enabled_verification_types |= type; + } +} + +bool G1HeapVerifier::should_verify(G1VerifyType type) { + return (_enabled_verification_types & type) == type; +} void G1HeapVerifier::verify(VerifyOption vo) { if (!SafepointSynchronize::is_at_safepoint()) { @@ -541,28 +569,32 @@ } } -double G1HeapVerifier::verify(bool guard, const char* msg) { +double G1HeapVerifier::verify(G1VerifyType type, VerifyOption vo, const char* msg) { double verify_time_ms = 0.0; - if (guard && _g1h->total_collections() >= VerifyGCStartAt) { + if (should_verify(type) && _g1h->total_collections() >= VerifyGCStartAt) { double verify_start = os::elapsedTime(); HandleMark hm; // Discard invalid handles created during verification prepare_for_verify(); - Universe::verify(VerifyOption_G1UsePrevMarking, msg); + Universe::verify(vo, msg); verify_time_ms = (os::elapsedTime() - verify_start) * 1000; } return verify_time_ms; } -void G1HeapVerifier::verify_before_gc() { - double verify_time_ms = verify(VerifyBeforeGC, "Before GC"); - _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms); +void G1HeapVerifier::verify_before_gc(G1VerifyType type) { + if (VerifyBeforeGC) { + double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "Before GC"); + _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms); + } } -void G1HeapVerifier::verify_after_gc() { - double verify_time_ms = verify(VerifyAfterGC, "After GC"); - _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms); +void G1HeapVerifier::verify_after_gc(G1VerifyType type) { + if (VerifyAfterGC) { + double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "After GC"); + _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms); + } }