test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java

Wed, 21 Jan 2015 12:38:11 +0100

author
goetz
date
Wed, 21 Jan 2015 12:38:11 +0100
changeset 7574
a51071796915
parent 0
f90c822e73f8
permissions
-rw-r--r--

8068013: [TESTBUG] Aix support in hotspot jtreg tests
Reviewed-by: ctornqvi, fzhinkin, farvidsson

     1 /*
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 /**
    26  * @test
    27  * @bug 8031320
    28  * @summary Verify that UseRTMLockEliding option could be applied to
    29  *          specified method and that such method will not be deoptimized
    30  *          on high abort ratio.
    31  * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
    32  * @build TestUseRTMLockElidingOption
    33  * @run main ClassFileInstaller sun.hotspot.WhiteBox
    34  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
    35  *                   -XX:+WhiteBoxAPI TestUseRTMLockElidingOption
    36  */
    38 import java.util.List;
    39 import com.oracle.java.testlibrary.*;
    40 import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
    41 import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
    42 import rtm.*;
    43 import rtm.predicate.SupportedCPU;
    44 import rtm.predicate.SupportedVM;
    46 /**
    47  * Test verifies that method tagged with option <i>UseRTMLockElidingOption</i>
    48  * will use RTM-based lock elision, but will be never deoptimized with
    49  * <i>rtm_state_change reason</i>.
    50  * Test invokes compiled method and checks that no deoptimization with
    51  * <i>rtm_state_change</i> reason had happened and that that VM output
    52  * contains RTM locking statistics for compiled method and that total locks
    53  * count equals to method's invocations.
    54  * Since last assert is pretty strict, test uses -XX:RTMRetryCount=0 in order
    55  * to avoid issue with retriable aborts described in
    56  * {@link TestUseRTMAfterLockInflation}.
    57  */
    58 public class TestUseRTMLockElidingOption extends CommandLineOptionTest {
    59     private TestUseRTMLockElidingOption() {
    60         super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
    61     }
    63     @Override
    64     public void runTestCases() throws Throwable {
    65         verifyOption(false);
    66         verifyOption(true);
    67     }
    69     public void verifyOption(boolean useStackLock) throws Throwable {
    70         AbortProvoker provoker = AbortType.XABORT.provoker();
    71         String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
    72                 (useStackLock ? "use" : "no"));
    73         String methodOption = String.format("-XX:CompileCommand=option," +
    74                 "%s,UseRTMLockEliding", provoker.getMethodWithLockName());
    76         OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
    77                 logFileName,
    78                 provoker,
    79                 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
    80                         useStackLock),
    81                 methodOption,
    82                 "-XX:RTMTotalCountIncrRate=1",
    83                 "-XX:RTMRetryCount=0",
    84                 "-XX:+UseRTMDeopt",
    85                 "-XX:+PrintPreciseRTMLockingStatistics",
    86                 provoker.getClass().getName(),
    87                 AbortType.XABORT.toString(),
    88                 Boolean.toString(!useStackLock)
    89         );
    91         outputAnalyzer.shouldHaveExitValue(0);
    93         int firedTraps = RTMTestBase.firedRTMStateChangeTraps(logFileName);
    95         Asserts.assertEQ(firedTraps, 0,
    96                 "Method deoptimization with rtm_state_change is unexpected");
    98         List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
    99                 provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
   101         Asserts.assertEQ(statistics.size(), 1,
   102                 "VM output should contain exactly one RTM locking "
   103                 + "statistics entry for method "
   104                 + provoker.getMethodWithLockName());
   106         RTMLockingStatistics lock = statistics.get(0);
   108         Asserts.assertEQ(lock.getTotalLocks(), AbortProvoker.DEFAULT_ITERATIONS,
   109                 "Expected to get total locks count equal to total amount of "
   110                 + "lock attempts.");
   111     }
   113     public static void main(String args[]) throws Throwable {
   114         new TestUseRTMLockElidingOption().test();
   115     }
   116 }

mercurial