8184800: Streamline RTM flag validity testing with generic flag testing support
Reviewed-by: kvn, lucy
--- a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp Thu Jul 20 11:01:20 2017 -0400
+++ b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp Tue Jul 18 16:11:28 2017 +0200
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017 SAP SE. 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
@@ -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 " \
--- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp Thu Jul 20 11:01:20 2017 -0400
+++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp Tue Jul 18 16:11:28 2017 +0200
@@ -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
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp Thu Jul 20 11:01:20 2017 -0400
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp Tue Jul 18 16:11:28 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -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 " \
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp Thu Jul 20 11:01:20 2017 -0400
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp Tue Jul 18 16:11:28 2017 +0200
@@ -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)) {
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp Thu Jul 20 11:01:20 2017 -0400
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp Tue Jul 18 16:11:28 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -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;
+}
--- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.hpp Thu Jul 20 11:01:20 2017 -0400
+++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.hpp Tue Jul 18 16:11:28 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -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 */
--- a/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java Thu Jul 20 11:01:20 2017 -0400
+++ b/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java Tue Jul 18 16:11:28 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, 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
@@ -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";
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java Thu Jul 20 11:01:20 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
- }
-}
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java Thu Jul 20 11:01:20 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
- }
-}
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java Thu Jul 20 11:01:20 2017 -0400
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java Tue Jul 18 16:11:28 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, 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
@@ -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);
}
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java Thu Jul 20 11:01:20 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
- }
-}