34 * java.management
35 * @build sun.hotspot.WhiteBox
36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
37 * sun.hotspot.WhiteBox$WhiteBoxPermission
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
39 * -XX:+WhiteBoxAPI
40 * compiler.rtm.locking.TestRTMAfterNonRTMDeopt
41 */
42
43 package compiler.rtm.locking;
44
45 import compiler.testlibrary.rtm.AbortProvoker;
46 import compiler.testlibrary.rtm.CompilableTest;
47 import compiler.testlibrary.rtm.RTMLockingStatistics;
48 import compiler.testlibrary.rtm.RTMTestBase;
49 import compiler.testlibrary.rtm.predicate.SupportedCPU;
50 import compiler.testlibrary.rtm.predicate.SupportedVM;
51 import jdk.internal.misc.Unsafe;
52 import jdk.test.lib.Asserts;
53 import jdk.test.lib.process.OutputAnalyzer;
54 import jdk.test.lib.unsafe.UnsafeHelper;
55 import jdk.test.lib.cli.CommandLineOptionTest;
56 import jdk.test.lib.cli.predicate.AndPredicate;
57
58 import java.util.List;
59
60 /**
61 * To verify that with +UseRTMDeopt method's RTM state will be
62 * changed to ProfileRTM on deoptimization unrelated to
63 * rtm_state_change following sequence of events is used:
64 * <pre>
65 *
66 * rtm state ^
67 * |
68 * UseRTM | ******| ******
69 * | |
70 * ProfileRTM |******| |*****|
71 * | | | |
72 * 0-------|-----|-----|---------------------> time
73 * | | \ force abort
74 * | |
141
142 Asserts.assertEQ(rangeCheckTraps, 1,
143 "One range_check uncommon trap should be fired.");
144
145 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
146 test.getMethodWithLockName(), outputAnalyzer.getOutput());
147
148 int expectedStatEntries = (useRTMDeopt ? 4 : 2);
149
150 Asserts.assertEQ(statistics.size(), expectedStatEntries,
151 String.format("VM output should contain %d RTM locking "
152 + "statistics entries.", expectedStatEntries));
153 }
154
155 public static class Test implements CompilableTest {
156 // Following field have to be static in order to avoid escape analysis.
157 @SuppressWarnings("UnsuedDeclaration")
158 private static int field = 0;
159 private static final int ITERATIONS = 10000;
160 private static final int RANGE_CHECK_AT = ITERATIONS / 2;
161 private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe();
162 private final Object monitor = new Object();
163
164 @Override
165 public String getMethodWithLockName() {
166 return this.getClass().getName() + "::forceAbort";
167 }
168
169 @Override
170 public String[] getMethodsToCompileNames() {
171 return new String[] { getMethodWithLockName() };
172 }
173
174 public void forceAbort(int a[], boolean abort) {
175 try {
176 synchronized(monitor) {
177 a[0]++;
178 if (abort) {
179 Test.field = Test.UNSAFE.addressSize();
180 }
181 }
|
34 * java.management
35 * @build sun.hotspot.WhiteBox
36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
37 * sun.hotspot.WhiteBox$WhiteBoxPermission
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
39 * -XX:+WhiteBoxAPI
40 * compiler.rtm.locking.TestRTMAfterNonRTMDeopt
41 */
42
43 package compiler.rtm.locking;
44
45 import compiler.testlibrary.rtm.AbortProvoker;
46 import compiler.testlibrary.rtm.CompilableTest;
47 import compiler.testlibrary.rtm.RTMLockingStatistics;
48 import compiler.testlibrary.rtm.RTMTestBase;
49 import compiler.testlibrary.rtm.predicate.SupportedCPU;
50 import compiler.testlibrary.rtm.predicate.SupportedVM;
51 import jdk.internal.misc.Unsafe;
52 import jdk.test.lib.Asserts;
53 import jdk.test.lib.process.OutputAnalyzer;
54 import jdk.test.lib.cli.CommandLineOptionTest;
55 import jdk.test.lib.cli.predicate.AndPredicate;
56
57 import java.util.List;
58
59 /**
60 * To verify that with +UseRTMDeopt method's RTM state will be
61 * changed to ProfileRTM on deoptimization unrelated to
62 * rtm_state_change following sequence of events is used:
63 * <pre>
64 *
65 * rtm state ^
66 * |
67 * UseRTM | ******| ******
68 * | |
69 * ProfileRTM |******| |*****|
70 * | | | |
71 * 0-------|-----|-----|---------------------> time
72 * | | \ force abort
73 * | |
140
141 Asserts.assertEQ(rangeCheckTraps, 1,
142 "One range_check uncommon trap should be fired.");
143
144 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
145 test.getMethodWithLockName(), outputAnalyzer.getOutput());
146
147 int expectedStatEntries = (useRTMDeopt ? 4 : 2);
148
149 Asserts.assertEQ(statistics.size(), expectedStatEntries,
150 String.format("VM output should contain %d RTM locking "
151 + "statistics entries.", expectedStatEntries));
152 }
153
154 public static class Test implements CompilableTest {
155 // Following field have to be static in order to avoid escape analysis.
156 @SuppressWarnings("UnsuedDeclaration")
157 private static int field = 0;
158 private static final int ITERATIONS = 10000;
159 private static final int RANGE_CHECK_AT = ITERATIONS / 2;
160 private static final Unsafe UNSAFE = Unsafe.getUnsafe();
161 private final Object monitor = new Object();
162
163 @Override
164 public String getMethodWithLockName() {
165 return this.getClass().getName() + "::forceAbort";
166 }
167
168 @Override
169 public String[] getMethodsToCompileNames() {
170 return new String[] { getMethodWithLockName() };
171 }
172
173 public void forceAbort(int a[], boolean abort) {
174 try {
175 synchronized(monitor) {
176 a[0]++;
177 if (abort) {
178 Test.field = Test.UNSAFE.addressSize();
179 }
180 }
|