Skip to content

Commit f53138f

Browse files
Turn TestContinuationPinningAndEA into IR test
1 parent d4d1835 commit f53138f

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @requires vm.continuations
27+
* @bug 8347997
28+
* @library /test/lib /
29+
* @summary Test that Continuation.pin() and unpin() intrinsics work with EA.
30+
* @modules java.base/jdk.internal.vm
31+
* @run driver compiler.c2.irTests.TestContinuationPinningAndEA
32+
*/
33+
34+
package compiler.c2.irTests;
35+
36+
import compiler.lib.ir_framework.*;
37+
import jdk.internal.vm.Continuation;
38+
39+
public class TestContinuationPinningAndEA {
40+
public static void main(String[] args) {
41+
TestFramework.run();
42+
}
43+
44+
@Run(test = {
45+
"test_FailsEA", "test_Crashes",
46+
"test_FailsEANoInline", "test_CrashesNoInline",
47+
})
48+
public void runMethod() {
49+
try {
50+
test_FailsEA();
51+
} catch (Throwable _) {
52+
}
53+
try {
54+
test_Crashes();
55+
} catch (Throwable _) {
56+
}
57+
try {
58+
test_FailsEANoInline();
59+
} catch (Throwable _) {
60+
}
61+
try {
62+
test_CrashesNoInline();
63+
} catch (Throwable _) {
64+
}
65+
}
66+
67+
// ===Cases where allocations are removed===
68+
static class FailsEA {
69+
final Object o;
70+
71+
@ForceInline
72+
public FailsEA() throws Throwable {
73+
o = new Object();
74+
Continuation.pin();
75+
Continuation.unpin();
76+
}
77+
}
78+
79+
static class Crashes {
80+
final Object o;
81+
82+
@ForceInline
83+
public Crashes() throws Throwable {
84+
Continuation.pin();
85+
Continuation.unpin();
86+
o = new Object();
87+
}
88+
}
89+
90+
@Test
91+
@IR(failOn = {IRNode.ALLOC})
92+
static void test_FailsEA() throws Throwable {
93+
new FailsEA();
94+
}
95+
96+
@Test
97+
@IR(failOn = {IRNode.ALLOC})
98+
static void test_Crashes() throws Throwable {
99+
new Crashes();
100+
}
101+
102+
// ===Sanity check that allocations would happen===
103+
static class FailsEANoInline {
104+
final Object o;
105+
106+
@DontInline
107+
public FailsEANoInline() throws Throwable {
108+
o = new Object();
109+
Continuation.pin();
110+
Continuation.unpin();
111+
}
112+
}
113+
114+
static class CrashesNoInline {
115+
final Object o;
116+
117+
@DontInline
118+
public CrashesNoInline() throws Throwable {
119+
Continuation.pin();
120+
Continuation.unpin();
121+
o = new Object();
122+
}
123+
}
124+
125+
@Test
126+
@IR(counts = {IRNode.ALLOC, ">0"})
127+
static void test_FailsEANoInline() throws Throwable {
128+
new FailsEANoInline();
129+
}
130+
131+
@Test
132+
@IR(counts = {IRNode.ALLOC, ">0"})
133+
static void test_CrashesNoInline() throws Throwable {
134+
new CrashesNoInline();
135+
}
136+
}

0 commit comments

Comments
 (0)