diff --git a/src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp b/src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp index 9c22c29a107..19e51fbb9b8 100644 --- a/src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp +++ b/src/hotspot/share/gc/cms/jvmFlagConstraintsCMS.cpp @@ -36,6 +36,10 @@ static JVMFlag::Error ParallelGCThreadsAndCMSWorkQueueDrainThreshold(uint threads, uintx threshold, bool verbose) { // CMSWorkQueueDrainThreshold is verified to be less than max_juint if (UseConcMarkSweepGC && (threads > (uint)(max_jint / (uint)threshold))) { + if (VerifyFlagConstraints) { + //JVMFlag::printError(true, "ParallelGCThreads:"UINT32_FORMAT"\n", ) + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "ParallelGCThreads (" UINT32_FORMAT ") or CMSWorkQueueDrainThreshold (" UINTX_FORMAT ") is too large\n", diff --git a/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp b/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp index 6b581ccb02e..f0d31d22adf 100644 --- a/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp +++ b/src/hotspot/share/gc/g1/jvmFlagConstraintsG1.cpp @@ -29,42 +29,61 @@ #include "utilities/globalDefinitions.hpp" JVMFlag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "G1RSetRegionEntriesConstraintFunc\n"); + if (!UseG1GC) return JVMFlag::SUCCESS; // Default value of G1RSetRegionEntries=0 means will be set ergonomically. // Minimum value is 1. if (FLAG_IS_CMDLINE(G1RSetRegionEntries) && (value < 1)) { - JVMFlag::printError(verbose, - "G1RSetRegionEntries (" INTX_FORMAT ") must be " - "greater than or equal to 1\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "G1RSetRegionEntries:1\n"); + return JVMFlag::SUCCESS; + } + else + { + JVMFlag::printError(verbose, + "G1RSetRegionEntries (" INTX_FORMAT ") must be " + "greater than or equal to 1\n", + value); + return JVMFlag::VIOLATES_CONSTRAINT; + } } else { return JVMFlag::SUCCESS; } } JVMFlag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "G1RSetSparseRegionEntriesConstraintFunc\n"); if (!UseG1GC) return JVMFlag::SUCCESS; // Default value of G1RSetSparseRegionEntries=0 means will be set ergonomically. // Minimum value is 1. if (FLAG_IS_CMDLINE(G1RSetSparseRegionEntries) && (value < 1)) { - JVMFlag::printError(verbose, - "G1RSetSparseRegionEntries (" INTX_FORMAT ") must be " - "greater than or equal to 1\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "G1RSetSparseRegionEntries:1\n"); + return JVMFlag::SUCCESS; + } + else + { + JVMFlag::printError(verbose, + "G1RSetSparseRegionEntries (" INTX_FORMAT ") must be " + "greater than or equal to 1\n", + value); + return JVMFlag::VIOLATES_CONSTRAINT; + } } else { return JVMFlag::SUCCESS; } } JVMFlag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "G1HeapRegionSizeConstraintFunc\n"); if (!UseG1GC) return JVMFlag::SUCCESS; // Default value of G1HeapRegionSize=0 means will be set ergonomically. if (FLAG_IS_CMDLINE(G1HeapRegionSize) && (value < HeapRegionBounds::min_size())) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "G1HeapRegionSize:"SIZE_FORMAT"\n", HeapRegionBounds::min_size()); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "G1HeapRegionSize (" SIZE_FORMAT ") must be " "greater than or equal to ergonomic heap region minimum size\n", @@ -76,10 +95,13 @@ JVMFlag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) { } JVMFlag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "G1NewSizePercentConstraintFunc\n"); if (!UseG1GC) return JVMFlag::SUCCESS; - if (value > G1MaxNewSizePercent) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "G1MaxNewSizePercent:"UINTX_FORMAT"\n", G1MaxNewSizePercent); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "G1NewSizePercent (" UINTX_FORMAT ") must be " "less than or equal to G1MaxNewSizePercent (" UINTX_FORMAT ")\n", @@ -91,10 +113,13 @@ JVMFlag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "G1MaxNewSizePercentConstraintFunc\n"); if (!UseG1GC) return JVMFlag::SUCCESS; - if (value < G1NewSizePercent) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "G1MaxNewSizePercent:"UINTX_FORMAT"\n", G1NewSizePercent); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "G1MaxNewSizePercent (" UINTX_FORMAT ") must be " "greater than or equal to G1NewSizePercent (" UINTX_FORMAT ")\n", @@ -106,8 +131,12 @@ JVMFlag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose) { - JVMFlag::printError(true, "MaxGCPauseMillisConstraintFuncG1\n"); if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "MaxGCPauseMillis:"UINTX_FORMAT"\n", (GCPauseIntervalMillis-1)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MaxGCPauseMillis (" UINTX_FORMAT ") must be " "less than GCPauseIntervalMillis (" UINTX_FORMAT ")\n", @@ -119,10 +148,14 @@ JVMFlag::Error MaxGCPauseMillisConstraintFuncG1(uintx value, bool verbose) { } JVMFlag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) { - JVMFlag::printError(true, "GCPauseIntervalMillisConstraintFuncG1\n"); if (UseG1GC) { if (FLAG_IS_CMDLINE(GCPauseIntervalMillis)) { if (value < 1) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "GCPauseIntervalMillis:"UINTX_FORMAT"\n", 1); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " "greater than or equal to 1\n", @@ -131,6 +164,11 @@ JVMFlag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) } if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "GCPauseIntervalMillis:MaxGCPauseMillis\n"); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "GCPauseIntervalMillis cannot be set " "without setting MaxGCPauseMillis\n"); @@ -138,6 +176,11 @@ JVMFlag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) } if (value <= MaxGCPauseMillis) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "GCPauseIntervalMillis:"UINTX_FORMAT"\n", (MaxGCPauseMillis + 1)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " "greater than MaxGCPauseMillis (" UINTX_FORMAT ")\n", @@ -151,13 +194,17 @@ JVMFlag::Error GCPauseIntervalMillisConstraintFuncG1(uintx value, bool verbose) } JVMFlag::Error NewSizeConstraintFuncG1(size_t value, bool verbose) { - JVMFlag::printError(true, "NewSizeConstraintFuncG1\n"); #ifdef _LP64 // Overflow would happen for uint type variable of YoungGenSizer::_min_desired_young_length // when the value to be assigned exceeds uint range. // i.e. result of '(uint)(NewSize / region size(1~32MB))' // So maximum of NewSize should be 'max_juint * 1M' if (UseG1GC && (value > (max_juint * 1 * M))) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "NewSize:"SIZE_FORMAT"\n", (max_juint * 1 * M)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "NewSize (" SIZE_FORMAT ") must be less than ergonomic maximum value\n", value); diff --git a/src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp b/src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp index 2db70dc1412..91ababb4d23 100644 --- a/src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp +++ b/src/hotspot/share/gc/parallel/jvmFlagConstraintsParallel.cpp @@ -30,8 +30,11 @@ JVMFlag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose) { // Parallel GC passes ParallelGCThreads when creating GrowableArray as 'int' type parameter. // So can't exceed with "max_jint" - JVMFlag::printError(false, "ParallelGCThreadsConstraintFuncParallel\n"); if (UseParallelGC && (value > (uint)max_jint)) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "ParallelGCThreads:"UINT32_FORMAT"\n", max_jint); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "ParallelGCThreads (" UINT32_FORMAT ") must be " "less than or equal to " UINT32_FORMAT " for Parallel GC\n", @@ -42,9 +45,12 @@ JVMFlag::Error ParallelGCThreadsConstraintFuncParallel(uint value, bool verbose) } JVMFlag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) { - JVMFlag::printError(false, "InitialTenuringThresholdConstraintFuncParallel\n"); // InitialTenuringThreshold is only used for ParallelGC. if (UseParallelGC && (value > MaxTenuringThreshold)) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "InitialTenuringThreshold"UINTX_FORMAT"\n", MaxTenuringThreshold); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "InitialTenuringThreshold (" UINTX_FORMAT ") must be " "less than or equal to MaxTenuringThreshold (" UINTX_FORMAT ")\n", @@ -55,10 +61,13 @@ JVMFlag::Error InitialTenuringThresholdConstraintFuncParallel(uintx value, bool } JVMFlag::Error MaxTenuringThresholdConstraintFuncParallel(uintx value, bool verbose) { - JVMFlag::printError(false, "MaxTenuringThresholdConstraintFuncParallel\n"); // As only ParallelGC uses InitialTenuringThreshold, // we don't need to compare InitialTenuringThreshold with MaxTenuringThreshold. if (UseParallelGC && (value < InitialTenuringThreshold)) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MaxTenuringThreshold"UINTX_FORMAT"\n", InitialTenuringThreshold); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MaxTenuringThreshold (" UINTX_FORMAT ") must be " "greater than or equal to InitialTenuringThreshold (" UINTX_FORMAT ")\n", diff --git a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp index 78c04f003cf..197d16806ac 100644 --- a/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp +++ b/src/hotspot/share/gc/shared/jvmFlagConstraintsGC.cpp @@ -50,6 +50,7 @@ #ifdef COMPILER2 #include "opto/c2_globals.hpp" #endif // COMPILER2 +#include // Some flags that have default values that indicate that the // JVM should automatically determine an appropriate value @@ -62,7 +63,6 @@ // As ParallelGCThreads differs among GC modes, we need constraint function. JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) { JVMFlag::Error status = JVMFlag::SUCCESS; - JVMFlag::printError(true, "ParallelGCThreadsConstraintFunc\n"); #if INCLUDE_PARALLELGC status = ParallelGCThreadsConstraintFuncParallel(value, verbose); if (status != JVMFlag::SUCCESS) { @@ -83,10 +83,13 @@ JVMFlag::Error ParallelGCThreadsConstraintFunc(uint value, bool verbose) { // As ConcGCThreads should be smaller than ParallelGCThreads, // we need constraint function. JVMFlag::Error ConcGCThreadsConstraintFunc(uint value, bool verbose) { - JVMFlag::printError(true, "ConcGCThreadsConstraintFunc\n"); // CMS and G1 GCs use ConcGCThreads. if ((GCConfig::is_gc_selected(CollectedHeap::CMS) || GCConfig::is_gc_selected(CollectedHeap::G1)) && (value > ParallelGCThreads)) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "ConcGCThreads"UINT32_FORMAT"\n", ParallelGCThreads); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "ConcGCThreads (" UINT32_FORMAT ") must be " "less than or equal to ParallelGCThreads (" UINT32_FORMAT ")\n", @@ -101,6 +104,10 @@ static JVMFlag::Error MinPLABSizeBounds(const char* name, size_t value, bool ver if ((GCConfig::is_gc_selected(CollectedHeap::CMS) || GCConfig::is_gc_selected(CollectedHeap::G1) || GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value < PLAB::min_size())) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "%s:"SIZE_FORMAT"\n", name, PLAB::min_size()); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "%s (" SIZE_FORMAT ") must be " "greater than or equal to ergonomic PLAB minimum size (" SIZE_FORMAT ")\n", @@ -115,6 +122,10 @@ JVMFlag::Error MaxPLABSizeBounds(const char* name, size_t value, bool verbose) { if ((GCConfig::is_gc_selected(CollectedHeap::CMS) || GCConfig::is_gc_selected(CollectedHeap::G1) || GCConfig::is_gc_selected(CollectedHeap::Parallel)) && (value > PLAB::max_size())) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "%s:"SIZE_FORMAT"\n", name, PLAB::max_size()); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "%s (" SIZE_FORMAT ") must be " "less than or equal to ergonomic PLAB maximum size (" SIZE_FORMAT ")\n", @@ -135,12 +146,10 @@ static JVMFlag::Error MinMaxPLABSizeBounds(const char* name, size_t value, bool } JVMFlag::Error YoungPLABSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "YoungPLABSizeConstraintFunc\n"); return MinMaxPLABSizeBounds("YoungPLABSize", value, verbose); } JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "OldPLABSizeConstraintFunc\n"); JVMFlag::Error status = JVMFlag::SUCCESS; #if INCLUDE_CMSGC @@ -156,8 +165,11 @@ JVMFlag::Error OldPLABSizeConstraintFunc(size_t value, bool verbose) { } JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "MinHeapFreeRatioConstraintFunc\n"); if (value > MaxHeapFreeRatio) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MinHeapFreeRatio:"UINTX_FORMAT"\n", MaxHeapFreeRatio); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MinHeapFreeRatio (" UINTX_FORMAT ") must be " "less than or equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n", @@ -169,8 +181,11 @@ JVMFlag::Error MinHeapFreeRatioConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error MaxHeapFreeRatioConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "MaxHeapFreeRatioConstraintFunc\n"); if (value < MinHeapFreeRatio) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MaxHeapFreeRatio:"UINTX_FORMAT"\n", MinHeapFreeRatio); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MaxHeapFreeRatio (" UINTX_FORMAT ") must be " "greater than or equal to MinHeapFreeRatio (" UINTX_FORMAT ")\n", @@ -195,13 +210,28 @@ static JVMFlag::Error CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(size_t maxHeap, } JVMFlag::Error SoftRefLRUPolicyMSPerMBConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "SoftRefLRUPolicyMSPerMBConstraintFunc\n"); - return CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(MaxHeapSize, value, verbose); + if ((value > 0) && ((MaxHeapSize / M) > (max_uintx / value))) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "SoftRefLRUPolicyMSPerMB:"INTX_FORMAT"\n", (max_uintx/(MaxHeapSize / M))); + return JVMFlag::SUCCESS; + } + JVMFlag::printError(verbose, + "Desired lifetime of SoftReferences cannot be expressed correctly. " + "MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB " + "(" INTX_FORMAT ") is too large\n", + MaxHeapSize, value); + return JVMFlag::VIOLATES_CONSTRAINT; + } else { + return JVMFlag::SUCCESS; + } } JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "MarkStackSizeConstraintFunc\n"); if (value > MarkStackSizeMax) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MarkStackSize:"SIZE_FORMAT"\n", MarkStackSizeMax); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MarkStackSize (" SIZE_FORMAT ") must be " "less than or equal to MarkStackSizeMax (" SIZE_FORMAT ")\n", @@ -213,8 +243,11 @@ JVMFlag::Error MarkStackSizeConstraintFunc(size_t value, bool verbose) { } JVMFlag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "MinMetaspaceFreeRatioConstraintFunc\n"); if (value > MaxMetaspaceFreeRatio) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MinMetaspaceFreeRatio:"UINTX_FORMAT"\n", MaxMetaspaceFreeRatio); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MinMetaspaceFreeRatio (" UINTX_FORMAT ") must be " "less than or equal to MaxMetaspaceFreeRatio (" UINTX_FORMAT ")\n", @@ -226,8 +259,11 @@ JVMFlag::Error MinMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "MaxMetaspaceFreeRatioConstraintFunc\n"); if (value < MinMetaspaceFreeRatio) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MaxMetaspaceFreeRatio:"UINTX_FORMAT"\n", MinMetaspaceFreeRatio); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MaxMetaspaceFreeRatio (" UINTX_FORMAT ") must be " "greater than or equal to MinMetaspaceFreeRatio (" UINTX_FORMAT ")\n", @@ -239,7 +275,6 @@ JVMFlag::Error MaxMetaspaceFreeRatioConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "InitialTenuringThresholdConstraintFunc\n"); #if INCLUDE_PARALLELGC JVMFlag::Error status = InitialTenuringThresholdConstraintFuncParallel(value, verbose); if (status != JVMFlag::SUCCESS) { @@ -251,7 +286,6 @@ JVMFlag::Error InitialTenuringThresholdConstraintFunc(uintx value, bool verbose) } JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "MaxTenuringThresholdConstraintFunc\n"); #if INCLUDE_PARALLELGC JVMFlag::Error status = MaxTenuringThresholdConstraintFuncParallel(value, verbose); if (status != JVMFlag::SUCCESS) { @@ -261,6 +295,10 @@ JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) { // MaxTenuringThreshold=0 means NeverTenure=false && AlwaysTenure=true if ((value == 0) && (NeverTenure || !AlwaysTenure)) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MaxTenuringThreshold:NeverTenure=false,AlwaysTenure=true\n"); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MaxTenuringThreshold (0) should match to NeverTenure=false " "&& AlwaysTenure=true. But we have NeverTenure=%s " @@ -273,7 +311,6 @@ JVMFlag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "MaxGCPauseMillisConstraintFunc\n"); #if INCLUDE_G1GC JVMFlag::Error status = MaxGCPauseMillisConstraintFuncG1(value, verbose); if (status != JVMFlag::SUCCESS) { @@ -285,7 +322,6 @@ JVMFlag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "GCPauseIntervalMillisConstraintFunc\n"); #if INCLUDE_G1GC JVMFlag::Error status = GCPauseIntervalMillisConstraintFuncG1(value, verbose); if (status != JVMFlag::SUCCESS) { @@ -297,9 +333,12 @@ JVMFlag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "InitialBootClassLoaderMetaspaceSizeConstraintFunc\n"); size_t aligned_max = align_down(max_uintx/2, Metaspace::reserve_alignment_words()); if (value > aligned_max) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "InitialBootClassLoaderMetaspaceSize:"SIZE_FORMAT"\n", aligned_max); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "InitialBootClassLoaderMetaspaceSize (" SIZE_FORMAT ") must be " "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", @@ -313,6 +352,10 @@ JVMFlag::Error InitialBootClassLoaderMetaspaceSizeConstraintFunc(size_t value, b static JVMFlag::Error MaxSizeForAlignment(const char* name, size_t value, size_t alignment, bool verbose) { size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1)); if (value > aligned_max) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "%s:"SIZE_FORMAT"\n", name, aligned_max); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "%s (" SIZE_FORMAT ") must be " "less than or equal to aligned maximum value (" SIZE_FORMAT ")\n", @@ -339,24 +382,39 @@ static JVMFlag::Error MaxSizeForHeapAlignment(const char* name, size_t value, bo } JVMFlag::Error InitialHeapSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "InitialHeapSizeConstraintFunc\n"); return MaxSizeForHeapAlignment("InitialHeapSize", value, verbose); } JVMFlag::Error MaxHeapSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "MaxHeapSizeConstraintFunc\n"); JVMFlag::Error status = MaxSizeForHeapAlignment("MaxHeapSize", value, verbose); if (status == JVMFlag::SUCCESS) { - status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose); + if ((SoftRefLRUPolicyMSPerMB > 0) && ((value / M) > (max_uintx / SoftRefLRUPolicyMSPerMB))) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MaxHeapSize:"SIZE_FORMAT"\n", (max_uintx / SoftRefLRUPolicyMSPerMB *M)); + return JVMFlag::SUCCESS; + } + JVMFlag::printError(verbose, + "Desired lifetime of SoftReferences cannot be expressed correctly. " + "MaxHeapSize (" SIZE_FORMAT ") or SoftRefLRUPolicyMSPerMB " + "(" INTX_FORMAT ") is too large\n", + value, SoftRefLRUPolicyMSPerMB); + return JVMFlag::VIOLATES_CONSTRAINT; + } else { + return JVMFlag::SUCCESS; + } + //status = CheckMaxHeapSizeAndSoftRefLRUPolicyMSPerMB(value, SoftRefLRUPolicyMSPerMB, verbose); } return status; } #if INCLUDE_ZGC JVMFlag::Error SoftMaxHeapSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "SoftMaxHeapSizeConstraintFunc\n"); if (value > MaxHeapSize) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "SoftMaxHeapSize:"SIZE_FORMAT"\n", MaxHeapSize); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "SoftMaxHeapSize must be less than or equal to the maximum heap size\n"); return JVMFlag::VIOLATES_CONSTRAINT; } @@ -366,22 +424,25 @@ JVMFlag::Error SoftMaxHeapSizeConstraintFunc(size_t value, bool verbose) { #endif JVMFlag::Error HeapBaseMinAddressConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "HeapBaseMinAddressConstraintFunc\n"); // If an overflow happened in Arguments::set_heap_size(), MaxHeapSize will have too large a value. // Check for this by ensuring that MaxHeapSize plus the requested min base address still fit within max_uintx. if (UseCompressedOops && FLAG_IS_ERGO(MaxHeapSize) && (value > (max_uintx - MaxHeapSize))) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + value = max_uintx - MaxHeapSize; + JVMFlag::printError(true, "HeapBaseMinAddress:"SIZE_FORMAT"\n", value); + } else { + JVMFlag::printError(verbose, "HeapBaseMinAddress (" SIZE_FORMAT ") or MaxHeapSize (" SIZE_FORMAT ") is too large. " "Sum of them must be less than or equal to maximum of size_t (" SIZE_FORMAT ")\n", value, MaxHeapSize, max_uintx); - return JVMFlag::VIOLATES_CONSTRAINT; + return JVMFlag::VIOLATES_CONSTRAINT; + } } return MaxSizeForHeapAlignment("HeapBaseMinAddress", value, verbose); } JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "NewSizeConstraintFunc\n"); #if INCLUDE_G1GC JVMFlag::Error status = NewSizeConstraintFuncG1(value, verbose); if (status != JVMFlag::SUCCESS) { @@ -393,42 +454,68 @@ JVMFlag::Error NewSizeConstraintFunc(size_t value, bool verbose) { } JVMFlag::Error MinTLABSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "MinTLABSizeConstraintFunc\n"); // At least, alignment reserve area is needed. + bool verifyFailed = false; if (value < ThreadLocalAllocBuffer::alignment_reserve_in_bytes()) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + verifyFailed = true; + value = ThreadLocalAllocBuffer::alignment_reserve_in_bytes(); + } else { + JVMFlag::printError(verbose, "MinTLABSize (" SIZE_FORMAT ") must be " "greater than or equal to reserved area in TLAB (" SIZE_FORMAT ")\n", value, ThreadLocalAllocBuffer::alignment_reserve_in_bytes()); - return JVMFlag::VIOLATES_CONSTRAINT; + return JVMFlag::VIOLATES_CONSTRAINT; + } } if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + value = (ThreadLocalAllocBuffer::max_size() * HeapWordSize); + verifyFailed = true; + } else { + JVMFlag::printError(verbose, "MinTLABSize (" SIZE_FORMAT ") must be " "less than or equal to ergonomic TLAB maximum (" SIZE_FORMAT ")\n", value, ThreadLocalAllocBuffer::max_size() * HeapWordSize); - return JVMFlag::VIOLATES_CONSTRAINT; + return JVMFlag::VIOLATES_CONSTRAINT; + } + } + if (verifyFailed) { + JVMFlag::printError(true, "MinTLABSize:"SIZE_FORMAT"\n", value); } return JVMFlag::SUCCESS; } JVMFlag::Error TLABSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "TLABSizeConstraintFunc\n"); // Skip for default value of zero which means set ergonomically. if (FLAG_IS_CMDLINE(TLABSize)) { + bool verifyFailed = false; if (value < MinTLABSize) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + value = MinTLABSize; + verifyFailed = true; + } else { + JVMFlag::printError(verbose, "TLABSize (" SIZE_FORMAT ") must be " "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n", value, MinTLABSize); - return JVMFlag::VIOLATES_CONSTRAINT; + return JVMFlag::VIOLATES_CONSTRAINT; + } } if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + value = ThreadLocalAllocBuffer::max_size() * HeapWordSize; + verifyFailed = true; + } else { + JVMFlag::printError(verbose, "TLABSize (" SIZE_FORMAT ") must be " "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n", value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize)); - return JVMFlag::VIOLATES_CONSTRAINT; + return JVMFlag::VIOLATES_CONSTRAINT; + } + } + if (verifyFailed) { + JVMFlag::printError(true, "TLABSize:"SIZE_FORMAT"\n", value); } } return JVMFlag::SUCCESS; @@ -437,12 +524,15 @@ JVMFlag::Error TLABSizeConstraintFunc(size_t value, bool verbose) { // We will protect overflow from ThreadLocalAllocBuffer::record_slow_allocation(), // so AfterMemoryInit type is enough to check. JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "TLABWasteIncrementConstraintFunc\n"); if (UseTLAB) { size_t refill_waste_limit = Thread::current()->tlab().refill_waste_limit(); // Compare with 'max_uintx' as ThreadLocalAllocBuffer::_refill_waste_limit is 'size_t'. if (refill_waste_limit > (max_uintx - value)) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "TLABWasteIncrement:"UINTX_FORMAT"\n", (max_uintx - refill_waste_limit)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "TLABWasteIncrement (" UINTX_FORMAT ") must be " "less than or equal to ergonomic TLAB waste increment maximum size(" SIZE_FORMAT ")\n", @@ -454,10 +544,13 @@ JVMFlag::Error TLABWasteIncrementConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "SurvivorRatioConstraintFunc\n"); if (FLAG_IS_CMDLINE(SurvivorRatio) && (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "SurvivorRatio:"UINTX_FORMAT"\n", (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment())); + return JVMFlag::SUCCESS; + } + JVMFlag::printError(verbose, "SurvivorRatio (" UINTX_FORMAT ") must be " "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n", value, @@ -469,8 +562,11 @@ JVMFlag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) { } JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "MetaspaceSizeConstraintFunc\n"); if (value > MaxMetaspaceSize) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MetaspaceSize:"SIZE_FORMAT"\n", MaxMetaspaceSize); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MetaspaceSize (" SIZE_FORMAT ") must be " "less than or equal to MaxMetaspaceSize (" SIZE_FORMAT ")\n", @@ -482,8 +578,11 @@ JVMFlag::Error MetaspaceSizeConstraintFunc(size_t value, bool verbose) { } JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) { - JVMFlag::printError(true, "MaxMetaspaceSizeConstraintFunc\n"); if (value < MetaspaceSize) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "MaxMetaspaceSize:"SIZE_FORMAT"\n", MetaspaceSize); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "MaxMetaspaceSize (" SIZE_FORMAT ") must be " "greater than or equal to MetaspaceSize (" SIZE_FORMAT ")\n", @@ -495,21 +594,35 @@ JVMFlag::Error MaxMetaspaceSizeConstraintFunc(size_t value, bool verbose) { } JVMFlag::Error SurvivorAlignmentInBytesConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "SurvivorAlignmentInBytesConstraintFunc\n"); if (value != 0) { + bool verifyFailed = false; if (!is_power_of_2(value)) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + verifyFailed = true; + int logValue = log2_intptr(value); + value = (intx)pow(2, logValue); + } else { + JVMFlag::printError(verbose, "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " "power of 2\n", value); - return JVMFlag::VIOLATES_CONSTRAINT; + return JVMFlag::VIOLATES_CONSTRAINT; + } } if (value < ObjectAlignmentInBytes) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + verifyFailed = true; + value = ObjectAlignmentInBytes; + } else { + JVMFlag::printError(verbose, "SurvivorAlignmentInBytes (" INTX_FORMAT ") must be " "greater than or equal to ObjectAlignmentInBytes (" INTX_FORMAT ")\n", value, ObjectAlignmentInBytes); - return JVMFlag::VIOLATES_CONSTRAINT; + return JVMFlag::VIOLATES_CONSTRAINT; + } + } + if (verifyFailed) { + JVMFlag::printError(true, "SurvivorAlignmentInBytes:"INTX_FORMAT"\n", value); } } return JVMFlag::SUCCESS; diff --git a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp index 9f4e6c5a819..d453908c5d0 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp @@ -33,10 +33,15 @@ #include "runtime/flags/jvmFlagConstraintsCompiler.hpp" #include "runtime/globals.hpp" #include "runtime/globals_extension.hpp" +#include JVMFlag::Error AliasLevelConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "AliasLevelConstraintFunc\n"); if ((value <= 1) && (Arguments::mode() == Arguments::_comp || Arguments::mode() == Arguments::_mixed)) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "AliasLevel:2\n"); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "AliasLevel (" INTX_FORMAT ") is not " "compatible with -Xcomp or -Xmixed\n", @@ -63,7 +68,6 @@ JVMFlag::Error AliasLevelConstraintFunc(intx value, bool verbose) { * the minimum number of compiler threads is 2. */ JVMFlag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "CICompilerCountConstraintFunc\n"); int min_number_of_compiler_threads = 0; #if !defined(COMPILER1) && !defined(COMPILER2) && !INCLUDE_JVMCI // case 1 @@ -82,6 +86,11 @@ JVMFlag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { min_number_of_compiler_threads = MIN2(min_number_of_compiler_threads, CI_COMPILER_COUNT); if (value < (intx)min_number_of_compiler_threads) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "CICompilerCount:"INTX_FORMAT"\n", min_number_of_compiler_threads); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "CICompilerCount (" INTX_FORMAT ") must be " "at least %d \n", @@ -93,8 +102,21 @@ JVMFlag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { } JVMFlag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "AllocatePrefetchDistanceConstraintFunc\n"); if (value < 0 || value > 512) { + if (VerifyFlagConstraints) + { + int suggestValue; + if (value < 0) + { + suggestValue = 0; + } + else + { + suggestValue = 512; + } + JVMFlag::printError(true, "AllocatePrefetchDistance:" INTX_FORMAT "\n", suggestValue); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "AllocatePrefetchDistance (" INTX_FORMAT ") must be " "between 0 and " INTX_FORMAT "\n", @@ -106,9 +128,15 @@ JVMFlag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) } JVMFlag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "AllocatePrefetchStepSizeConstraintFunc\n"); if (AllocatePrefetchStyle == 3) { - if (value % wordSize != 0) { + if (value % wordSize != 0) + { + if (VerifyFlagConstraints) + { + int remainder = value % wordSize; + JVMFlag::printError(true, "AllocatePrefetchStepSize:" INTX_FORMAT "\n", (value - remainder)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n", value, wordSize); @@ -119,7 +147,6 @@ JVMFlag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) } JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "AllocatePrefetchInstrConstraintFunc\n"); intx max_value = max_intx; #if defined(SPARC) max_value = 1; @@ -127,6 +154,11 @@ JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { max_value = 3; #endif if (value < 0 || value > max_value) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "AllocatePrefetchInstr:" INTX_FORMAT "\n", (value < 0 ? 0 : max_value)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "AllocatePrefetchInstr (" INTX_FORMAT ") must be " "between 0 and " INTX_FORMAT "\n", value, max_value); @@ -137,8 +169,12 @@ JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { } JVMFlag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "CompileThresholdConstraintFunc\n"); if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "CompileThreshold:" INTX_FORMAT "\n", (value < 0 ? 0 : INT_MAX >> InvocationCounter::count_shift)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "CompileThreshold (" INTX_FORMAT ") " "must be between 0 and %d\n", @@ -151,21 +187,35 @@ JVMFlag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { } JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "OnStackReplacePercentageConstraintFunc\n"); int backward_branch_limit; if (ProfileInterpreter) { if (OnStackReplacePercentage < InterpreterProfilePercentage) { - JVMFlag::printError(verbose, - "OnStackReplacePercentage (" INTX_FORMAT ") must be " - "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", - OnStackReplacePercentage, InterpreterProfilePercentage); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, + "OnStackReplacePercentage:"INTX_FORMAT"\n", InterpreterProfilePercentage); + return JVMFlag::SUCCESS; + } + else + { + JVMFlag::printError(verbose, + "OnStackReplacePercentage (" INTX_FORMAT ") must be " + "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", + OnStackReplacePercentage, InterpreterProfilePercentage); + return JVMFlag::VIOLATES_CONSTRAINT; + } } backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100) << InvocationCounter::count_shift; if (backward_branch_limit < 0) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, + "OnStackReplacePercentage:"INTX_FORMAT"\n", ((INT_MAX >> InvocationCounter::count_shift) / CompileThreshold + InterpreterProfilePercentage)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "CompileThreshold * (InterpreterProfilePercentage - OnStackReplacePercentage) / 100 = " INTX_FORMAT " " @@ -177,6 +227,12 @@ JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) } } else { if (OnStackReplacePercentage < 0 ) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, + "OnStackReplacePercentage:"INTX_FORMAT"\n", 0); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "OnStackReplacePercentage (" INTX_FORMAT ") must be " "non-negative\n", OnStackReplacePercentage); @@ -187,6 +243,11 @@ JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) << InvocationCounter::count_shift; if (backward_branch_limit < 0) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "OnStackReplacePercentage:"INTX_FORMAT"\n", ((INT_MAX >> InvocationCounter::count_shift) / CompileThreshold)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "CompileThreshold * OnStackReplacePercentage / 100 = " INTX_FORMAT " " "must be between 0 and " INTX_FORMAT ", try changing " @@ -200,40 +261,67 @@ JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) } JVMFlag::Error CodeCacheSegmentSizeConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "CodeCacheSegmentSizeConstraintFunc\n"); + bool verifyFailed = false; + uintx max = 0; if (CodeCacheSegmentSize < (uintx)CodeEntryAlignment) { - JVMFlag::printError(verbose, - "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " - "larger than or equal to CodeEntryAlignment (" INTX_FORMAT ") " - "to align entry points\n", - CodeCacheSegmentSize, CodeEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + verifyFailed = true; + max = CodeEntryAlignment; + } + else + { + JVMFlag::printError(verbose, + "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " + "larger than or equal to CodeEntryAlignment (" INTX_FORMAT ") " + "to align entry points\n", + CodeCacheSegmentSize, CodeEntryAlignment); + return JVMFlag::VIOLATES_CONSTRAINT; + } } if (CodeCacheSegmentSize < sizeof(jdouble)) { - JVMFlag::printError(verbose, - "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " - "at least " SIZE_FORMAT " to align constants\n", - CodeCacheSegmentSize, sizeof(jdouble)); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + verifyFailed = true; + max = sizeof(jdouble) >= max ? sizeof(jdouble) : max; + } + else + { + JVMFlag::printError(verbose, + "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " + "at least " SIZE_FORMAT " to align constants\n", + CodeCacheSegmentSize, sizeof(jdouble)); + return JVMFlag::VIOLATES_CONSTRAINT; + } } #ifdef COMPILER2 if (CodeCacheSegmentSize < (uintx)OptoLoopAlignment) { - JVMFlag::printError(verbose, - "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " - "larger than or equal to OptoLoopAlignment (" INTX_FORMAT ") " - "to align inner loops\n", - CodeCacheSegmentSize, OptoLoopAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + verifyFailed = true; + max = (uintx)OptoLoopAlignment > max ? (uintx)OptoLoopAlignment : max; + } + else + { + JVMFlag::printError(verbose, + "CodeCacheSegmentSize (" UINTX_FORMAT ") must be " + "larger than or equal to OptoLoopAlignment (" INTX_FORMAT ") " + "to align inner loops\n", + CodeCacheSegmentSize, OptoLoopAlignment); + return JVMFlag::VIOLATES_CONSTRAINT; + } } #endif - + if (verifyFailed) + { + JVMFlag::printError(true, "CodeCacheSegmentSize:"UINTX_FORMAT"\n", max); + } return JVMFlag::SUCCESS; } JVMFlag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "CompilerThreadPriorityConstraintFunc\n"); #ifdef SOLARIS if ((value < MinimumPriority || value > MaximumPriority) && (value != -1) && (value != -FXCriticalPriority)) { @@ -250,7 +338,6 @@ JVMFlag::Error CompilerThreadPriorityConstraintFunc(intx value, bool verbose) { } JVMFlag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "CodeEntryAlignmentConstraintFunc\n"); #ifdef SPARC if (CodeEntryAlignment % relocInfo::addr_unit() != 0) { JVMFlag::printError(verbose, @@ -259,51 +346,101 @@ JVMFlag::Error CodeEntryAlignmentConstraintFunc(intx value, bool verbose) { return JVMFlag::VIOLATES_CONSTRAINT; } #endif - + bool verifyFailed = false; if (!is_power_of_2(value)) { - JVMFlag::printError(verbose, - "CodeEntryAlignment (" INTX_FORMAT ") must be " - "a power of two\n", CodeEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + verifyFailed = true; + int logValue = log2_intptr(value); + value = (intx)pow(2, logValue); + } + else + { + JVMFlag::printError(verbose, + "CodeEntryAlignment (" INTX_FORMAT ") must be " + "a power of two\n", + CodeEntryAlignment); + return JVMFlag::VIOLATES_CONSTRAINT; + } } - if (CodeEntryAlignment < 16) { + if (value < 16) { + if (VerifyFlagConstraints) + { + value = 16; + } + else + { JVMFlag::printError(verbose, "CodeEntryAlignment (" INTX_FORMAT ") must be " "greater than or equal to %d\n", CodeEntryAlignment, 16); return JVMFlag::VIOLATES_CONSTRAINT; + } + } + + if (verifyFailed) + { + JVMFlag::printError(true, "CodeEntryAlignment:" INTX_FORMAT "\n", value); } return JVMFlag::SUCCESS; } JVMFlag::Error OptoLoopAlignmentConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "OptoLoopAlignmentConstraintFunc\n"); + bool verifyFailed = false; if (!is_power_of_2(value)) { - JVMFlag::printError(verbose, - "OptoLoopAlignment (" INTX_FORMAT ") " - "must be a power of two\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + verifyFailed = true; + int logValue = log2_intptr(value); + value = (intx)pow(2, logValue); + } + else + { + JVMFlag::printError(verbose, + "OptoLoopAlignment (" INTX_FORMAT ") " + "must be a power of two\n", + value); + return JVMFlag::VIOLATES_CONSTRAINT; + } } // Relevant on ppc, s390, sparc. Will be optimized where // addr_unit() == 1. - if (OptoLoopAlignment % relocInfo::addr_unit() != 0) { - JVMFlag::printError(verbose, - "OptoLoopAlignment (" INTX_FORMAT ") must be " - "multiple of NOP size (%d)\n", - value, relocInfo::addr_unit()); - return JVMFlag::VIOLATES_CONSTRAINT; + if (value % relocInfo::addr_unit() != 0) + { + if (VerifyFlagConstraints) + { + verifyFailed = true; + int remainder = value % relocInfo::addr_unit(); + value = value - remainder; + } + else + { + JVMFlag::printError(verbose, + "OptoLoopAlignment (" INTX_FORMAT ") must be " + "multiple of NOP size (%d)\n", + value, relocInfo::addr_unit()); + return JVMFlag::VIOLATES_CONSTRAINT; + } + } + + if (verifyFailed) + { + JVMFlag::printError(verbose, "OptoLoopAlignment:" INTX_FORMAT "\n", value); } return JVMFlag::SUCCESS; } JVMFlag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "ArraycopyDstPrefetchDistanceConstraintFunc\n"); if (value >= 4032) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "ArraycopyDstPrefetchDistance:" UINTX_FORMAT "\n", 4031); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "ArraycopyDstPrefetchDistance (" UINTX_FORMAT ") must be" "between 0 and 4031\n", value); @@ -316,6 +453,11 @@ JVMFlag::Error ArraycopyDstPrefetchDistanceConstraintFunc(uintx value, bool verb JVMFlag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verbose) { JVMFlag::printError(true, "ArraycopySrcPrefetchDistanceConstraintFunc\n"); if (value >= 4032) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "ArraycopySrcPrefetchDistance:" UINTX_FORMAT "\n", 4031); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "ArraycopySrcPrefetchDistance (" UINTX_FORMAT ") must be" "between 0 and 4031\n", value); @@ -326,23 +468,38 @@ JVMFlag::Error ArraycopySrcPrefetchDistanceConstraintFunc(uintx value, bool verb } JVMFlag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) { - JVMFlag::printError(true, "TypeProfileLevelConstraintFunc\n"); + bool verifyFailed = false; + int suggested[3]; for (int i = 0; i < 3; i++) { if (value % 10 > 2) { - JVMFlag::printError(verbose, - "Invalid value (" UINTX_FORMAT ") " - "in TypeProfileLevel at position %d\n", value, i); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + verifyFailed = true; + suggested[i] = 2; + } else { + JVMFlag::printError(verbose, + "Invalid value (" UINTX_FORMAT ") " + "in TypeProfileLevel at position %d\n", + value, i); + return JVMFlag::VIOLATES_CONSTRAINT; + } + } else { + suggested[i] = value % 10; } value = value / 10; } - + if (verifyFailed) { + JVMFlag::printError(true, "TypeProfileLevel:" UINTX_FORMAT "\n", (suggested[0] + suggested[1]*10 + suggested[2]*100)); + } return JVMFlag::SUCCESS; } JVMFlag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "InitArrayShortSizeConstraintFunc\n"); if (value % BytesPerLong != 0) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "InitArrayShortSize:"INTX_FORMAT"\n", (value - BytesPerLong)); + return JVMFlag::SUCCESS; + } return JVMFlag::VIOLATES_CONSTRAINT; } else { return JVMFlag::SUCCESS; @@ -351,13 +508,19 @@ JVMFlag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) { #ifdef COMPILER2 JVMFlag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "InteriorEntryAlignmentConstraintFunc\n"); + bool verifyFailed = false; + intx suggested; if (InteriorEntryAlignment > CodeEntryAlignment) { - JVMFlag::printError(verbose, - "InteriorEntryAlignment (" INTX_FORMAT ") must be " - "less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n", - InteriorEntryAlignment, CodeEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) { + value = CodeEntryAlignment; + verifyFailed = true; + } else { + JVMFlag::printError(verbose, + "InteriorEntryAlignment (" INTX_FORMAT ") must be " + "less than or equal to CodeEntryAlignment (" INTX_FORMAT ")\n", + InteriorEntryAlignment, CodeEntryAlignment); + return JVMFlag::VIOLATES_CONSTRAINT; + } } #ifdef SPARC @@ -370,11 +533,17 @@ JVMFlag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { #endif if (!is_power_of_2(value)) { - JVMFlag::printError(verbose, + if (VerifyFlagConstraints) { + int logValue = log2_intptr(value); + value = (intx)pow(2, logValue); + verifyFailed = true; + } else { + JVMFlag::printError(verbose, "InteriorEntryAlignment (" INTX_FORMAT ") must be " "a power of two\n", InteriorEntryAlignment); - return JVMFlag::VIOLATES_CONSTRAINT; - } + return JVMFlag::VIOLATES_CONSTRAINT; + } + } int minimum_alignment = 16; #if defined(SPARC) || (defined(X86) && !defined(AMD64)) @@ -383,20 +552,33 @@ JVMFlag::Error InteriorEntryAlignmentConstraintFunc(intx value, bool verbose) { minimum_alignment = 2; #endif - if (InteriorEntryAlignment < minimum_alignment) { - JVMFlag::printError(verbose, + if (value < minimum_alignment) { + if (VerifyFlagConstraints) { + value = minimum_alignment; + verifyFailed = true; + } else { + JVMFlag::printError(verbose, "InteriorEntryAlignment (" INTX_FORMAT ") must be " "greater than or equal to %d\n", InteriorEntryAlignment, minimum_alignment); - return JVMFlag::VIOLATES_CONSTRAINT; + return JVMFlag::VIOLATES_CONSTRAINT; + } + } + + if(verifyFailed) { + JVMFlag::printError(true, "InteriorEntryAlignment:"INTX_FORMAT"\n", value); } return JVMFlag::SUCCESS; } JVMFlag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "NodeLimitFudgeFactorConstraintFunc\n"); if (value < MaxNodeLimit * 2 / 100 || value > MaxNodeLimit * 40 / 100) { + if (VerifyFlagConstraints) { + JVMFlag::printError(true, "NodeLimitFudgeFactor:"INTX_FORMAT"\n", + ((value < MaxNodeLimit * 2 / 100)? (MaxNodeLimit * 2 / 100): (MaxNodeLimit * 40 / 100))); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "NodeLimitFudgeFactor must be between 2%% and 40%% " "of MaxNodeLimit (" INTX_FORMAT ")\n", @@ -409,7 +591,6 @@ JVMFlag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose) { #endif // COMPILER2 JVMFlag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) { - JVMFlag::printError(true, "RTMTotalCountIncrRateConstraintFunc\n"); #if INCLUDE_RTM_OPT if (UseRTMLocking && !is_power_of_2(RTMTotalCountIncrRate)) { JVMFlag::printError(verbose, diff --git a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp index 8cf35b6bd07..9160068e0be 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp @@ -29,32 +29,57 @@ #include "runtime/globals.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/task.hpp" +#include JVMFlag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "ObjectAlignmentInBytesConstraintFunc\n"); + bool verifyFailed = false; if (!is_power_of_2(value)) { - JVMFlag::printError(verbose, - "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " - "power of 2\n", - value); - return JVMFlag::VIOLATES_CONSTRAINT; + if (VerifyFlagConstraints) + { + verifyFailed = true; + int logValue = log2_intptr(value); + value = (intx)pow(2, logValue); + } + else + { + JVMFlag::printError(verbose, + "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " + "power of 2\n", + value); + return JVMFlag::VIOLATES_CONSTRAINT; + } } // In case page size is very small. if (value >= (intx)os::vm_page_size()) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "ObjectAlignmentInBytes:" INTX_FORMAT "\n", (intx)(os::vm_page_size()/2)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " "less than page size (" INTX_FORMAT ")\n", value, (intx)os::vm_page_size()); return JVMFlag::VIOLATES_CONSTRAINT; } + if (verifyFailed) + { + JVMFlag::printError(true, "ObjectAlignmentInBytes:" INTX_FORMAT "\n", value); + return JVMFlag::SUCCESS; + } return JVMFlag::SUCCESS; } // Need to enforce the padding not to break the existing field alignments. // It is sufficient to check against the largest type size. JVMFlag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) { - JVMFlag::printError(true, "ContendedPaddingWidthConstraintFunc\n"); if ((value % BytesPerLong) != 0) { + if (VerifyFlagConstraints) + { + int remainder = value % BytesPerLong; + JVMFlag::printError(true, "ContendedPaddingWidth:" INTX_FORMAT "\n", (value - remainder)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "ContendedPaddingWidth (" INTX_FORMAT ") must be " "a multiple of %d\n", @@ -66,8 +91,12 @@ JVMFlag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) { } JVMFlag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) { - JVMFlag::printError(true, "BiasedLockingBulkRebiasThresholdFunc\n"); if (value > BiasedLockingBulkRevokeThreshold) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "BiasedLockingBulkRebiasThreshold:" INTX_FORMAT "\n", BiasedLockingBulkRevokeThreshold); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ") must be " "less than or equal to BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")\n", @@ -79,8 +108,13 @@ JVMFlag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) { } JVMFlag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) { - JVMFlag::printError(true, "BiasedLockingStartupDelayFunc\n"); if ((value % PeriodicTask::interval_gran) != 0) { + if (VerifyFlagConstraints) + { + int remainder = value % PeriodicTask::interval_gran; + JVMFlag::printError(true, "BiasedLockingStartupDelay:" INTX_FORMAT "\n", (value - remainder)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "BiasedLockingStartupDelay (" INTX_FORMAT ") must be " "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n", @@ -92,14 +126,23 @@ JVMFlag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) { } JVMFlag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) { - JVMFlag::printError(true, "BiasedLockingBulkRevokeThresholdFunc\n"); if (value < BiasedLockingBulkRebiasThreshold) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "BiasedLockingBulkRevokeThreshold:" INTX_FORMAT "\n", BiasedLockingBulkRebiasThreshold); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ") must be " "greater than or equal to BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")\n", value, BiasedLockingBulkRebiasThreshold); return JVMFlag::VIOLATES_CONSTRAINT; } else if ((double)value/(double)BiasedLockingDecayTime > 0.1) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "BiasedLockingBulkRevokeThreshold:" INTX_FORMAT "\n", (BiasedLockingDecayTime * 0.1)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "The ratio of BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")" " to BiasedLockingDecayTime (" INTX_FORMAT ") must be " @@ -112,8 +155,12 @@ JVMFlag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) { } JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) { - JVMFlag::printError(true, "BiasedLockingDecayTimeFunc\n"); if (BiasedLockingBulkRebiasThreshold/(double)value > 0.1) { + if (VerifyFlagConstraints) + { + JVMFlag::printError(true, "BiasedLockingDecayTime:" INTX_FORMAT "\n", (BiasedLockingBulkRebiasThreshold * 10)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "The ratio of BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")" " to BiasedLockingDecayTime (" INTX_FORMAT ") must be " @@ -126,8 +173,13 @@ JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) { } JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) { - JVMFlag::printError(true, "PerfDataSamplingIntervalFunc\n"); if ((value % PeriodicTask::interval_gran != 0)) { + if (VerifyFlagConstraints) + { + int remainder = value % PeriodicTask::interval_gran; + JVMFlag::printError(true, "PerfDataSamplingInterval:" INTX_FORMAT "\n", (value - remainder)); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "PerfDataSamplingInterval (" INTX_FORMAT ") must be " "evenly divisible by PeriodicTask::interval_gran (" INTX_FORMAT ")\n", @@ -139,9 +191,14 @@ JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) { } JVMFlag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose) { - JVMFlag::printError(true, "ThreadLocalHandshakesConstraintFunc\n"); if (value) { if (!SafepointMechanism::supports_thread_local_poll()) { + if (VerifyFlagConstraints) + { + int remainder = value % PeriodicTask::interval_gran; + JVMFlag::printError(true, "ThreadLocalHandshakes:unsupported\n"); + return JVMFlag::SUCCESS; + } JVMFlag::printError(verbose, "ThreadLocalHandshakes not yet supported on this platform\n"); return JVMFlag::VIOLATES_CONSTRAINT; } diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 42ba54439c7..13b92e69177 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -1290,6 +1290,10 @@ define_pd_global(uint64_t,MaxRAM, 1ULL*G); product(bool, PrintFlagsInitial, false, \ "Print all VM flags before argument processing and exit VM") \ \ + diagnostic(bool, VerifyFlagConstraints, false, \ + "Verify flags, calculate suggested legal values for that " \ + "violate the constraints, and then exit VM") \ + \ product(bool, PrintFlagsFinal, false, \ "Print all VM flags after argument and ergonomic processing") \ \ diff --git a/src/hotspot/share/runtime/init.cpp b/src/hotspot/share/runtime/init.cpp index 90b203bf8b6..726a9be3699 100644 --- a/src/hotspot/share/runtime/init.cpp +++ b/src/hotspot/share/runtime/init.cpp @@ -160,6 +160,10 @@ jint init_globals() { JVMFlag::printFlags(tty, false, PrintFlagsRanges); } + if (VerifyFlagConstraints){ + vm_exit(0); + } + return JNI_OK; }