Mercurial > hg > truffle
comparison test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java @ 17873:ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
Reviewed-by: kvn, iignatyev
Contributed-by: filipp.zhinkin@oracle.com
author | iignatyev |
---|---|
date | Fri, 11 Apr 2014 00:35:23 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17872:100f2b109432 | 17873:ba8268c23fa2 |
---|---|
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 UseRTMXendForLockBusy option affects | |
29 * method behaviour if lock is busy. | |
30 * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary | |
31 * @build TestUseRTMXendForLockBusy | |
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox | |
33 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions | |
34 * -XX:+WhiteBoxAPI TestUseRTMXendForLockBusy | |
35 */ | |
36 | |
37 import java.util.List; | |
38 | |
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; | |
45 | |
46 /** | |
47 * Test verifies that with +UseRTMXendForLockBusy there will be no aborts | |
48 * forced by the test. | |
49 */ | |
50 public class TestUseRTMXendForLockBusy extends CommandLineOptionTest { | |
51 private final static int LOCKING_TIME = 5000; | |
52 | |
53 private TestUseRTMXendForLockBusy() { | |
54 super(new AndPredicate(new SupportedVM(), new SupportedCPU())); | |
55 } | |
56 | |
57 @Override | |
58 protected void runTestCases() throws Throwable { | |
59 // inflated lock, xabort on lock busy | |
60 verifyXendForLockBusy(true, false); | |
61 // inflated lock, xend on lock busy | |
62 verifyXendForLockBusy(true, true); | |
63 // stack lock, xabort on lock busy | |
64 verifyXendForLockBusy(false, false); | |
65 // stack lock, xend on lock busy | |
66 verifyXendForLockBusy(false, true); | |
67 } | |
68 | |
69 private void verifyXendForLockBusy(boolean inflateMonitor, | |
70 boolean useXend) throws Throwable { | |
71 CompilableTest test = new BusyLock(); | |
72 | |
73 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest( | |
74 test, | |
75 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks", | |
76 inflateMonitor), | |
77 CommandLineOptionTest.prepareBooleanFlag( | |
78 "UseRTMXendForLockBusy", | |
79 useXend), | |
80 "-XX:RTMRetryCount=0", | |
81 "-XX:RTMTotalCountIncrRate=1", | |
82 "-XX:+PrintPreciseRTMLockingStatistics", | |
83 BusyLock.class.getName(), | |
84 Boolean.toString(inflateMonitor), | |
85 Integer.toString(TestUseRTMXendForLockBusy.LOCKING_TIME) | |
86 ); | |
87 | |
88 outputAnalyzer.shouldHaveExitValue(0); | |
89 | |
90 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString( | |
91 test.getMethodWithLockName(), outputAnalyzer.getOutput()); | |
92 | |
93 Asserts.assertEQ(statistics.size(), 1, "VM output should contain " | |
94 + "exactly one rtm locking statistics entry for method " | |
95 + test.getMethodWithLockName()); | |
96 | |
97 long aborts = statistics.get(0).getAborts(AbortType.XABORT); | |
98 | |
99 if (useXend) { | |
100 Asserts.assertEQ(aborts, 0L, | |
101 "Expected to get no aborts on busy lock"); | |
102 } else { | |
103 Asserts.assertGT(aborts, 0L, | |
104 "Expected to get at least one abort on busy lock"); | |
105 } | |
106 } | |
107 | |
108 public static void main(String args[]) throws Throwable { | |
109 new TestUseRTMXendForLockBusy().test(); | |
110 } | |
111 } |