Skip to content

Commit 745d079

Browse files
Merge with master.
2 parents 26aa935 + a791ad9 commit 745d079

File tree

726 files changed

+5142
-1613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

726 files changed

+5142
-1613
lines changed

common.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@
3737
"labsjdk-ee-20-llvm": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-sulong", "platformspecific": true },
3838

3939
"oraclejdk21": {"name": "jpg-jdk", "version": "21", "build_id": "33", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
40-
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b26", "platformspecific": true },
41-
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b26-debug", "platformspecific": true },
42-
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b26-sulong", "platformspecific": true },
43-
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26", "platformspecific": true },
44-
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26-debug", "platformspecific": true },
45-
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b26-sulong", "platformspecific": true },
40+
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b33", "platformspecific": true },
41+
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b33-debug", "platformspecific": true },
42+
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
43+
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33", "platformspecific": true },
44+
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-debug", "platformspecific": true },
45+
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
4646

47-
"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "7", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
48-
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+7-jvmci-b01", "platformspecific": true },
49-
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+7-jvmci-b01-debug", "platformspecific": true },
50-
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+7-jvmci-b01-sulong", "platformspecific": true },
51-
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+7-jvmci-b01", "platformspecific": true },
52-
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+7-jvmci-b01-debug", "platformspecific": true },
53-
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+7-jvmci-b01-sulong", "platformspecific": true }
47+
"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "8", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
48+
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+8-jvmci-b01", "platformspecific": true },
49+
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+8-jvmci-b01-debug", "platformspecific": true },
50+
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+8-jvmci-b01-sulong", "platformspecific": true },
51+
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+8-jvmci-b01", "platformspecific": true },
52+
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+8-jvmci-b01-debug", "platformspecific": true },
53+
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+8-jvmci-b01-sulong", "platformspecific": true }
5454
},
5555

5656
"eclipse": {

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CheckGraalInvariants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.util.zip.ZipEntry;
5252
import java.util.zip.ZipFile;
5353

54+
import jdk.graal.compiler.test.SubprocessUtil;
5455
import org.graalvm.word.LocationIdentity;
5556
import org.junit.Assert;
5657
import org.junit.Assume;
@@ -231,6 +232,7 @@ public boolean checkAssertions() {
231232

232233
@Test
233234
public void test() {
235+
Assume.assumeFalse("JaCoCo causes failure", SubprocessUtil.isJaCoCoAttached()); // GR-50672
234236
assumeManagementLibraryIsLoadable();
235237
runTest(new InvariantsTool());
236238
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/jfr/TestGetEventWriter.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import jdk.graal.compiler.core.common.PermanentBailoutException;
3939
import jdk.graal.compiler.core.test.SubprocessTest;
4040
import jdk.graal.compiler.test.AddExports;
41-
import jdk.graal.compiler.test.SubprocessUtil;
4241
import jdk.jfr.Event;
4342
import jdk.jfr.Recording;
4443
import jdk.vm.ci.meta.ResolvedJavaMethod;
@@ -57,6 +56,10 @@
5756
@AddExports("jdk.jfr/jdk.jfr.internal.event")
5857
public class TestGetEventWriter extends SubprocessTest {
5958

59+
private static boolean isJFRAvailable() {
60+
return ModuleLayer.boot().findModule("jdk.jfr").isPresent();
61+
}
62+
6063
private static void initializeJFR() {
6164
try (Recording r = new Recording()) {
6265
r.start();
@@ -77,6 +80,12 @@ static class InitializationEvent extends Event {
7780

7881
@Test
7982
public void test() throws IOException, InterruptedException {
83+
String[] args;
84+
if (isJFRAvailable()) {
85+
args = new String[0];
86+
} else {
87+
args = new String[]{"--add-modules", "jdk.jfr"};
88+
}
8089
launchSubprocess(() -> {
8190
try {
8291
initializeJFR();
@@ -90,7 +99,7 @@ public void test() throws IOException, InterruptedException {
9099
} catch (Throwable t) {
91100
throw rethrowSilently(RuntimeException.class, t);
92101
}
93-
}, SubprocessUtil.PACKAGE_OPENING_OPTIONS);
102+
}, args);
94103
}
95104

96105
@SuppressWarnings({"unused", "unchecked"})

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/CheckGraalIntrinsics.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
import java.util.ServiceLoader;
3838
import java.util.stream.Collectors;
3939

40-
import jdk.graal.compiler.api.test.Graal;
4140
import org.graalvm.collections.EconomicMap;
4241
import org.graalvm.collections.MapCursor;
42+
import org.junit.Test;
43+
44+
import jdk.graal.compiler.api.test.Graal;
4345
import jdk.graal.compiler.hotspot.GraalHotSpotVMConfig;
4446
import jdk.graal.compiler.hotspot.HotSpotGraalRuntimeProvider;
4547
import jdk.graal.compiler.hotspot.meta.HotSpotProviders;
@@ -50,8 +52,6 @@
5052
import jdk.graal.compiler.options.OptionValues;
5153
import jdk.graal.compiler.runtime.RuntimeProvider;
5254
import jdk.graal.compiler.test.GraalTest;
53-
import org.junit.Test;
54-
5555
import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
5656
import jdk.vm.ci.hotspot.VMIntrinsicMethod;
5757
import jdk.vm.ci.meta.MetaAccessProvider;
@@ -142,7 +142,7 @@ public interface Refiner {
142142

143143
public final HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
144144
public final GraalHotSpotVMConfig config = rt.getVMConfig();
145-
public final UnimplementedGraalIntrinsics unimplementedGraalIntrinsics = new UnimplementedGraalIntrinsics();
145+
public final UnimplementedGraalIntrinsics unimplementedGraalIntrinsics = new UnimplementedGraalIntrinsics(rt.getTarget().arch);
146146

147147
@Test
148148
@SuppressWarnings("try")
@@ -163,7 +163,6 @@ public void test() throws ClassNotFoundException, NoSuchFieldException {
163163
List<String> mischaracterizedAsIgnored = new ArrayList<>();
164164
List<String> notAvailableYetIntrinsified = new ArrayList<>();
165165

166-
Field toBeInvestigated = UnimplementedGraalIntrinsics.class.getDeclaredField("toBeInvestigated");
167166
for (VMIntrinsicMethod intrinsic : intrinsics) {
168167
ResolvedJavaMethod method = resolveIntrinsic(providers.getMetaAccess(), intrinsic);
169168
if (method == null) {
@@ -195,6 +194,7 @@ public void test() throws ClassNotFoundException, NoSuchFieldException {
195194

196195
Formatter errorMsgBuf = new Formatter();
197196
if (!missing.isEmpty()) {
197+
Field toBeInvestigated = UnimplementedGraalIntrinsics.class.getDeclaredField("toBeInvestigated");
198198
Collections.sort(missing);
199199
String missingString = missing.stream().map(s -> '"' + s + '"').collect(Collectors.joining(String.format(",%n ")));
200200
errorMsgBuf.format("missing Graal intrinsics for:%n %s%n", missingString);

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/VirtualThreadJFRTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public class VirtualThreadJFRTest extends SubprocessTest {
5252
private static class TestEvent extends Event {
5353
}
5454

55+
private static boolean isJFRAvailable() {
56+
return ModuleLayer.boot().findModule("jdk.jfr").isPresent();
57+
}
58+
5559
public static void testSnippet() {
5660
try (Recording r = new Recording()) {
5761
r.start();
@@ -122,7 +126,13 @@ public void testJFR() {
122126

123127
@Test
124128
public void testInSubprocess() throws InterruptedException, IOException {
125-
launchSubprocess(this::testJFR);
129+
String[] args;
130+
if (isJFRAvailable()) {
131+
args = new String[0];
132+
} else {
133+
args = new String[]{"--add-modules", "jdk.jfr"};
134+
}
135+
launchSubprocess(this::testJFR, args);
126136
}
127137

128138
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/MethodHandleImplTest.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,20 @@
2727
import java.lang.invoke.MethodHandle;
2828
import java.lang.invoke.MethodHandles;
2929
import java.lang.invoke.MethodType;
30+
import java.lang.invoke.VarHandle;
3031

3132
import org.junit.Test;
3233

34+
import jdk.graal.compiler.nodes.DeoptimizeNode;
35+
import jdk.graal.compiler.nodes.ValueNode;
36+
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
37+
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderContext;
38+
import jdk.graal.compiler.nodes.graphbuilderconf.NodePlugin;
39+
import jdk.vm.ci.meta.DeoptimizationAction;
40+
import jdk.vm.ci.meta.DeoptimizationReason;
41+
import jdk.vm.ci.meta.ResolvedJavaField;
42+
import jdk.vm.ci.meta.ResolvedJavaMethod;
43+
3344
public class MethodHandleImplTest extends MethodSubstitutionTest {
3445

3546
static final MethodHandle squareHandle;
@@ -63,4 +74,48 @@ public void testIsCompileConstant() {
6374
testGraph("invokeSquare");
6475
}
6576

77+
@Override
78+
protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
79+
conf.getPlugins().prependNodePlugin(new NodePlugin() {
80+
@Override
81+
public boolean handleLoadField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field) {
82+
if (field.getName().equals("fieldOffset") && b.getGraph().method().getName().equals("incrementThreadCount")) {
83+
// Force a deopt in the testFlock test case
84+
b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved));
85+
return true;
86+
}
87+
return false;
88+
}
89+
});
90+
return super.editGraphBuilderConfiguration(conf);
91+
}
92+
93+
public static class ThreadFlock {
94+
private static final VarHandle THREAD_COUNT;
95+
96+
static {
97+
try {
98+
MethodHandles.Lookup l = MethodHandles.lookup();
99+
THREAD_COUNT = l.findVarHandle(ThreadFlock.class, "threadCount", int.class);
100+
} catch (Exception e) {
101+
throw new InternalError(e);
102+
}
103+
}
104+
105+
@SuppressWarnings("unused") private volatile int threadCount;
106+
107+
public void incrementThreadCount() {
108+
THREAD_COUNT.getAndAdd(this, 1);
109+
}
110+
}
111+
112+
@Test
113+
public void testFlock() {
114+
ThreadFlock flock = new ThreadFlock();
115+
for (int i = 0; i < 10_000; i++) {
116+
flock.incrementThreadCount();
117+
}
118+
ResolvedJavaMethod method = getResolvedJavaMethod(ThreadFlock.class, "incrementThreadCount");
119+
getCode(method);
120+
}
66121
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/CompilationMemoryTest.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
*/
2525
package jdk.graal.compiler.truffle.test;
2626

27+
import java.io.IOException;
2728
import java.lang.ref.Reference;
2829
import java.lang.ref.WeakReference;
2930
import java.util.Arrays;
3031
import java.util.concurrent.FutureTask;
3132

33+
import com.oracle.truffle.api.test.SubprocessTestUtils;
3234
import org.junit.Assert;
3335
import org.junit.Before;
3436
import org.junit.Test;
@@ -50,7 +52,11 @@ public void setUp() {
5052
}
5153

5254
@Test
53-
public void testFieldsFreedAfterCompilation() throws InterruptedException {
55+
public void testFieldsFreedAfterCompilation() throws IOException, InterruptedException {
56+
SubprocessTestUtils.newBuilder(CompilationMemoryTest.class, CompilationMemoryTest::performTest).run();
57+
}
58+
59+
private static void performTest() {
5460
TestObject expected = new TestObject();
5561
OptimizedCallTarget callTarget = (OptimizedCallTarget) RootNode.createConstantNode(expected).getCallTarget();
5662
GraalTruffleRuntimeListenerImpl listener = new GraalTruffleRuntimeListenerImpl(callTarget);
@@ -69,21 +75,25 @@ public void testFieldsFreedAfterCompilation() throws InterruptedException {
6975
// method that references the Callable, in our case CompilationTask, finishes. The
7076
// CompilationTask holds the CallTarget via inliningData. Therefore, we have to wait for the
7177
// compiler thread to actually finish FutureTask execution.
72-
awaitDone(compilerTread, 10_000);
78+
Assert.assertTrue(awaitDone(compilerTread, 10_000));
7379
Reference<?> ref = new WeakReference<>(expected);
7480
expected = null;
7581
callTarget = null;
7682
GCUtils.assertGc("JavaConstant for TestObject should be freed after compilation.", ref);
7783
}
7884

79-
private static boolean awaitDone(Thread t, long timeout) throws InterruptedException {
85+
private static boolean awaitDone(Thread t, long timeout) {
8086
long deadline = System.currentTimeMillis() + timeout;
81-
while (System.currentTimeMillis() < deadline) {
82-
boolean working = Arrays.stream(t.getStackTrace()).map(StackTraceElement::getClassName).anyMatch((name) -> name.equals(FutureTask.class.getName()));
83-
if (!working) {
84-
return true;
87+
try {
88+
while (System.currentTimeMillis() < deadline) {
89+
boolean working = Arrays.stream(t.getStackTrace()).map(StackTraceElement::getClassName).anyMatch((name) -> name.equals(FutureTask.class.getName()));
90+
if (!working) {
91+
return true;
92+
}
93+
Thread.sleep(100);
8594
}
86-
Thread.sleep(100);
95+
} catch (InterruptedException ie) {
96+
// pass and return false
8797
}
8898
return false;
8999
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/DefaultLoomTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import com.oracle.truffle.api.Truffle;
3636
import com.oracle.truffle.api.impl.DefaultTruffleRuntime;
3737

38+
import static com.oracle.truffle.api.test.SubprocessTestUtils.markForRemoval;
39+
3840
/**
3941
* See {@link OptimizedLoomTest} for other runtimes.
4042
*/
@@ -58,6 +60,6 @@ public void test() throws InterruptedException, IOException {
5860
} catch (InterruptedException e) {
5961
Assert.fail(e.getMessage());
6062
}
61-
}, "--enable-preview", "-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime", "~~-Dpolyglot.engine.DynamicCompilationThresholds");
63+
}, "--enable-preview", "-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime", markForRemoval("-Dpolyglot.engine.DynamicCompilationThresholds"));
6264
}
6365
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/ExceptionActionTest.java

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
import java.util.logging.SimpleFormatter;
3636
import java.util.regex.Pattern;
3737

38+
import com.oracle.truffle.api.CompilerDirectives;
3839
import com.oracle.truffle.api.test.SubprocessTestUtils;
39-
import com.oracle.truffle.api.test.SubprocessTestUtils.Subprocess;
4040
import com.oracle.truffle.runtime.OptimizedTruffleRuntime;
4141
import com.oracle.truffle.runtime.OptimizedCallTarget;
4242

@@ -52,6 +52,8 @@
5252
import com.oracle.truffle.api.frame.VirtualFrame;
5353
import com.oracle.truffle.api.nodes.RootNode;
5454

55+
import static com.oracle.truffle.api.test.SubprocessTestUtils.markForRemoval;
56+
5557
public class ExceptionActionTest extends TestWithPolyglotOptions {
5658

5759
private static final String LOG_FILE_PROPERTY = ExceptionActionTest.class.getSimpleName() + ".LogFile";
@@ -125,6 +127,15 @@ public void testPermanentBailoutThrowWithGraalExitVM() throws Exception {
125127
new String[]{
126128
"-Djdk.graal.CompilationFailureAction=ExitVM",
127129
"-Djdk.graal.CompilationBailoutAsFailure=true",
130+
/*
131+
* The test validates that Truffle compilation uses
132+
* CompilationFailureAction#Throw even when the Graal
133+
* CompilationFailureAction option is set to ExitVM. To
134+
* ensure test stability, we disable JVMCI host
135+
* compilations, as they may lead to bailouts and random
136+
* test failures, as observed in issue GR-51840.
137+
*/
138+
"-XX:-UseJVMCICompiler",
128139
},
129140
"engine.CompilationFailureAction", "Throw");
130141
}
@@ -158,17 +169,15 @@ private void executeInSubProcess(BiConsumer<String, String> verifier, String...
158169
executeInSubProcess(verifier, ExceptionActionTest::createPermanentBailoutNode, new String[0], contextOptions);
159170
}
160171

161-
private void executeInSubProcess(BiConsumer<String, String> verifier, Supplier<RootNode> rootNodeFactory, String[] additionalVmOptions, String... contextOptions)
172+
private void executeInSubProcess(BiConsumer<String, String> verifier, Supplier<RootNode> rootNodeFactory, String[] appendVmOptions, String... contextOptions)
162173
throws IOException, InterruptedException {
163174
Path log = SubprocessTestUtils.isSubprocess() ? null : File.createTempFile("compiler", ".log").toPath();
164-
Subprocess subprocess = null;
165-
boolean success = false;
166175
try {
167-
String[] useVMOptions = Arrays.copyOf(additionalVmOptions, additionalVmOptions.length + 2);
176+
String[] useVMOptions = Arrays.copyOf(appendVmOptions, appendVmOptions.length + 2);
168177
useVMOptions[useVMOptions.length - 2] = String.format("-D%s=%s", LOG_FILE_PROPERTY, log);
169178
// Prevent graal graph dumping for ExceptionAction#Diagnose
170-
useVMOptions[useVMOptions.length - 1] = "~~-Djdk.graal.Dump";
171-
subprocess = SubprocessTestUtils.executeInSubprocess(ExceptionActionTest.class, () -> {
179+
useVMOptions[useVMOptions.length - 1] = markForRemoval("-Djdk.graal.Dump");
180+
SubprocessTestUtils.newBuilder(ExceptionActionTest.class, () -> {
172181
setupContext(contextOptions);
173182
OptimizedCallTarget target = (OptimizedCallTarget) rootNodeFactory.get().getCallTarget();
174183
try {
@@ -179,15 +188,17 @@ private void executeInSubProcess(BiConsumer<String, String> verifier, Supplier<R
179188
OptimizedTruffleRuntime.getRuntime().log(target, optFailedException.getClass().getName());
180189
}
181190
}
182-
}, false, useVMOptions);
183-
success = true;
184-
} finally {
185-
if (log != null) {
186-
if (success) {
191+
}).failOnNonZeroExit(false).postfixVmOption(useVMOptions).onExit((p) -> {
192+
try {
187193
String logContent = String.join("\n", Files.readAllLines(log));
188-
String output = String.join("\n", subprocess.output);
194+
String output = String.join("\n", p.output);
189195
verifier.accept(logContent, output);
196+
} catch (IOException ioe) {
197+
throw CompilerDirectives.shouldNotReachHere(ioe);
190198
}
199+
}).run();
200+
} finally {
201+
if (log != null) {
191202
Files.deleteIfExists(log);
192203
}
193204
}

0 commit comments

Comments
 (0)