--- old/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp 2018-11-21 06:38:43.092097672 -0800 +++ new/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp 2018-11-21 06:38:42.640055601 -0800 @@ -145,47 +145,39 @@ } JVMFlag::Error OnStackReplacePercentageConstraintFunc(intx value, bool verbose) { - int backward_branch_limit; + int64_t max_percentage_limit = ((int64_t)INT_MAX>>InvocationCounter::count_shift)*100; + max_percentage_limit = CompileThreshold == 0 ? max_percentage_limit : max_percentage_limit/CompileThreshold; + if (ProfileInterpreter) { - if (OnStackReplacePercentage < InterpreterProfilePercentage) { + if (value < InterpreterProfilePercentage) { JVMFlag::printError(verbose, "OnStackReplacePercentage (" INTX_FORMAT ") must be " "larger than InterpreterProfilePercentage (" INTX_FORMAT ")\n", - OnStackReplacePercentage, InterpreterProfilePercentage); + value, InterpreterProfilePercentage); return JVMFlag::VIOLATES_CONSTRAINT; } - backward_branch_limit = ((CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100) - << InvocationCounter::count_shift; - - if (backward_branch_limit < 0) { + max_percentage_limit += InterpreterProfilePercentage; + if (value > max_percentage_limit) { JVMFlag::printError(verbose, - "CompileThreshold * (InterpreterProfilePercentage - OnStackReplacePercentage) / 100 = " - INTX_FORMAT " " - "must be between 0 and %d, try changing " - "CompileThreshold, InterpreterProfilePercentage, and/or OnStackReplacePercentage\n", - (CompileThreshold * (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100, - INT_MAX >> InvocationCounter::count_shift); + "OnStackReplacePercentage (" INTX_FORMAT ") must be between 0 and " INT64_FORMAT "\n", + value, + max_percentage_limit); return JVMFlag::VIOLATES_CONSTRAINT; } } else { - if (OnStackReplacePercentage < 0 ) { + if (value < 0) { JVMFlag::printError(verbose, "OnStackReplacePercentage (" INTX_FORMAT ") must be " - "non-negative\n", OnStackReplacePercentage); + "non-negative\n", value); return JVMFlag::VIOLATES_CONSTRAINT; } - backward_branch_limit = ((CompileThreshold * OnStackReplacePercentage) / 100) - << InvocationCounter::count_shift; - - if (backward_branch_limit < 0) { + if (value > max_percentage_limit) { JVMFlag::printError(verbose, - "CompileThreshold * OnStackReplacePercentage / 100 = " INTX_FORMAT " " - "must be between 0 and %d, try changing " - "CompileThreshold and/or OnStackReplacePercentage\n", - (CompileThreshold * OnStackReplacePercentage) / 100, - INT_MAX >> InvocationCounter::count_shift); + "OnStackReplacePercentage (" INTX_FORMAT ") must be between 0 and " INT64_FORMAT "\n", + value, + max_percentage_limit); return JVMFlag::VIOLATES_CONSTRAINT; } } --- old/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/IntxTest.java 2018-11-21 06:38:43.983180605 -0800 +++ new/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/IntxTest.java 2018-11-21 06:38:43.523137789 -0800 @@ -38,13 +38,21 @@ public class IntxTest { private static final String FLAG_NAME = "OnStackReplacePercentage"; private static final String FLAG_DEBUG_NAME = "InlineFrequencyCount"; - private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE}; + private static final long COMPILE_THRESHOLD = VmFlagTest.WHITE_BOX.getIntxVMFlag("CompileThreshold"); + private static final Long[] TESTS = {0L, 100L, (long)(Integer.MAX_VALUE>>3)*100L}; public static void main(String[] args) throws Exception { + find_and_set_max_osrp(); VmFlagTest.runTest(FLAG_NAME, TESTS, VmFlagTest.WHITE_BOX::setIntxVMFlag, VmFlagTest.WHITE_BOX::getIntxVMFlag); VmFlagTest.runTest(FLAG_DEBUG_NAME, VmFlagTest.WHITE_BOX::getIntxVMFlag); } + + static void find_and_set_max_osrp() { + long max_percentage_limit = (long)(Integer.MAX_VALUE>>3)*100L; + max_percentage_limit = COMPILE_THRESHOLD == 0 ? max_percentage_limit : max_percentage_limit/COMPILE_THRESHOLD; + TESTS[2] = max_percentage_limit; + } }