Path: blob/master/test/hotspot/jtreg/compiler/rtm/locking/TestRTMLockingCalculationDelay.java
41154 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 that RTMLockingCalculationDelay affect when27* abort ratio calculation is started.28* @library /test/lib /29* @modules java.base/jdk.internal.misc30* java.management31* @requires vm.rtm.cpu & vm.rtm.compiler32* @build sun.hotspot.WhiteBox33* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox34* @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions35* -XX:+WhiteBoxAPI36* compiler.rtm.locking.TestRTMLockingCalculationDelay37*/3839package compiler.rtm.locking;4041import compiler.testlibrary.rtm.AbortProvoker;42import compiler.testlibrary.rtm.AbortType;43import compiler.testlibrary.rtm.RTMTestBase;44import jdk.test.lib.Asserts;45import jdk.test.lib.process.OutputAnalyzer;46import jdk.test.lib.cli.CommandLineOptionTest;4748/**49* Test verifies that abort ratio calculation could be delayed using50* RTMLockingCalculationDelay option.51*/52public class TestRTMLockingCalculationDelay {53private static final boolean INFLATE_MONITOR = true;5455protected void runTestCases() throws Throwable {56// verify that calculation will be started immediately57verifyLockingCalculationDelay(0, 0, true);5859// verify that calculation will not be started during60// first 10 minutes, while test will be started immediately61verifyLockingCalculationDelay(600000, 0, false);6263// verify that calculation will be started after a second64verifyLockingCalculationDelay(1000, 1000, true);65}6667private void verifyLockingCalculationDelay(long delay, long testDelay,68boolean deoptExpected) throws Throwable {69AbortProvoker provoker = AbortType.XABORT.provoker();70String logFileName = String.format("rtm_delay_%d_%d.xml", delay,71testDelay);7273OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(74logFileName,75provoker,76"-XX:+UseRTMDeopt",77CommandLineOptionTest.prepareNumericFlag(78"RTMLockingCalculationDelay", delay),79"-XX:RTMAbortRatio=0",80"-XX:RTMAbortThreshold=0",81AbortProvoker.class.getName(),82AbortType.XABORT.toString(),83Boolean.toString(84TestRTMLockingCalculationDelay.INFLATE_MONITOR),85Long.toString(AbortProvoker.DEFAULT_ITERATIONS),86Long.toString(testDelay)87);8889outputAnalyzer.shouldHaveExitValue(0);9091int deopts = RTMTestBase.firedRTMStateChangeTraps(logFileName);9293if (deoptExpected) {94Asserts.assertGT(deopts, 0, "At least one deoptimization due to "95+ "rtm_state_chage is expected");96} else {97Asserts.assertEQ(deopts, 0, "No deoptimizations due to "98+ "rtm_state_chage are expected");99}100}101102public static void main(String args[]) throws Throwable {103new TestRTMLockingCalculationDelay().runTestCases();104}105}106107108