author | stsmirno |
Mon, 17 Oct 2016 18:54:12 -0400 | |
changeset 41705 | 332239c052cc |
parent 41321 | 463ff7705f2f |
child 46515 | dbb676a40899 |
permissions | -rw-r--r-- |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, 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 |
* @test |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
26 |
* @bug 8031320 |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
27 |
* @summary Verify that rtm locking statistics contain proper information |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
28 |
* 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
|
29 |
* different types. Test also verify that VM output does not |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
30 |
* contain rtm locking statistics when it should not. |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
31 |
* @library /test/lib / |
36851 | 32 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28498
diff
changeset
|
33 |
* java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
34 |
* @build sun.hotspot.WhiteBox |
39438 | 35 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
36 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
37 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
40059 | 38 |
* -XX:+WhiteBoxAPI |
39 |
* compiler.rtm.print.TestPrintPreciseRTMLockingStatistics |
|
24006
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 |
|
40059 | 42 |
|
43 |
package compiler.rtm.print; |
|
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
44 |
|
40059 | 45 |
import compiler.testlibrary.rtm.AbortProvoker; |
46 |
import compiler.testlibrary.rtm.AbortType; |
|
47 |
import compiler.testlibrary.rtm.RTMLockingStatistics; |
|
48 |
import compiler.testlibrary.rtm.RTMTestBase; |
|
49 |
import compiler.testlibrary.rtm.predicate.SupportedCPU; |
|
41321 | 50 |
import compiler.testlibrary.rtm.predicate.SupportedOS; |
40059 | 51 |
import compiler.testlibrary.rtm.predicate.SupportedVM; |
52 |
import jdk.test.lib.Asserts; |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
53 |
import jdk.test.lib.process.OutputAnalyzer; |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
54 |
import jdk.test.lib.cli.CommandLineOptionTest; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
55 |
import jdk.test.lib.cli.predicate.AndPredicate; |
40059 | 56 |
|
57 |
import java.util.Collections; |
|
58 |
import java.util.LinkedList; |
|
59 |
import java.util.List; |
|
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
60 |
|
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 |
* 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
|
63 |
* should not (when PrintPreciseRTMLockingStatistics is off) and that with |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
64 |
* -XX:+PrintPreciseRTMLockingStatistics locking statistics contains sane |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
65 |
* 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
|
66 |
*/ |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
67 |
public class TestPrintPreciseRTMLockingStatistics |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
68 |
extends CommandLineOptionTest { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
69 |
private TestPrintPreciseRTMLockingStatistics() { |
41321 | 70 |
super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())); |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
71 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
72 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
73 |
@Override |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
74 |
public void runTestCases() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
75 |
verifyNoStatistics(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
76 |
verifyStatistics(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
77 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
78 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
79 |
// verify that VM output does not contain |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
80 |
// rtm locking statistics |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
81 |
private void verifyNoStatistics() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
82 |
verifyNoStatistics(AbortType.XABORT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
83 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
84 |
verifyNoStatistics(AbortType.XABORT, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
85 |
"-XX:-PrintPreciseRTMLockingStatistics"); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
86 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
87 |
verifyNoStatistics(AbortType.XABORT, "-XX:-UseRTMLocking", |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
88 |
"-XX:+PrintPreciseRTMLockingStatistics"); |
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 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
91 |
// verify that rtm locking statistics contain information |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
92 |
// about each type of aborts |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
93 |
private void verifyStatistics() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
94 |
verifyAbortsCount(AbortType.XABORT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
95 |
verifyAbortsCount(AbortType.MEM_CONFLICT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
96 |
verifyAbortsCount(AbortType.BUF_OVERFLOW); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
97 |
verifyAbortsCount(AbortType.NESTED_ABORT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
98 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
99 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
100 |
private void verifyNoStatistics(AbortType abortProvokerType, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
101 |
String... vmOpts) throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
102 |
AbortProvoker provoker = abortProvokerType.provoker(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
103 |
List<String> finalVMOpts = new LinkedList<>(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
104 |
Collections.addAll(finalVMOpts, vmOpts); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
105 |
Collections.addAll(finalVMOpts, AbortProvoker.class.getName(), |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
106 |
abortProvokerType.toString()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
107 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
108 |
OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(provoker, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
109 |
finalVMOpts.toArray(new String[finalVMOpts.size()])); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
110 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
111 |
outputAnalyzer.shouldHaveExitValue(0); |
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 |
List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
114 |
outputAnalyzer.getOutput()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
115 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
116 |
Asserts.assertEQ(statistics.size(), 0, "VM output should not contain " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
117 |
+ "any RTM locking statistics"); |
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 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
120 |
private void verifyAbortsCount(AbortType abortType) throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
121 |
AbortProvoker provoker = abortType.provoker(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
122 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
123 |
OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
124 |
provoker, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
125 |
"-XX:+PrintPreciseRTMLockingStatistics", |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
126 |
AbortProvoker.class.getName(), |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
127 |
abortType.toString()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
128 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
129 |
outputAnalyzer.shouldHaveExitValue(0); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
130 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
131 |
List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
132 |
provoker.getMethodWithLockName(),outputAnalyzer.getOutput()); |
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(statistics.size(), 0, "VM output should contain one " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
135 |
+ "rtm locking statistics entry for method " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
136 |
+ provoker.getMethodWithLockName()); |
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 |
RTMLockingStatistics lock = statistics.get(0); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
139 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
140 |
Asserts.assertGT(lock.getTotalAborts(), 0L, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
141 |
"RTM locking statistics should contain non zero total aborts " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
142 |
+ "count"); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
143 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
144 |
Asserts.assertGT(lock.getAborts(abortType), 0L, String.format( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
145 |
"RTM locking statistics should contain non zero aborts count " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
146 |
+ "for abort reason %s", abortType)); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
147 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
148 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
149 |
public static void main(String args[]) throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
150 |
new TestPrintPreciseRTMLockingStatistics().test(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
151 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
152 |
} |