Path: blob/master/test/hotspot/jtreg/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java
41152 views
/*1* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 803132026* @summary Verify UseRTMForStackLocks option processing on CPU and OS with27* rtm support when VM supports rtm locking.28* @library /test/lib /29* @modules java.base/jdk.internal.misc30* java.management31* @requires vm.flagless32* @requires vm.rtm.cpu & vm.rtm.compiler33* @run driver compiler.rtm.cli.TestUseRTMForStackLocksOptionOnSupportedConfig34*/3536package compiler.rtm.cli;3738import jdk.test.lib.process.ExitCode;39import jdk.test.lib.cli.CommandLineOptionTest;4041public class TestUseRTMForStackLocksOptionOnSupportedConfig {42private static final String DEFAULT_VALUE = "false";4344public void runTestCases() throws Throwable {45String errorMessage46= CommandLineOptionTest.getExperimentalOptionErrorMessage(47"UseRTMForStackLocks");48String warningMessage49= RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING;5051String shouldFailMessage = " VM option 'UseRTMForStackLocks' is "52+ "experimental%nJVM startup should fail without "53+ "-XX:+UnlockExperimentalVMOptions flag";5455CommandLineOptionTest.verifySameJVMStartup(56new String[] { errorMessage }, null, shouldFailMessage,57shouldFailMessage + "%nError message expected", ExitCode.FAIL,58"-XX:+UseRTMForStackLocks");59String shouldPassMessage = " VM option 'UseRTMForStackLocks'"60+ " is experimental%nJVM startup should pass with "61+ "-XX:+UnlockExperimentalVMOptions flag";62// verify that we get a warning when trying to use rtm for stack63// lock, but not using rtm locking.64CommandLineOptionTest.verifySameJVMStartup(65new String[] { warningMessage }, null, shouldPassMessage,66"There should be warning when trying to use rtm for stack "67+ "lock, but not using rtm locking", ExitCode.OK,68CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,69"-XX:+UseRTMForStackLocks",70"-XX:-UseRTMLocking");71// verify that we don't get a warning when no using rtm for stack72// lock and not using rtm locking.73CommandLineOptionTest.verifySameJVMStartup(null,74new String[] { warningMessage }, shouldPassMessage,75"There should not be any warning when use both "76+ "-XX:-UseRTMForStackLocks and -XX:-UseRTMLocking "77+ "flags",78ExitCode.OK,79CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,80"-XX:-UseRTMForStackLocks",81"-XX:-UseRTMLocking");82// verify that we don't get a warning when using rtm for stack83// lock and using rtm locking.84CommandLineOptionTest.verifySameJVMStartup(null,85new String[] { warningMessage }, shouldPassMessage,86"There should not be any warning when use both "87+ "-XX:+UseRTMForStackLocks and -XX:+UseRTMLocking"88+ " flags",89ExitCode.OK,90CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,91"-XX:+UseRTMForStackLocks",92"-XX:+UseRTMLocking");93// verify that default value if false94CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",95TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE,96"Default value of option 'UseRTMForStackLocks' should be false",97CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);98// verify that default value is false even with +UseRTMLocking99CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",100TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE,101"Default value of option 'UseRTMForStackLocks' should be false",102CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,103"-XX:+UseRTMLocking");104// verify that we can turn the option on105CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",106"true", "Value of option 'UseRTMForStackLocks' should "107+ "be able to be set as 'true' when both "108+ "-XX:+UseRTMForStackLocks and "109+ "-XX:+UseRTMLocking flags used",110CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,111"-XX:+UseRTMLocking", "-XX:+UseRTMForStackLocks");112}113114public static void main(String args[]) throws Throwable {115new TestUseRTMForStackLocksOptionOnSupportedConfig().runTestCases();116}117}118119120