author | ykantser |
Mon, 04 May 2015 16:30:07 +0200 | |
changeset 30604 | b8d532cb6420 |
parent 29678 | dd2f3932c21e |
child 33730 | 30e064828045 |
permissions | -rw-r--r-- |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28498
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
4 |
* |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
8 |
* |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
14 |
* |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
18 |
* |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
22 |
* |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
23 |
*/ |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
24 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
25 |
/** |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
26 |
* @test |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
27 |
* @bug 8031320 |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
28 |
* @summary Verify that rtm locking statistics contain proper information |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
29 |
* on overall aborts and locks count and count of aborts of |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
30 |
* different types. Test also verify that VM output does not |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
31 |
* contain rtm locking statistics when it should not. |
28190
5a6b07edeb21
8066433: Move Whitebox test library to top level repository
thartmann
parents:
25958
diff
changeset
|
32 |
* @library /testlibrary /../../test/lib /compiler/testlibrary |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28498
diff
changeset
|
33 |
* @modules java.base/sun.misc |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28498
diff
changeset
|
34 |
* java.management |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
35 |
* @build TestPrintPreciseRTMLockingStatistics |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
36 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
25958
8dc85547d6d6
8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot
mgerdin
parents:
24006
diff
changeset
|
37 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
38 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
39 |
* -XX:+WhiteBoxAPI TestPrintPreciseRTMLockingStatistics |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
40 |
*/ |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
41 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
42 |
import java.util.*; |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
43 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
44 |
import jdk.test.lib.*; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
45 |
import jdk.test.lib.cli.CommandLineOptionTest; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
46 |
import jdk.test.lib.cli.predicate.AndPredicate; |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
47 |
import rtm.*; |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
48 |
import rtm.predicate.SupportedCPU; |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
49 |
import rtm.predicate.SupportedVM; |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
50 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
51 |
/** |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
52 |
* Test verifies that VM output does not contain RTM locking statistics when it |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
53 |
* should not (when PrintPreciseRTMLockingStatistics is off) and that with |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
54 |
* -XX:+PrintPreciseRTMLockingStatistics locking statistics contains sane |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
55 |
* total locks and aborts count as well as for specific abort types. |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
56 |
*/ |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
57 |
public class TestPrintPreciseRTMLockingStatistics |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
58 |
extends CommandLineOptionTest { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
59 |
private TestPrintPreciseRTMLockingStatistics() { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
60 |
super(new AndPredicate(new SupportedCPU(), new SupportedVM())); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
61 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
62 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
63 |
@Override |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
64 |
public void runTestCases() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
65 |
verifyNoStatistics(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
66 |
verifyStatistics(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
67 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
68 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
69 |
// verify that VM output does not contain |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
70 |
// rtm locking statistics |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
71 |
private void verifyNoStatistics() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
72 |
verifyNoStatistics(AbortType.XABORT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
73 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
74 |
verifyNoStatistics(AbortType.XABORT, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
75 |
"-XX:-PrintPreciseRTMLockingStatistics"); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
76 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
77 |
verifyNoStatistics(AbortType.XABORT, "-XX:-UseRTMLocking", |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
78 |
"-XX:+PrintPreciseRTMLockingStatistics"); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
79 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
80 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
81 |
// verify that rtm locking statistics contain information |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
82 |
// about each type of aborts |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
83 |
private void verifyStatistics() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
84 |
verifyAbortsCount(AbortType.XABORT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
85 |
verifyAbortsCount(AbortType.MEM_CONFLICT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
86 |
verifyAbortsCount(AbortType.BUF_OVERFLOW); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
87 |
verifyAbortsCount(AbortType.NESTED_ABORT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
88 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
89 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
90 |
private void verifyNoStatistics(AbortType abortProvokerType, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
91 |
String... vmOpts) throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
92 |
AbortProvoker provoker = abortProvokerType.provoker(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
93 |
List<String> finalVMOpts = new LinkedList<>(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
94 |
Collections.addAll(finalVMOpts, vmOpts); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
95 |
Collections.addAll(finalVMOpts, AbortProvoker.class.getName(), |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
96 |
abortProvokerType.toString()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
97 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
98 |
OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(provoker, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
99 |
finalVMOpts.toArray(new String[finalVMOpts.size()])); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
100 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
101 |
outputAnalyzer.shouldHaveExitValue(0); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
102 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
103 |
List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
104 |
outputAnalyzer.getOutput()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
105 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
106 |
Asserts.assertEQ(statistics.size(), 0, "VM output should not contain " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
107 |
+ "any RTM locking statistics"); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
108 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
109 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
110 |
private void verifyAbortsCount(AbortType abortType) throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
111 |
AbortProvoker provoker = abortType.provoker(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
112 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
113 |
OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
114 |
provoker, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
115 |
"-XX:+PrintPreciseRTMLockingStatistics", |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
116 |
AbortProvoker.class.getName(), |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
117 |
abortType.toString()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
118 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
119 |
outputAnalyzer.shouldHaveExitValue(0); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
120 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
121 |
List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
122 |
provoker.getMethodWithLockName(),outputAnalyzer.getOutput()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
123 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
124 |
Asserts.assertGT(statistics.size(), 0, "VM output should contain one " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
125 |
+ "rtm locking statistics entry for method " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
126 |
+ provoker.getMethodWithLockName()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
127 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
128 |
RTMLockingStatistics lock = statistics.get(0); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
129 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
130 |
Asserts.assertGT(lock.getTotalAborts(), 0L, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
131 |
"RTM locking statistics should contain non zero total aborts " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
132 |
+ "count"); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
133 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
134 |
Asserts.assertGT(lock.getAborts(abortType), 0L, String.format( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
135 |
"RTM locking statistics should contain non zero aborts count " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
136 |
+ "for abort reason %s", abortType)); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
137 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
138 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
139 |
public static void main(String args[]) throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
140 |
new TestPrintPreciseRTMLockingStatistics().test(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
141 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
142 |
} |