--- old/src/hotspot/share/gc/g1/g1Arguments.cpp 2017-11-29 12:36:29.272645044 +0100 +++ new/src/hotspot/share/gc/g1/g1Arguments.cpp 2017-11-29 12:36:29.052636303 +0100 @@ -95,8 +95,10 @@ log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); } -void G1Arguments::parse_verification_type(const char* type) { +bool G1Arguments::parse_verification_type(const char* type) { G1CollectedHeap::heap()->verifier()->parse_verification_type(type); + // Always return true because we want to parse all values. + return true; } CollectedHeap* G1Arguments::create_heap() { --- old/src/hotspot/share/gc/g1/g1Arguments.hpp 2017-11-29 12:36:29.984673334 +0100 +++ new/src/hotspot/share/gc/g1/g1Arguments.hpp 2017-11-29 12:36:29.748663957 +0100 @@ -32,7 +32,7 @@ class G1Arguments : public GCArguments { public: virtual void initialize_flags(); - virtual void parse_verification_type(const char* type); + virtual bool parse_verification_type(const char* type); virtual size_t conservative_max_heap_alignment(); virtual CollectedHeap* create_heap(); }; --- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-29 12:36:30.676700830 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-29 12:36:30.448691770 +0100 @@ -1083,7 +1083,14 @@ PostCompactionPrinterClosure cl(hr_printer()); heap_region_iterate(&cl); } +} +G1HeapVerifier::G1VerifyType G1CollectedHeap::young_verification_type() { + if (collector_state()->yc_type() == Mixed) { + return G1HeapVerifier::G1VerifyMixed; + } else { + return G1HeapVerifier::G1VerifyYoung; + } } void G1CollectedHeap::abort_concurrent_cycle() { @@ -2984,7 +2991,7 @@ heap_region_iterate(&v_cl); } - _verifier->verify_before_gc(collector_state()->yc_type() == Mixed ? G1HeapVerifier::G1VerifyMixed : G1HeapVerifier::G1VerifyYoung); + _verifier->verify_before_gc(young_verification_type()); _verifier->check_bitmaps("GC Start"); @@ -3144,7 +3151,7 @@ heap_region_iterate(&v_cl); } - _verifier->verify_after_gc(collector_state()->yc_type() == Mixed ? G1HeapVerifier::G1VerifyMixed : G1HeapVerifier::G1VerifyYoung); + _verifier->verify_after_gc(young_verification_type()); _verifier->check_bitmaps("GC End"); assert(!ref_processor_stw()->discovery_enabled(), "Postcondition"); --- old/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-29 12:36:31.492733252 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-29 12:36:31.244723398 +0100 @@ -526,6 +526,9 @@ void verify_after_full_collection(); void print_heap_after_full_collection(G1HeapTransition* heap_transition); + // Verification type helper. + G1HeapVerifier::G1VerifyType young_verification_type(); + // Helper method for satisfy_failed_allocation() HeapWord* satisfy_failed_allocation_helper(size_t word_size, AllocationContext_t context, --- old/src/hotspot/share/gc/g1/g1FullCollector.cpp 2017-11-29 12:36:32.200761383 +0100 +++ new/src/hotspot/share/gc/g1/g1FullCollector.cpp 2017-11-29 12:36:31.976752483 +0100 @@ -246,7 +246,7 @@ void G1FullCollector::verify_after_marking() { if (!VerifyDuringGC || !_heap->verifier()->should_verify(G1HeapVerifier::G1VerifyFull)) { - //Only do verification if VerifyDuringGC and Verify_Full is set. + // Only do verification if VerifyDuringGC and G1VerifyFull is set. return; } --- old/src/hotspot/share/gc/g1/g1HeapVerifier.cpp 2017-11-29 12:36:32.912789673 +0100 +++ new/src/hotspot/share/gc/g1/g1HeapVerifier.cpp 2017-11-29 12:36:32.672780137 +0100 @@ -388,12 +388,12 @@ } 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); + log_warning(gc, verify)("VerifyGCType: '%s' is unknown. Available types are: young, mixed, remark, cleanup and full", type); } } void G1HeapVerifier::enable_verification_type(G1VerifyType type) { - // First enable will clear _types. + // First enable will clear _enabled_verification_types. if (_enabled_verification_types == G1VerifyAll) { _enabled_verification_types = type; } else { --- old/src/hotspot/share/gc/shared/gcArguments.cpp 2017-11-29 12:36:33.652819076 +0100 +++ new/src/hotspot/share/gc/shared/gcArguments.cpp 2017-11-29 12:36:33.404809222 +0100 @@ -85,8 +85,10 @@ #endif // INCLUDE_ALL_GCS } -void GCArguments::parse_verification_type(const char* type) { +bool GCArguments::parse_verification_type(const char* type) { log_warning(gc, verify)("VerifyGCType is not supported by this collector."); + // Return false to avoid multiple warnings. + return false; } void GCArguments::initialize_flags() { @@ -112,7 +114,10 @@ strncpy(type_list, VerifyGCType, length + 1); char* token = strtok(type_list, delimiter); while (token != NULL) { - parse_verification_type(token); + bool success = parse_verification_type(token); + if (!success) { + break; + } token = strtok(NULL, delimiter); } FREE_C_HEAP_ARRAY(char, type_list); --- old/src/hotspot/share/gc/shared/gcArguments.hpp 2017-11-29 12:36:34.392848478 +0100 +++ new/src/hotspot/share/gc/shared/gcArguments.hpp 2017-11-29 12:36:34.144838624 +0100 @@ -49,7 +49,7 @@ void post_heap_initialize(); virtual void initialize_flags(); - virtual void parse_verification_type(const char* type); + virtual bool parse_verification_type(const char* type); virtual size_t conservative_max_heap_alignment() = 0; --- old/src/hotspot/share/runtime/globals.hpp 2017-11-29 12:36:35.128877722 +0100 +++ new/src/hotspot/share/runtime/globals.hpp 2017-11-29 12:36:34.896868504 +0100 @@ -2273,7 +2273,7 @@ \ diagnostic(ccstrlist, VerifyGCType, "", \ "GC type(s) to verify when Verify*GC is enabled." \ - "Available types are: young, mixed, concurrent, full") \ + "Available types are: young, mixed, remark, cleanup and full") \ \ diagnostic(ccstrlist, VerifySubSet, "", \ "Memory sub-systems to verify when Verify*GC flag(s) " \ --- old/test/hotspot/gtest/gc/g1/test_g1HeapVerifier.cpp 2017-11-29 12:36:35.896908237 +0100 +++ new/test/hotspot/gtest/gc/g1/test_g1HeapVerifier.cpp 2017-11-29 12:36:35.672899337 +0100 @@ -70,7 +70,3 @@ // Enabling all is not the same as G1VerifyAll ASSERT_FALSE(verifier.should_verify(G1HeapVerifier::G1VerifyAll)); } - - - - --- old/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java 2017-11-29 12:36:36.580935414 +0100 +++ new/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java 2017-11-29 12:36:36.352926355 +0100 @@ -39,12 +39,20 @@ import jdk.test.lib.process.ProcessTools; public class TestVerifyGCType { - public static final String VERIFY_TAG = "[gc,verify]"; - public static final String VERIFY_BEFORE = "Verifying Before GC"; - public static final String VERIFY_DURING = "Verifying During GC"; - public static final String VERIFY_AFTER = "Verifying After GC"; + public static final String VERIFY_TAG = "[gc,verify]"; + public static final String VERIFY_BEFORE = "Verifying Before GC"; + public static final String VERIFY_DURING = "Verifying During GC"; + public static final String VERIFY_AFTER = "Verifying After GC"; public static void main(String args[]) throws Exception { + testAllVerificationEnabled(); + testAllExplicitlyEnabled(); + testFullAndRemark(); + testBadVerificationType(); + testUnsupportedCollector(); + } + + private static void testAllVerificationEnabled() throws Exception { // Test with all verification enabled OutputAnalyzer output = testWithVerificationType(new String[0]); output.shouldHaveExitValue(0); @@ -53,7 +61,10 @@ verifyCollection("Pause Remark", false, true, false, output.getStdout()); verifyCollection("Pause Cleanup", false, true, false, output.getStdout()); verifyCollection("Pause Full", true, true, true, output.getStdout()); + } + private static void testAllExplicitlyEnabled() throws Exception { + OutputAnalyzer output; // Test with all explicitly enabled output = testWithVerificationType(new String[] {"young", "remark", "cleanup", "full"}); output.shouldHaveExitValue(0); @@ -62,7 +73,10 @@ verifyCollection("Pause Remark", false, true, false, output.getStdout()); verifyCollection("Pause Cleanup", false, true, false, output.getStdout()); verifyCollection("Pause Full", true, true, true, output.getStdout()); + } + private static void testFullAndRemark() throws Exception { + OutputAnalyzer output; // Test with full and remark output = testWithVerificationType(new String[] {"remark", "full"}); output.shouldHaveExitValue(0); @@ -71,17 +85,23 @@ verifyCollection("Pause Remark", false, true, false, output.getStdout()); verifyCollection("Pause Cleanup", false, false, false, output.getStdout()); verifyCollection("Pause Full", true, true, true, output.getStdout()); + } + private static void testBadVerificationType() throws Exception { + OutputAnalyzer output; // Test bad type output = testWithVerificationType(new String[] {"old"}); output.shouldHaveExitValue(0); - output.shouldMatch("VerifyGCType: '.*' is unknown. Available are: young, mixed, remark, cleanup and full "); + output.shouldMatch("VerifyGCType: '.*' is unknown. Available types are: young, mixed, remark, cleanup and full"); verifyCollection("Pause Young", true, false, true, output.getStdout()); verifyCollection("Pause Remark", false, true, false, output.getStdout()); verifyCollection("Pause Cleanup", false, true, false, output.getStdout()); verifyCollection("Pause Full", true, true, true, output.getStdout()); + } + private static void testUnsupportedCollector() throws Exception { + OutputAnalyzer output; // Test bad gc output = testWithBadGC(); output.shouldHaveExitValue(0);