author | gromero |
Fri, 14 Sep 2018 15:32:22 -0400 | |
changeset 51753 | 763aa4d1d596 |
parent 47216 | 71c04702a3d5 |
child 55087 | 82fe7292ca5c |
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 |
51753 | 34 |
* @requires vm.rtm.cpu & vm.rtm.compiler |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
35 |
* @build sun.hotspot.WhiteBox |
39438 | 36 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
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 |
40059 | 39 |
* -XX:+WhiteBoxAPI |
40 |
* compiler.rtm.print.TestPrintPreciseRTMLockingStatistics |
|
24006
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 |
|
40059 | 43 |
|
44 |
package compiler.rtm.print; |
|
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
45 |
|
40059 | 46 |
import compiler.testlibrary.rtm.AbortProvoker; |
47 |
import compiler.testlibrary.rtm.AbortType; |
|
48 |
import compiler.testlibrary.rtm.RTMLockingStatistics; |
|
49 |
import compiler.testlibrary.rtm.RTMTestBase; |
|
50 |
import jdk.test.lib.Asserts; |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
51 |
import jdk.test.lib.process.OutputAnalyzer; |
40059 | 52 |
|
53 |
import java.util.Collections; |
|
54 |
import java.util.LinkedList; |
|
55 |
import java.util.List; |
|
24006
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 |
/** |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
58 |
* 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
|
59 |
* should not (when PrintPreciseRTMLockingStatistics is off) and that with |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
60 |
* -XX:+PrintPreciseRTMLockingStatistics locking statistics contains sane |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
61 |
* 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
|
62 |
*/ |
46515
dbb676a40899
8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents:
41705
diff
changeset
|
63 |
public class TestPrintPreciseRTMLockingStatistics { |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
64 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
65 |
public void runTestCases() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
66 |
verifyNoStatistics(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
67 |
verifyStatistics(); |
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 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
70 |
// verify that VM output does not contain |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
71 |
// rtm locking statistics |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
72 |
private void verifyNoStatistics() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
73 |
verifyNoStatistics(AbortType.XABORT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
74 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
75 |
verifyNoStatistics(AbortType.XABORT, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
76 |
"-XX:-PrintPreciseRTMLockingStatistics"); |
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 |
verifyNoStatistics(AbortType.XABORT, "-XX:-UseRTMLocking", |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
79 |
"-XX:+PrintPreciseRTMLockingStatistics"); |
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 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
82 |
// verify that rtm locking statistics contain information |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
83 |
// about each type of aborts |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
84 |
private void verifyStatistics() throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
85 |
verifyAbortsCount(AbortType.XABORT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
86 |
verifyAbortsCount(AbortType.MEM_CONFLICT); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
87 |
verifyAbortsCount(AbortType.BUF_OVERFLOW); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
88 |
verifyAbortsCount(AbortType.NESTED_ABORT); |
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 |
private void verifyNoStatistics(AbortType abortProvokerType, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
92 |
String... vmOpts) throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
93 |
AbortProvoker provoker = abortProvokerType.provoker(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
94 |
List<String> finalVMOpts = new LinkedList<>(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
95 |
Collections.addAll(finalVMOpts, vmOpts); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
96 |
Collections.addAll(finalVMOpts, AbortProvoker.class.getName(), |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
97 |
abortProvokerType.toString()); |
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 |
OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(provoker, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
100 |
finalVMOpts.toArray(new String[finalVMOpts.size()])); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
101 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
102 |
outputAnalyzer.shouldHaveExitValue(0); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
103 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
104 |
List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
105 |
outputAnalyzer.getOutput()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
106 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
107 |
Asserts.assertEQ(statistics.size(), 0, "VM output should not contain " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
108 |
+ "any RTM locking statistics"); |
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 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
111 |
private void verifyAbortsCount(AbortType abortType) throws Throwable { |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
112 |
AbortProvoker provoker = abortType.provoker(); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
113 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
114 |
OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
115 |
provoker, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
116 |
"-XX:+PrintPreciseRTMLockingStatistics", |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
117 |
AbortProvoker.class.getName(), |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
118 |
abortType.toString()); |
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 |
outputAnalyzer.shouldHaveExitValue(0); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
121 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
122 |
List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
123 |
provoker.getMethodWithLockName(),outputAnalyzer.getOutput()); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
124 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
125 |
Asserts.assertGT(statistics.size(), 0, "VM output should contain one " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
126 |
+ "rtm locking statistics entry for method " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
127 |
+ provoker.getMethodWithLockName()); |
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 |
RTMLockingStatistics lock = statistics.get(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 |
Asserts.assertGT(lock.getTotalAborts(), 0L, |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
132 |
"RTM locking statistics should contain non zero total aborts " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
133 |
+ "count"); |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
134 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
135 |
Asserts.assertGT(lock.getAborts(abortType), 0L, String.format( |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
136 |
"RTM locking statistics should contain non zero aborts count " |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
137 |
+ "for abort reason %s", abortType)); |
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 |
|
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
140 |
public static void main(String args[]) throws Throwable { |
46515
dbb676a40899
8181124: Get rid of compiler.testlibrary.rtm.predicate
epavlova
parents:
41705
diff
changeset
|
141 |
new TestPrintPreciseRTMLockingStatistics().runTestCases(); |
24006
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
142 |
} |
54399106938f
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
143 |
} |