# HG changeset patch # User goetz # Date 1500387088 -7200 # Node ID 408093091935f26871ca7ad7c1837d88f8332360 # Parent 5e9c41536bd2f4eb9f991cfa37bff82a0240cea7 8184800: Streamline RTM flag validity testing with generic flag testing support diff --git a/src/cpu/ppc/vm/globals_ppc.hpp b/src/cpu/ppc/vm/globals_ppc.hpp --- a/src/cpu/ppc/vm/globals_ppc.hpp +++ b/src/cpu/ppc/vm/globals_ppc.hpp @@ -193,11 +193,12 @@ \ experimental(int, RTMAbortRatio, 50, \ "Lock abort ratio at which to stop use RTM lock eliding") \ - range(0, 100) /* natural range, checked in vm_version_ppc.cpp */ \ + range(0, 100) /* natural range */ \ \ experimental(int, RTMTotalCountIncrRate, 64, \ "Increment total RTM attempted lock count once every n times") \ range(1, 32767) /* immediate operand limit on ppc */ \ + constraint(RTMTotalCountIncrRateConstraintFunc,AfterErgo) \ \ experimental(intx, RTMLockingCalculationDelay, 0, \ "Number of milliseconds to wait before start calculating aborts " \ diff --git a/src/cpu/ppc/vm/vm_version_ppc.cpp b/src/cpu/ppc/vm/vm_version_ppc.cpp --- a/src/cpu/ppc/vm/vm_version_ppc.cpp +++ b/src/cpu/ppc/vm/vm_version_ppc.cpp @@ -327,18 +327,6 @@ // high lock contention. For now we do not use it by default. vm_exit_during_initialization("UseRTMLocking flag should be only set on command line"); } - if (!is_power_of_2(RTMTotalCountIncrRate)) { - warning("RTMTotalCountIncrRate must be a power of 2, resetting it to 64"); - FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64); - } - if (RTMAbortRatio < 0 || RTMAbortRatio > 100) { - warning("RTMAbortRatio must be in the range 0 to 100, resetting it to 50"); - FLAG_SET_DEFAULT(RTMAbortRatio, 50); - } - if (RTMSpinLoopCount < 0) { - warning("RTMSpinLoopCount must not be a negative value, resetting it to 0"); - FLAG_SET_DEFAULT(RTMSpinLoopCount, 0); - } #else // Only C2 does RTM locking optimization. // Can't continue because UseRTMLocking affects UseBiasedLocking flag diff --git a/src/cpu/x86/vm/globals_x86.hpp b/src/cpu/x86/vm/globals_x86.hpp --- a/src/cpu/x86/vm/globals_x86.hpp +++ b/src/cpu/x86/vm/globals_x86.hpp @@ -179,11 +179,12 @@ \ experimental(int, RTMAbortRatio, 50, \ "Lock abort ratio at which to stop use RTM lock eliding") \ - range(0, 100) /* natural range, checked in vm_version_x86.cpp */ \ + range(0, 100) /* natural range */ \ \ experimental(int, RTMTotalCountIncrRate, 64, \ "Increment total RTM attempted lock count once every n times") \ range(1, max_jint) \ + constraint(RTMTotalCountIncrRateConstraintFunc,AfterErgo) \ \ experimental(intx, RTMLockingCalculationDelay, 0, \ "Number of milliseconds to wait before start calculating aborts " \ diff --git a/src/cpu/x86/vm/vm_version_x86.cpp b/src/cpu/x86/vm/vm_version_x86.cpp --- a/src/cpu/x86/vm/vm_version_x86.cpp +++ b/src/cpu/x86/vm/vm_version_x86.cpp @@ -884,7 +884,8 @@ (_model == CPU_MODEL_BROADWELL && _stepping < 4)) { // currently a collision between SKL and HSW_E3 if (!UnlockExperimentalVMOptions && UseAVX < 3) { - vm_exit_during_initialization("UseRTMLocking is only available as experimental option on this platform. It must be enabled via -XX:+UnlockExperimentalVMOptions flag."); + vm_exit_during_initialization("UseRTMLocking is only available as experimental option on this " + "platform. It must be enabled via -XX:+UnlockExperimentalVMOptions flag."); } else { warning("UseRTMLocking is only available as experimental option on this platform."); } @@ -895,14 +896,6 @@ // high lock contention. For now we do not use it by default. vm_exit_during_initialization("UseRTMLocking flag should be only set on command line"); } - if (!is_power_of_2(RTMTotalCountIncrRate)) { - warning("RTMTotalCountIncrRate must be a power of 2, resetting it to 64"); - FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64); - } - if (RTMAbortRatio < 0 || RTMAbortRatio > 100) { - warning("RTMAbortRatio must be in the range 0 to 100, resetting it to 50"); - FLAG_SET_DEFAULT(RTMAbortRatio, 50); - } } else { // !UseRTMLocking if (UseRTMForStackLocks) { if (!FLAG_IS_DEFAULT(UseRTMForStackLocks)) { diff --git a/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp b/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp --- a/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp +++ b/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp @@ -389,3 +389,17 @@ return Flag::SUCCESS; } #endif // COMPILER2 + +Flag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) { +#if INCLUDE_RTM_OPT + if (UseRTMLocking && !is_power_of_2(RTMTotalCountIncrRate)) { + CommandLineError::print(verbose, + "RTMTotalCountIncrRate (" INTX_FORMAT + ") must be a power of 2, resetting it to 64\n", + RTMTotalCountIncrRate); + FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64); + } +#endif + + return Flag::SUCCESS; +} diff --git a/src/share/vm/runtime/commandLineFlagConstraintsCompiler.hpp b/src/share/vm/runtime/commandLineFlagConstraintsCompiler.hpp --- a/src/share/vm/runtime/commandLineFlagConstraintsCompiler.hpp +++ b/src/share/vm/runtime/commandLineFlagConstraintsCompiler.hpp @@ -70,4 +70,6 @@ Flag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose); #endif +Flag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose); + #endif /* SHARE_VM_RUNTIME_COMMANDLINEFLAGCONSTRAINTSCOMPILER_HPP */ diff --git a/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java b/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java --- a/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java +++ b/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java @@ -38,13 +38,11 @@ = "RTM instructions are not available on this CPU"; protected static final String RTM_UNSUPPORTED_VM_ERROR = "RTM locking optimization is not supported in this VM"; - protected static final String RTM_ABORT_RATIO_WARNING - = "RTMAbortRatio must be in the range 0 to 100, resetting it to 50"; protected static final String RTM_FOR_STACK_LOCKS_WARNING = "UseRTMForStackLocks flag should be off when UseRTMLocking " + "flag is off"; protected static final String RTM_COUNT_INCR_WARNING - = "RTMTotalCountIncrRate must be a power of 2, resetting it to 64"; + = "must be a power of 2, resetting it to 64"; protected static final String RTM_BIASED_LOCKING_WARNING = "Biased locking is not supported with RTM locking; " + "ignoring UseBiasedLocking flag"; diff --git a/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java b/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java deleted file mode 100644 --- a/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8031320 - * @summary Verify RTMAbortRatio option processing on CPU with rtm - * support and on VM with rtm locking support. - * @library /test/lib / - * @modules java.base/jdk.internal.misc - * java.management - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.rtm.cpu & vm.rtm.os - * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.cli.TestRTMAbortRatioOptionOnSupportedConfig - */ - -package compiler.rtm.cli; - -public class TestRTMAbortRatioOptionOnSupportedConfig - extends RTMLockingAwareTest { - private static final String DEFAULT_VALUE = "50"; - - private TestRTMAbortRatioOptionOnSupportedConfig() { - super("RTMAbortRatio", false, true, - TestRTMAbortRatioOptionOnSupportedConfig.DEFAULT_VALUE, - /* correct values */ - new String[] { "0", "20", "100" }, - /* incorrect values */ - new String[] { "-1", "101" }, - RTMGenericCommandLineOptionTest.RTM_ABORT_RATIO_WARNING); - } - - public static void main(String args[]) throws Throwable { - new TestRTMAbortRatioOptionOnSupportedConfig().runTestCases(); - } -} diff --git a/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java b/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java deleted file mode 100644 --- a/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8031320 - * @summary Verify RTMAbortRatio option processing on CPU without rtm - * support or on VM that does not support rtm locking. - * @library /test/lib / - * @modules java.base/jdk.internal.misc - * java.management - * @requires !(vm.flavor == "server" & !vm.emulatedClient & vm.rtm.cpu & vm.rtm.os) - * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.cli.TestRTMAbortRatioOptionOnUnsupportedConfig - */ - -package compiler.rtm.cli; - -public class TestRTMAbortRatioOptionOnUnsupportedConfig - extends RTMGenericCommandLineOptionTest { - private static final String DEFAULT_VALUE = "50"; - - private TestRTMAbortRatioOptionOnUnsupportedConfig() { - super("RTMAbortRatio", false, true, - TestRTMAbortRatioOptionOnUnsupportedConfig.DEFAULT_VALUE, - "0", "10", "100"); - } - - public static void main(String args[]) throws Throwable { - new TestRTMAbortRatioOptionOnUnsupportedConfig().runTestCases(); - } -} diff --git a/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java b/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java --- a/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java +++ b/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java @@ -50,7 +50,7 @@ /* correct values */ new String[] { "1", "2", "128", "1024" }, /* incorrect values */ - new String[] { "-1", "0", "3", "42" }, + new String[] { "3", "5", "7", "42" }, RTMGenericCommandLineOptionTest.RTM_COUNT_INCR_WARNING); } diff --git a/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java b/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java deleted file mode 100644 --- a/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8031320 - * @summary Verify RTMTotalCountIncrRate option processing on CPU without - * rtm support and/or on VM without rtm locking support. - * @library /test/lib / - * @modules java.base/jdk.internal.misc - * java.management - * @requires !(vm.flavor == "server" & !vm.emulatedClient & vm.rtm.cpu & vm.rtm.os) - * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * compiler.rtm.cli.TestRTMTotalCountIncrRateOptionOnUnsupportedConfig - */ - -package compiler.rtm.cli; - -public class TestRTMTotalCountIncrRateOptionOnUnsupportedConfig - extends RTMGenericCommandLineOptionTest { - private static final String DEFAULT_VALUE = "64"; - - private TestRTMTotalCountIncrRateOptionOnUnsupportedConfig() { - super("RTMTotalCountIncrRate", false, true, - TestRTMTotalCountIncrRateOptionOnUnsupportedConfig - .DEFAULT_VALUE, - "1", "42", "128"); - } - - public static void main(String args[]) throws Throwable { - new TestRTMTotalCountIncrRateOptionOnUnsupportedConfig().runTestCases(); - } -}