103 * -Xms256m -Xmx256m
104 * -Xbootclasspath/a:.
105 * -XX:CompileCommand=dontinline,*::dontinline_*
106 * -XX:+WhiteBoxAPI
107 * -Xbatch
108 * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks
109 * -XX:+UnlockExperimentalVMOptions -XX:LockingMode=2
110 *
111 * @comment Excercise -XX:+DeoptimizeObjectsALot. Mostly to prevent bit-rot because the option is meant to stress object deoptimization
112 * with non-synthetic workloads.
113 * @run driver EATests
114 * -XX:+UnlockDiagnosticVMOptions
115 * -Xms256m -Xmx256m
116 * -Xbootclasspath/a:.
117 * -XX:CompileCommand=dontinline,*::dontinline_*
118 * -XX:+WhiteBoxAPI
119 * -Xbatch
120 * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks
121 * -XX:+IgnoreUnrecognizedVMOptions -XX:+DeoptimizeObjectsALot
122 *
123 */
124 /**
125 * @test
126 * @bug 8227745
127 *
128 * @summary This is another configuration of EATests.java to test Graal. Some testcases are expected
129 * to fail because Graal does not provide all information about non-escaping objects in
130 * scope. These are skipped.
131 *
132 * @author Richard Reingruber richard DOT reingruber AT sap DOT com
133 *
134 * @requires ((vm.compMode == "Xmixed") & vm.graal.enabled)
135 *
136 * @library /test/lib /test/hotspot/jtreg
137 *
138 * @run build TestScaffold VMConnection TargetListener TargetAdapter jdk.test.whitebox.WhiteBox
139 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
140 * @run compile -g EATests.java
141 *
142 * @comment Test with Graal. Some testcases are expected to fail because Graal does not provide all information about non-escaping
143 * objects in scope. These are skipped.
236 new EAMaterializeLocalAtObjectPollReturnReturnTarget() .run();
237 new EAMaterializeIntArrayTarget() .run();
238 new EAMaterializeLongArrayTarget() .run();
239 new EAMaterializeFloatArrayTarget() .run();
240 new EAMaterializeDoubleArrayTarget() .run();
241 new EAMaterializeObjectArrayTarget() .run();
242 new EAMaterializeObjectWithConstantAndNotConstantValuesTarget() .run();
243 new EAMaterializeObjReferencedBy2LocalsTarget() .run();
244 new EAMaterializeObjReferencedBy2LocalsAndModifyTarget() .run();
245 new EAMaterializeObjReferencedBy2LocalsInDifferentVirtFramesTarget() .run();
246 new EAMaterializeObjReferencedBy2LocalsInDifferentVirtFramesAndModifyTarget() .run();
247 new EAMaterializeObjReferencedFromOperandStackTarget() .run();
248 new EAMaterializeLocalVariableUponGetAfterSetIntegerTarget() .run();
249
250 // Relocking test cases
251 new EARelockingSimpleTarget() .run();
252 new EARelockingSimpleWithAccessInOtherThreadTarget() .run();
253 new EARelockingRecursiveTarget() .run();
254 new EARelockingNestedInflatedTarget() .run();
255 new EARelockingNestedInflated_02Target() .run();
256 new EARelockingArgEscapeLWLockedInCalleeFrameTarget() .run();
257 new EARelockingArgEscapeLWLockedInCalleeFrame_2Target() .run();
258 new EARelockingArgEscapeLWLockedInCalleeFrameNoRecursiveTarget() .run();
259 new EAGetOwnedMonitorsTarget() .run();
260 new EAEntryCountTarget() .run();
261 new EARelockingObjectCurrentlyWaitingOnTarget() .run();
262
263 // Test cases that require deoptimization even though neither
264 // locks nor allocations are eliminated at the point where
265 // escape state is changed.
266 new EADeoptFrameAfterReadLocalObject_01Target() .run();
267 new EADeoptFrameAfterReadLocalObject_01BTarget() .run();
268 new EADeoptFrameAfterReadLocalObject_02Target() .run();
269 new EADeoptFrameAfterReadLocalObject_02BTarget() .run();
270 new EADeoptFrameAfterReadLocalObject_02CTarget() .run();
271 new EADeoptFrameAfterReadLocalObject_03Target() .run();
272
273 // PopFrame test cases
274 new EAPopFrameNotInlinedTarget() .run();
275 new EAPopFrameNotInlinedReallocFailureTarget() .run();
276 new EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget() .run();
277
278 // ForceEarlyReturn test cases
279 new EAForceEarlyReturnNotInlinedTarget() .run();
280 new EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsTarget() .run();
281 new EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailureTarget().run();
355 new EAMaterializeLocalAtObjectPollReturnReturn() .run(this);
356 new EAMaterializeIntArray() .run(this);
357 new EAMaterializeLongArray() .run(this);
358 new EAMaterializeFloatArray() .run(this);
359 new EAMaterializeDoubleArray() .run(this);
360 new EAMaterializeObjectArray() .run(this);
361 new EAMaterializeObjectWithConstantAndNotConstantValues() .run(this);
362 new EAMaterializeObjReferencedBy2Locals() .run(this);
363 new EAMaterializeObjReferencedBy2LocalsAndModify() .run(this);
364 new EAMaterializeObjReferencedBy2LocalsInDifferentVirtFrames() .run(this);
365 new EAMaterializeObjReferencedBy2LocalsInDifferentVirtFramesAndModify() .run(this);
366 new EAMaterializeObjReferencedFromOperandStack() .run(this);
367 new EAMaterializeLocalVariableUponGetAfterSetInteger() .run(this);
368
369 // Relocking test cases
370 new EARelockingSimple() .run(this);
371 new EARelockingSimpleWithAccessInOtherThread() .run(this);
372 new EARelockingRecursive() .run(this);
373 new EARelockingNestedInflated() .run(this);
374 new EARelockingNestedInflated_02() .run(this);
375 new EARelockingArgEscapeLWLockedInCalleeFrame() .run(this);
376 new EARelockingArgEscapeLWLockedInCalleeFrame_2() .run(this);
377 new EARelockingArgEscapeLWLockedInCalleeFrameNoRecursive() .run(this);
378 new EAGetOwnedMonitors() .run(this);
379 new EAEntryCount() .run(this);
380 new EARelockingObjectCurrentlyWaitingOn() .run(this);
381
382 // Test cases that require deoptimization even though neither
383 // locks nor allocations are eliminated at the point where
384 // escape state is changed.
385 new EADeoptFrameAfterReadLocalObject_01() .run(this);
386 new EADeoptFrameAfterReadLocalObject_01B() .run(this);
387 new EADeoptFrameAfterReadLocalObject_02() .run(this);
388 new EADeoptFrameAfterReadLocalObject_02B() .run(this);
389 new EADeoptFrameAfterReadLocalObject_02C() .run(this);
390 new EADeoptFrameAfterReadLocalObject_03() .run(this);
391
392 // PopFrame test cases
393 new EAPopFrameNotInlined() .run(this);
394 new EAPopFrameNotInlinedReallocFailure() .run(this);
395 new EAPopInlinedMethodWithScalarReplacedObjectsReallocFailure() .run(this);
396
397 // ForceEarlyReturn test cases
398 new EAForceEarlyReturnNotInlined() .run(this);
399 new EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjects() .run(this);
400 new EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailure().run(this);
1905 }
1906
1907 public void dontinline_testMethod() {
1908 @SuppressWarnings("unused")
1909 XYVal xy = new XYVal(1, 1); // scalar replaced
1910 XYVal l1 = inflatedLock; // read by debugger
1911 synchronized (l1) {
1912 testMethod_inlined(l1);
1913 }
1914 }
1915
1916 public void testMethod_inlined(XYVal l2) {
1917 synchronized (l2) { // eliminated nested locking
1918 dontinline_brkpt();
1919 }
1920 }
1921 }
1922
1923 /////////////////////////////////////////////////////////////////////////////
1924
1925 /**
1926 * Checks if an eliminated lock of an ArgEscape object l1 can be relocked if
1927 * l1 is locked in a callee frame.
1928 */
1929 class EARelockingArgEscapeLWLockedInCalleeFrame extends EATestCaseBaseDebugger {
1930
1931 public void runTestCase() throws Exception {
1932 BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
1933 printStack(bpe.thread());
1934 @SuppressWarnings("unused")
1935 ObjectReference o = getLocalRef(bpe.thread().frame(2), XYVAL_NAME, "l1");
1936 }
1937 }
1938
1939 class EARelockingArgEscapeLWLockedInCalleeFrameTarget extends EATestCaseBaseTarget {
1940
1941 @Override
1942 public void setUp() {
1943 super.setUp();
1944 testMethodDepth = 2;
2120 synchronized (l0) {
2121 synchronized (l1) {
2122 testMethod_inlined(l1);
2123 }
2124 }
2125 }
2126
2127 public void testMethod_inlined(ForLocking l2) throws Exception {
2128 synchronized (l2) { // eliminated nested locking
2129 dontinline_waitWhenWarmupDone(l2);
2130 }
2131 }
2132
2133 public void dontinline_waitWhenWarmupDone(ForLocking l2) throws Exception {
2134 if (warmupDone) {
2135 l2.wait();
2136 }
2137 }
2138 }
2139
2140 /////////////////////////////////////////////////////////////////////////////
2141 //
2142 // Test cases that require deoptimization even though neither locks
2143 // nor allocations are eliminated at the point where escape state is changed.
2144 //
2145 /////////////////////////////////////////////////////////////////////////////
2146
2147 /**
2148 * Let xy be NoEscape whose allocation cannot be eliminated (simulated by
2149 * -XX:-EliminateAllocations). The holding compiled frame has to be deoptimized when debugger
2150 * accesses xy because afterwards locking on xy is omitted.
2151 * Note: there are no EA based optimizations at the escape point.
2152 */
2153 class EADeoptFrameAfterReadLocalObject_01 extends EATestCaseBaseDebugger {
2154
2155 public void runTestCase() throws Exception {
2156 BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
2157 printStack(bpe.thread());
2158 @SuppressWarnings("unused")
2159 ObjectReference xy = getLocalRef(bpe.thread().frame(1), XYVAL_NAME, "xy");
|
103 * -Xms256m -Xmx256m
104 * -Xbootclasspath/a:.
105 * -XX:CompileCommand=dontinline,*::dontinline_*
106 * -XX:+WhiteBoxAPI
107 * -Xbatch
108 * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks
109 * -XX:+UnlockExperimentalVMOptions -XX:LockingMode=2
110 *
111 * @comment Excercise -XX:+DeoptimizeObjectsALot. Mostly to prevent bit-rot because the option is meant to stress object deoptimization
112 * with non-synthetic workloads.
113 * @run driver EATests
114 * -XX:+UnlockDiagnosticVMOptions
115 * -Xms256m -Xmx256m
116 * -Xbootclasspath/a:.
117 * -XX:CompileCommand=dontinline,*::dontinline_*
118 * -XX:+WhiteBoxAPI
119 * -Xbatch
120 * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks
121 * -XX:+IgnoreUnrecognizedVMOptions -XX:+DeoptimizeObjectsALot
122 *
123 * @bug 8324881
124 * @comment Regression test for using the wrong thread when logging during re-locking from deoptimization.
125 *
126 * @comment DiagnoseSyncOnValueBasedClasses=2 will cause logging when locking on \@ValueBased objects.
127 * @run driver EATests
128 * -XX:+UnlockDiagnosticVMOptions
129 * -Xms256m -Xmx256m
130 * -Xbootclasspath/a:.
131 * -XX:CompileCommand=dontinline,*::dontinline_*
132 * -XX:+WhiteBoxAPI
133 * -Xbatch
134 * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks
135 * -XX:+UnlockExperimentalVMOptions -XX:LockingMode=1
136 * -XX:DiagnoseSyncOnValueBasedClasses=2
137 *
138 * @comment Re-lock may inflate monitors when re-locking, which cause monitorinflation trace logging.
139 * @run driver EATests
140 * -XX:+UnlockDiagnosticVMOptions
141 * -Xms256m -Xmx256m
142 * -Xbootclasspath/a:.
143 * -XX:CompileCommand=dontinline,*::dontinline_*
144 * -XX:+WhiteBoxAPI
145 * -Xbatch
146 * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks
147 * -XX:+UnlockExperimentalVMOptions -XX:LockingMode=2
148 * -Xlog:monitorinflation=trace:file=monitorinflation.log
149 *
150 * @comment Re-lock may race with deflation.
151 * @run driver EATests
152 * -XX:+UnlockDiagnosticVMOptions
153 * -Xms256m -Xmx256m
154 * -Xbootclasspath/a:.
155 * -XX:CompileCommand=dontinline,*::dontinline_*
156 * -XX:+WhiteBoxAPI
157 * -Xbatch
158 * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks
159 * -XX:+UnlockExperimentalVMOptions -XX:LockingMode=0
160 * -XX:GuaranteedAsyncDeflationInterval=1000
161 */
162
163 /**
164 * @test
165 * @bug 8227745
166 *
167 * @summary This is another configuration of EATests.java to test Graal. Some testcases are expected
168 * to fail because Graal does not provide all information about non-escaping objects in
169 * scope. These are skipped.
170 *
171 * @author Richard Reingruber richard DOT reingruber AT sap DOT com
172 *
173 * @requires ((vm.compMode == "Xmixed") & vm.graal.enabled)
174 *
175 * @library /test/lib /test/hotspot/jtreg
176 *
177 * @run build TestScaffold VMConnection TargetListener TargetAdapter jdk.test.whitebox.WhiteBox
178 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
179 * @run compile -g EATests.java
180 *
181 * @comment Test with Graal. Some testcases are expected to fail because Graal does not provide all information about non-escaping
182 * objects in scope. These are skipped.
275 new EAMaterializeLocalAtObjectPollReturnReturnTarget() .run();
276 new EAMaterializeIntArrayTarget() .run();
277 new EAMaterializeLongArrayTarget() .run();
278 new EAMaterializeFloatArrayTarget() .run();
279 new EAMaterializeDoubleArrayTarget() .run();
280 new EAMaterializeObjectArrayTarget() .run();
281 new EAMaterializeObjectWithConstantAndNotConstantValuesTarget() .run();
282 new EAMaterializeObjReferencedBy2LocalsTarget() .run();
283 new EAMaterializeObjReferencedBy2LocalsAndModifyTarget() .run();
284 new EAMaterializeObjReferencedBy2LocalsInDifferentVirtFramesTarget() .run();
285 new EAMaterializeObjReferencedBy2LocalsInDifferentVirtFramesAndModifyTarget() .run();
286 new EAMaterializeObjReferencedFromOperandStackTarget() .run();
287 new EAMaterializeLocalVariableUponGetAfterSetIntegerTarget() .run();
288
289 // Relocking test cases
290 new EARelockingSimpleTarget() .run();
291 new EARelockingSimpleWithAccessInOtherThreadTarget() .run();
292 new EARelockingRecursiveTarget() .run();
293 new EARelockingNestedInflatedTarget() .run();
294 new EARelockingNestedInflated_02Target() .run();
295 new EARelockingNestedInflated_03Target() .run();
296 new EARelockingArgEscapeLWLockedInCalleeFrameTarget() .run();
297 new EARelockingArgEscapeLWLockedInCalleeFrame_2Target() .run();
298 new EARelockingArgEscapeLWLockedInCalleeFrameNoRecursiveTarget() .run();
299 new EAGetOwnedMonitorsTarget() .run();
300 new EAEntryCountTarget() .run();
301 new EARelockingObjectCurrentlyWaitingOnTarget() .run();
302 new EARelockingValueBasedTarget() .run();
303
304 // Test cases that require deoptimization even though neither
305 // locks nor allocations are eliminated at the point where
306 // escape state is changed.
307 new EADeoptFrameAfterReadLocalObject_01Target() .run();
308 new EADeoptFrameAfterReadLocalObject_01BTarget() .run();
309 new EADeoptFrameAfterReadLocalObject_02Target() .run();
310 new EADeoptFrameAfterReadLocalObject_02BTarget() .run();
311 new EADeoptFrameAfterReadLocalObject_02CTarget() .run();
312 new EADeoptFrameAfterReadLocalObject_03Target() .run();
313
314 // PopFrame test cases
315 new EAPopFrameNotInlinedTarget() .run();
316 new EAPopFrameNotInlinedReallocFailureTarget() .run();
317 new EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget() .run();
318
319 // ForceEarlyReturn test cases
320 new EAForceEarlyReturnNotInlinedTarget() .run();
321 new EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsTarget() .run();
322 new EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailureTarget().run();
396 new EAMaterializeLocalAtObjectPollReturnReturn() .run(this);
397 new EAMaterializeIntArray() .run(this);
398 new EAMaterializeLongArray() .run(this);
399 new EAMaterializeFloatArray() .run(this);
400 new EAMaterializeDoubleArray() .run(this);
401 new EAMaterializeObjectArray() .run(this);
402 new EAMaterializeObjectWithConstantAndNotConstantValues() .run(this);
403 new EAMaterializeObjReferencedBy2Locals() .run(this);
404 new EAMaterializeObjReferencedBy2LocalsAndModify() .run(this);
405 new EAMaterializeObjReferencedBy2LocalsInDifferentVirtFrames() .run(this);
406 new EAMaterializeObjReferencedBy2LocalsInDifferentVirtFramesAndModify() .run(this);
407 new EAMaterializeObjReferencedFromOperandStack() .run(this);
408 new EAMaterializeLocalVariableUponGetAfterSetInteger() .run(this);
409
410 // Relocking test cases
411 new EARelockingSimple() .run(this);
412 new EARelockingSimpleWithAccessInOtherThread() .run(this);
413 new EARelockingRecursive() .run(this);
414 new EARelockingNestedInflated() .run(this);
415 new EARelockingNestedInflated_02() .run(this);
416 new EARelockingNestedInflated_03() .run(this);
417 new EARelockingArgEscapeLWLockedInCalleeFrame() .run(this);
418 new EARelockingArgEscapeLWLockedInCalleeFrame_2() .run(this);
419 new EARelockingArgEscapeLWLockedInCalleeFrameNoRecursive() .run(this);
420 new EAGetOwnedMonitors() .run(this);
421 new EAEntryCount() .run(this);
422 new EARelockingObjectCurrentlyWaitingOn() .run(this);
423 new EARelockingValueBased() .run(this);
424
425 // Test cases that require deoptimization even though neither
426 // locks nor allocations are eliminated at the point where
427 // escape state is changed.
428 new EADeoptFrameAfterReadLocalObject_01() .run(this);
429 new EADeoptFrameAfterReadLocalObject_01B() .run(this);
430 new EADeoptFrameAfterReadLocalObject_02() .run(this);
431 new EADeoptFrameAfterReadLocalObject_02B() .run(this);
432 new EADeoptFrameAfterReadLocalObject_02C() .run(this);
433 new EADeoptFrameAfterReadLocalObject_03() .run(this);
434
435 // PopFrame test cases
436 new EAPopFrameNotInlined() .run(this);
437 new EAPopFrameNotInlinedReallocFailure() .run(this);
438 new EAPopInlinedMethodWithScalarReplacedObjectsReallocFailure() .run(this);
439
440 // ForceEarlyReturn test cases
441 new EAForceEarlyReturnNotInlined() .run(this);
442 new EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjects() .run(this);
443 new EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailure().run(this);
1948 }
1949
1950 public void dontinline_testMethod() {
1951 @SuppressWarnings("unused")
1952 XYVal xy = new XYVal(1, 1); // scalar replaced
1953 XYVal l1 = inflatedLock; // read by debugger
1954 synchronized (l1) {
1955 testMethod_inlined(l1);
1956 }
1957 }
1958
1959 public void testMethod_inlined(XYVal l2) {
1960 synchronized (l2) { // eliminated nested locking
1961 dontinline_brkpt();
1962 }
1963 }
1964 }
1965
1966 /////////////////////////////////////////////////////////////////////////////
1967
1968 /**
1969 * Like {@link EARelockingNestedInflated_02} with the difference that the
1970 * inflation of the lock happens because of contention.
1971 */
1972 class EARelockingNestedInflated_03 extends EATestCaseBaseDebugger {
1973
1974 public void runTestCase() throws Exception {
1975 BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
1976 printStack(bpe.thread());
1977 @SuppressWarnings("unused")
1978 ObjectReference o = getLocalRef(bpe.thread().frame(2), XYVAL_NAME, "l1");
1979 }
1980 }
1981
1982 class EARelockingNestedInflated_03Target extends EATestCaseBaseTarget {
1983
1984 public XYVal lockInflatedByContention;
1985 public boolean doLockNow;
1986 public EATestCaseBaseTarget testCase;
1987
1988 @Override
1989 public void setUp() {
1990 super.setUp();
1991 testMethodDepth = 2;
1992 lockInflatedByContention = new XYVal(1, 1);
1993 testCase = this;
1994 }
1995
1996 @Override
1997 public void warmupDone() {
1998 super.warmupDone();
1999 // Use new lock. lockInflatedByContention might have been inflated because of recursion.
2000 lockInflatedByContention = new XYVal(1, 1);
2001 // Start thread that tries to enter lockInflatedByContention while the main thread owns it -> inflation
2002 TestScaffold.newThread(() -> {
2003 while (true) {
2004 synchronized (testCase) {
2005 try {
2006 if (doLockNow) {
2007 doLockNow = false; // reset for main thread
2008 testCase.notify();
2009 break;
2010 }
2011 testCase.wait();
2012 } catch (InterruptedException e) { /* ignored */ }
2013 }
2014 }
2015 synchronized (lockInflatedByContention) { // will block and trigger inflation
2016 msg(Thread.currentThread().getName() + ": acquired lockInflatedByContention");
2017 }
2018 }, testCaseName + ": Lock Contender (test thread)").start();
2019 }
2020
2021 public void dontinline_testMethod() {
2022 @SuppressWarnings("unused")
2023 XYVal xy = new XYVal(1, 1); // scalar replaced
2024 XYVal l1 = lockInflatedByContention; // read by debugger
2025 synchronized (l1) {
2026 testMethod_inlined(l1);
2027 }
2028 }
2029
2030 public void testMethod_inlined(XYVal l2) {
2031 synchronized (l2) { // eliminated nested locking
2032 dontinline_notifyOtherThread();
2033 dontinline_brkpt();
2034 }
2035 }
2036
2037 public void dontinline_notifyOtherThread() {
2038 if (!warmupDone) {
2039 return;
2040 }
2041 synchronized (testCase) {
2042 doLockNow = true;
2043 testCase.notify();
2044 // wait for other thread to reset doLockNow again
2045 while (doLockNow) {
2046 try {
2047 testCase.wait();
2048 } catch (InterruptedException e) { /* ignored */ }
2049 }
2050 }
2051 }
2052 }
2053
2054 /////////////////////////////////////////////////////////////////////////////
2055
2056 /**
2057 * Checks if an eliminated lock of an ArgEscape object l1 can be relocked if
2058 * l1 is locked in a callee frame.
2059 */
2060 class EARelockingArgEscapeLWLockedInCalleeFrame extends EATestCaseBaseDebugger {
2061
2062 public void runTestCase() throws Exception {
2063 BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
2064 printStack(bpe.thread());
2065 @SuppressWarnings("unused")
2066 ObjectReference o = getLocalRef(bpe.thread().frame(2), XYVAL_NAME, "l1");
2067 }
2068 }
2069
2070 class EARelockingArgEscapeLWLockedInCalleeFrameTarget extends EATestCaseBaseTarget {
2071
2072 @Override
2073 public void setUp() {
2074 super.setUp();
2075 testMethodDepth = 2;
2251 synchronized (l0) {
2252 synchronized (l1) {
2253 testMethod_inlined(l1);
2254 }
2255 }
2256 }
2257
2258 public void testMethod_inlined(ForLocking l2) throws Exception {
2259 synchronized (l2) { // eliminated nested locking
2260 dontinline_waitWhenWarmupDone(l2);
2261 }
2262 }
2263
2264 public void dontinline_waitWhenWarmupDone(ForLocking l2) throws Exception {
2265 if (warmupDone) {
2266 l2.wait();
2267 }
2268 }
2269 }
2270
2271
2272 /////////////////////////////////////////////////////////////////////////////
2273
2274 /**
2275 * Test relocking eliminated @ValueBased object.
2276 */
2277 class EARelockingValueBased extends EATestCaseBaseDebugger {
2278
2279 public void runTestCase() throws Exception {
2280 BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
2281 printStack(bpe.thread());
2282 @SuppressWarnings("unused")
2283 ObjectReference o = getLocalRef(bpe.thread().frame(1), Integer.class.getName(), "l1");
2284 }
2285 }
2286
2287 class EARelockingValueBasedTarget extends EATestCaseBaseTarget {
2288
2289 public void dontinline_testMethod() {
2290 Integer l1 = new Integer(255);
2291 synchronized (l1) {
2292 dontinline_brkpt();
2293 }
2294 }
2295 }
2296
2297 /////////////////////////////////////////////////////////////////////////////
2298 //
2299 // Test cases that require deoptimization even though neither locks
2300 // nor allocations are eliminated at the point where escape state is changed.
2301 //
2302 /////////////////////////////////////////////////////////////////////////////
2303
2304 /**
2305 * Let xy be NoEscape whose allocation cannot be eliminated (simulated by
2306 * -XX:-EliminateAllocations). The holding compiled frame has to be deoptimized when debugger
2307 * accesses xy because afterwards locking on xy is omitted.
2308 * Note: there are no EA based optimizations at the escape point.
2309 */
2310 class EADeoptFrameAfterReadLocalObject_01 extends EATestCaseBaseDebugger {
2311
2312 public void runTestCase() throws Exception {
2313 BreakpointEvent bpe = resumeTo(TARGET_TESTCASE_BASE_NAME, "dontinline_brkpt", "()V");
2314 printStack(bpe.thread());
2315 @SuppressWarnings("unused")
2316 ObjectReference xy = getLocalRef(bpe.thread().frame(1), XYVAL_NAME, "xy");
|