Mercurial > hg > truffle
annotate test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java @ 20821:1bfa14fd1275
Cache the reflection Field in HotSpotResolvedFieldImpl, since it is accessed repeatedly when accessing the annotations of the field
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Wed, 08 Apr 2015 21:58:46 -0700 |
parents | ba8268c23fa2 |
children |
rev | line source |
---|---|
17873
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
1 /* |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
ba8268c23fa2
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. |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
4 * |
ba8268c23fa2
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 |
ba8268c23fa2
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 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
8 * |
ba8268c23fa2
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 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ba8268c23fa2
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 |
ba8268c23fa2
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 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
13 * accompanied this code). |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
14 * |
ba8268c23fa2
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 |
ba8268c23fa2
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, |
ba8268c23fa2
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. |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
18 * |
ba8268c23fa2
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 |
ba8268c23fa2
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 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
21 * questions. |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
22 * |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
23 */ |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
24 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
25 /** |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
26 * @test |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
27 * @bug 8031320 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
28 * @summary Verify that if we use RTMDeopt, then deoptimization |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
29 * caused by reason other then rtm_state_change will reset |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
30 * method's RTM state. And if we don't use RTMDeopt, then |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
31 * RTM state remain the same after such deoptimization. |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
32 * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
33 * @build TestRTMAfterNonRTMDeopt |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
34 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
35 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
36 * -XX:+WhiteBoxAPI TestRTMAfterNonRTMDeopt |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
37 */ |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
38 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
39 import java.util.List; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
40 import com.oracle.java.testlibrary.*; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
41 import com.oracle.java.testlibrary.cli.CommandLineOptionTest; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
42 import com.oracle.java.testlibrary.cli.predicate.AndPredicate; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
43 import rtm.*; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
44 import rtm.predicate.SupportedCPU; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
45 import rtm.predicate.SupportedVM; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
46 import sun.misc.Unsafe; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
47 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
48 /** |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
49 * To verify that with +UseRTMDeopt method's RTM state will be |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
50 * changed to ProfileRTM on deoptimization unrelated to |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
51 * rtm_state_change following sequence of events is used: |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
52 * <pre> |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
53 * |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
54 * rtm state ^ |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
55 * | |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
56 * UseRTM | ******| ****** |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
57 * | | |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
58 * ProfileRTM |******| |*****| |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
59 * | | | | |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
60 * 0-------|-----|-----|---------------------> time |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
61 * | | \ force abort |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
62 * | | |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
63 * | \ force deoptimization |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
64 * | |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
65 * \ force xabort |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
66 * </pre> |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
67 * When xabort is forced by native method call method should |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
68 * change it's state to UseRTM, because we use RTMAbortRatio=100 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
69 * and low RTMLockingThreshold, so at this point actual abort |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
70 * ratio will be below 100% and there should be enough lock |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
71 * attempts to recompile method without RTM profiling. |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
72 */ |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
73 public class TestRTMAfterNonRTMDeopt extends CommandLineOptionTest { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
74 private static final int ABORT_THRESHOLD = 1000; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
75 private static final String RANGE_CHECK = "range_check"; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
76 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
77 private TestRTMAfterNonRTMDeopt() { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
78 super(new AndPredicate(new SupportedCPU(), new SupportedVM())); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
79 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
80 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
81 @Override |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
82 protected void runTestCases() throws Throwable { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
83 verifyRTMAfterDeopt(false, false); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
84 verifyRTMAfterDeopt(true, false); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
85 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
86 verifyRTMAfterDeopt(false, true); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
87 verifyRTMAfterDeopt(true, true); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
88 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
89 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
90 private void verifyRTMAfterDeopt(boolean useStackLock, |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
91 boolean useRTMDeopt) throws Throwable { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
92 CompilableTest test = new Test(); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
93 String logFile = String.format("rtm_%s_stack_lock_%s_deopt.xml", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
94 (useStackLock ? "use" : "no"), (useRTMDeopt ? "use" : "no")); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
95 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
96 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest( |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
97 logFile, |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
98 test, |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
99 "-XX:CompileThreshold=1", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
100 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
101 useStackLock), |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
102 CommandLineOptionTest.prepareBooleanFlag("UseRTMDeopt", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
103 useRTMDeopt), |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
104 "-XX:RTMAbortRatio=100", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
105 CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
106 TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD), |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
107 CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
108 TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD / 2L), |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
109 "-XX:RTMTotalCountIncrRate=1", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
110 "-XX:+PrintPreciseRTMLockingStatistics", |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
111 Test.class.getName(), |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
112 Boolean.toString(!useStackLock) |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
113 ); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
114 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
115 outputAnalyzer.shouldHaveExitValue(0); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
116 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
117 int traps = RTMTestBase.firedRTMStateChangeTraps(logFile); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
118 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
119 if (useRTMDeopt) { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
120 Asserts.assertEQ(traps, 2, "Two uncommon traps with " |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
121 + "reason rtm_state_change should be fired."); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
122 } else { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
123 Asserts.assertEQ(traps, 0, "No uncommon traps with " |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
124 + "reason rtm_state_change should be fired."); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
125 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
126 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
127 int rangeCheckTraps = RTMTestBase.firedUncommonTraps(logFile, |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
128 TestRTMAfterNonRTMDeopt.RANGE_CHECK); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
129 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
130 Asserts.assertEQ(rangeCheckTraps, 1, |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
131 "One range_check uncommon trap should be fired."); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
132 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
133 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString( |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
134 test.getMethodWithLockName(), outputAnalyzer.getOutput()); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
135 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
136 int expectedStatEntries = (useRTMDeopt ? 4 : 2); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
137 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
138 Asserts.assertEQ(statistics.size(), expectedStatEntries, |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
139 String.format("VM output should contain %d RTM locking " |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
140 + "statistics entries.", expectedStatEntries)); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
141 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
142 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
143 public static class Test implements CompilableTest { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
144 // Following field have to be static in order to avoid escape analysis. |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
145 @SuppressWarnings("UnsuedDeclaration") |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
146 private static int field = 0; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
147 private static final int ITERATIONS = 10000; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
148 private static final int RANGE_CHECK_AT = ITERATIONS / 2; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
149 private static final Unsafe UNSAFE = Utils.getUnsafe(); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
150 private final Object monitor = new Object(); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
151 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
152 @Override |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
153 public String getMethodWithLockName() { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
154 return this.getClass().getName() + "::forceAbort"; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
155 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
156 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
157 @Override |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
158 public String[] getMethodsToCompileNames() { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
159 return new String[] { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
160 getMethodWithLockName(), |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
161 sun.misc.Unsafe.class.getName() + "::forceAbort" |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
162 }; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
163 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
164 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
165 public void forceAbort(int a[], boolean abort) { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
166 try { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
167 synchronized(monitor) { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
168 a[0]++; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
169 if (abort) { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
170 Test.field = Test.UNSAFE.addressSize(); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
171 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
172 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
173 } catch (Throwable t) { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
174 // suppress any throwables |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
175 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
176 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
177 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
178 /** |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
179 * Usage: |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
180 * Test <inflate monitor> |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
181 */ |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
182 public static void main(String args[]) throws Throwable { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
183 Test t = new Test(); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
184 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
185 if (Boolean.valueOf(args[0])) { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
186 AbortProvoker.inflateMonitor(t.monitor); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
187 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
188 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
189 int tmp[] = new int[1]; |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
190 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
191 for (int i = 0; i < Test.ITERATIONS; i++ ) { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
192 if (i == Test.RANGE_CHECK_AT) { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
193 t.forceAbort(new int[0], false); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
194 } else { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
195 boolean isThreshold |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
196 = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
197 boolean isThresholdPlusRange |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
198 = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
199 + Test.RANGE_CHECK_AT); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
200 t.forceAbort(tmp, isThreshold || isThresholdPlusRange); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
201 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
202 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
203 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
204 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
205 |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
206 public static void main(String args[]) throws Throwable { |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
207 new TestRTMAfterNonRTMDeopt().test(); |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
208 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
209 } |
ba8268c23fa2
8037860: Add tests to cover Intel RTM instructions support
iignatyev
parents:
diff
changeset
|
210 |