TestUseRTMForStackLocksOptionOnSupportedConfig.java revision 11707:ad7af1afda7a
159816Smdodd/* 259816Smdodd * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 359816Smdodd * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 459816Smdodd * 559816Smdodd * This code is free software; you can redistribute it and/or modify it 659816Smdodd * under the terms of the GNU General Public License version 2 only, as 759816Smdodd * published by the Free Software Foundation. 859816Smdodd * 959816Smdodd * This code is distributed in the hope that it will be useful, but WITHOUT 1059816Smdodd * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1159816Smdodd * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1259816Smdodd * version 2 for more details (a copy is included in the LICENSE file that 1359816Smdodd * accompanied this code). 1459816Smdodd * 1559816Smdodd * You should have received a copy of the GNU General Public License version 1659816Smdodd * 2 along with this work; if not, write to the Free Software Foundation, 1759816Smdodd * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1859816Smdodd * 1959816Smdodd * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2059816Smdodd * or visit www.oracle.com if you need additional information or have any 2159816Smdodd * questions. 2259816Smdodd * 2359816Smdodd */ 2459816Smdodd 2559816Smdodd/** 2659816Smdodd * @test 2759816Smdodd * @bug 8031320 2859816Smdodd * @summary Verify UseRTMForStackLocks option processing on CPU with 2959816Smdodd * rtm support when VM supports rtm locking. 3059816Smdodd * @library /testlibrary /test/lib / 3159816Smdodd * @modules java.base/jdk.internal.misc 3259816Smdodd * java.management 3359816Smdodd * 3459816Smdodd * @build compiler.rtm.cli.TestUseRTMForStackLocksOptionOnSupportedConfig 3559816Smdodd * @run driver ClassFileInstaller sun.hotspot.WhiteBox 3659816Smdodd * sun.hotspot.WhiteBox$WhiteBoxPermission 3759816Smdodd * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 3859816Smdodd * -XX:+WhiteBoxAPI 3959816Smdodd * compiler.rtm.cli.TestUseRTMForStackLocksOptionOnSupportedConfig 4059816Smdodd */ 4159816Smdodd 4259816Smdoddpackage compiler.rtm.cli; 4359816Smdodd 4459816Smdoddimport compiler.testlibrary.rtm.predicate.SupportedCPU; 4559816Smdoddimport compiler.testlibrary.rtm.predicate.SupportedVM; 4659816Smdoddimport jdk.test.lib.ExitCode; 4759816Smdoddimport jdk.test.lib.cli.CommandLineOptionTest; 4859816Smdoddimport jdk.test.lib.cli.predicate.AndPredicate; 4959816Smdodd 5059816Smdoddpublic class TestUseRTMForStackLocksOptionOnSupportedConfig 5159816Smdodd extends CommandLineOptionTest { 5259816Smdodd private static final String DEFAULT_VALUE = "false"; 5359816Smdodd 5459816Smdodd private TestUseRTMForStackLocksOptionOnSupportedConfig() { 5559816Smdodd super(new AndPredicate(new SupportedVM(), new SupportedCPU())); 5659816Smdodd } 5759816Smdodd 5859816Smdodd @Override 5959816Smdodd public void runTestCases() throws Throwable { 6059816Smdodd String errorMessage 6159816Smdodd = CommandLineOptionTest.getExperimentalOptionErrorMessage( 6259816Smdodd "UseRTMForStackLocks"); 6359816Smdodd String warningMessage 6459816Smdodd = RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING; 6559816Smdodd 6659816Smdodd String shouldFailMessage = " VM option 'UseRTMForStackLocks' is " 6759816Smdodd + "experimental%nJVM startup should fail without " 6859816Smdodd + "-XX:+UnlockExperimentalVMOptions flag"; 6959816Smdodd 7059816Smdodd CommandLineOptionTest.verifySameJVMStartup( 7159816Smdodd new String[] { errorMessage }, null, shouldFailMessage, 7259816Smdodd shouldFailMessage + "%nError message expected", ExitCode.FAIL, 7359816Smdodd "-XX:+UseRTMForStackLocks"); 7459816Smdodd String shouldPassMessage = " VM option 'UseRTMForStackLocks'" 7559816Smdodd + " is experimental%nJVM startup should pass with " 7659816Smdodd + "-XX:+UnlockExperimentalVMOptions flag"; 7759816Smdodd // verify that we get a warning when trying to use rtm for stack 7859816Smdodd // lock, but not using rtm locking. 7959816Smdodd CommandLineOptionTest.verifySameJVMStartup( 8059816Smdodd new String[] { warningMessage }, null, shouldPassMessage, 8159816Smdodd "There should be warning when trying to use rtm for stack " 8259816Smdodd + "lock, but not using rtm locking", ExitCode.OK, 8359816Smdodd CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, 8459816Smdodd "-XX:+UseRTMForStackLocks", 8559816Smdodd "-XX:-UseRTMLocking"); 8659816Smdodd // verify that we don't get a warning when no using rtm for stack 8759816Smdodd // lock and not using rtm locking. 8859816Smdodd CommandLineOptionTest.verifySameJVMStartup(null, 8959816Smdodd new String[] { warningMessage }, shouldPassMessage, 9059816Smdodd "There should not be any warning when use both " 9159816Smdodd + "-XX:-UseRTMForStackLocks and -XX:-UseRTMLocking " 9259816Smdodd + "flags", 9359816Smdodd ExitCode.OK, 9459816Smdodd CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, 9559816Smdodd "-XX:-UseRTMForStackLocks", 9659816Smdodd "-XX:-UseRTMLocking"); 9759816Smdodd // verify that we don't get a warning when using rtm for stack 9859816Smdodd // lock and using rtm locking. 9959816Smdodd CommandLineOptionTest.verifySameJVMStartup(null, 10059816Smdodd new String[] { warningMessage }, shouldPassMessage, 10159816Smdodd "There should not be any warning when use both " 10259816Smdodd + "-XX:+UseRTMForStackLocks and -XX:+UseRTMLocking" 10359816Smdodd + " flags", 10459816Smdodd ExitCode.OK, 10559816Smdodd CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, 10659816Smdodd "-XX:+UseRTMForStackLocks", 10759816Smdodd "-XX:+UseRTMLocking"); 10859816Smdodd // verify that default value if false 10959816Smdodd CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks", 11059816Smdodd TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE, 11159816Smdodd "Default value of option 'UseRTMForStackLocks' should be false", 11259816Smdodd CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS); 11359816Smdodd // verify that default value is false even with +UseRTMLocking 11459816Smdodd CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks", 11559816Smdodd TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE, 11659816Smdodd "Default value of option 'UseRTMForStackLocks' should be false", 11759816Smdodd CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, 11859816Smdodd "-XX:+UseRTMLocking"); 11959816Smdodd // verify that we can turn the option on 12059816Smdodd CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks", 12159816Smdodd "true", "Value of option 'UseRTMForStackLocks' should " 12259816Smdodd + "be able to be set as 'true' when both " 12359816Smdodd + "-XX:+UseRTMForStackLocks and " 12459816Smdodd + "-XX:+UseRTMLocking flags used", 12559816Smdodd CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, 12659816Smdodd "-XX:+UseRTMLocking", "-XX:+UseRTMForStackLocks"); 12759816Smdodd } 12859816Smdodd 12959816Smdodd public static void main(String args[]) throws Throwable { 13059816Smdodd new TestUseRTMForStackLocksOptionOnSupportedConfig().test(); 13159816Smdodd } 13259816Smdodd} 13359816Smdodd