comparison test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java @ 18058:54bc75c144b0

Merge
author asaha
date Thu, 29 May 2014 13:14:25 -0700
parents ba8268c23fa2
children
comparison
equal deleted inserted replaced
18055:1fa005fb28f5 18058:54bc75c144b0
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 */
24
25 /**
26 * @test
27 * @bug 8031320
28 * @summary Verify that on high abort ratio method will be recompiled
29 * without rtm locking.
30 * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
31 * @build TestRTMDeoptOnHighAbortRatio
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox
33 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
34 * -XX:+WhiteBoxAPI TestRTMDeoptOnHighAbortRatio
35 */
36
37 import java.util.List;
38 import com.oracle.java.testlibrary.*;
39 import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
40 import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
41 import rtm.*;
42 import rtm.predicate.SupportedCPU;
43 import rtm.predicate.SupportedVM;
44
45 /**
46 * Test verifies that on high abort ratio method wil be deoptimized with
47 * <i>rtm_state_change</i> reason and after that RTM-based lock elision will not
48 * be used for that method.
49 * This test make asserts on total locks count done by compiled method,
50 * so in order to avoid issue with retriable locks -XX:RTMRetryCount=0 is used.
51 * For more details on that issue see {@link TestUseRTMAfterLockInflation}.
52 */
53 public class TestRTMDeoptOnHighAbortRatio extends CommandLineOptionTest {
54 private static final long ABORT_THRESHOLD
55 = AbortProvoker.DEFAULT_ITERATIONS / 2L;
56
57 private TestRTMDeoptOnHighAbortRatio() {
58 super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
59 }
60
61 @Override
62 protected void runTestCases() throws Throwable {
63 verifyDeopt(false);
64 verifyDeopt(true);
65 }
66
67 private void verifyDeopt(boolean useStackLock) throws Throwable {
68 AbortProvoker provoker = AbortType.XABORT.provoker();
69 String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
70 (useStackLock ? "use" : "no"));
71
72 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
73 logFileName,
74 provoker,
75 "-XX:+UseRTMDeopt",
76 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
77 useStackLock),
78 "-XX:RTMRetryCount=0",
79 CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
80 TestRTMDeoptOnHighAbortRatio.ABORT_THRESHOLD),
81 "-XX:RTMAbortRatio=100",
82 "-XX:CompileThreshold=1",
83 "-XX:RTMTotalCountIncrRate=1",
84 "-XX:+PrintPreciseRTMLockingStatistics",
85 AbortProvoker.class.getName(),
86 AbortType.XABORT.toString(),
87 Boolean.toString(!useStackLock)
88 );
89
90 outputAnalyzer.shouldHaveExitValue(0);
91
92 int firedTraps = RTMTestBase.firedRTMStateChangeTraps(logFileName);
93
94 Asserts.assertEQ(firedTraps, 1, "Expected to get only one "
95 + "deoptimization due to rtm state change");
96
97 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
98 provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
99
100 Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
101 + "exactly one RTM locking statistics entry for method "
102 + provoker.getMethodWithLockName());
103
104 Asserts.assertEQ(statistics.get(0).getTotalLocks(),
105 TestRTMDeoptOnHighAbortRatio.ABORT_THRESHOLD,
106 "After AbortThreshold was reached, method should be"
107 + " recompiled without rtm lock eliding.");
108 }
109
110 public static void main(String args[]) throws Throwable {
111 new TestRTMDeoptOnHighAbortRatio().test();
112 }
113 }
114