Skip to content

Commit af5036d

Browse files
committed
Merge graalvm-community-jdk21u into mandrel/23.1
2 parents 7ef1994 + 561738d commit af5036d

File tree

22 files changed

+335
-121
lines changed

22 files changed

+335
-121
lines changed

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/virtual/phases/ea/EffectsClosure.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ protected BlockT merge(HIRBlock merge, List<BlockT> states) {
352352
@Override
353353
@SuppressWarnings("try")
354354
protected final List<BlockT> processLoop(Loop<HIRBlock> loop, BlockT initialState) {
355+
final StructuredGraph graph = loop.getHeader().getBeginNode().graph();
355356
if (initialState.isDead()) {
356357
ArrayList<BlockT> states = new ArrayList<>();
357358
for (int i = 0; i < loop.getLoopExits().size(); i++) {
@@ -422,6 +423,8 @@ protected final List<BlockT> processLoop(Loop<HIRBlock> loop, BlockT initialStat
422423
loopLocationKillCacheCopy.putAll(loopLocationKillCache);
423424
}
424425
}
426+
427+
boolean tooManyIterationsSeen = false;
425428
while (true) {
426429
try {
427430
BlockT loopEntryState = initialStateRemovedKilledLocations;
@@ -511,7 +514,18 @@ protected final List<BlockT> processLoop(Loop<HIRBlock> loop, BlockT initialStat
511514
currentMode = EffectsClosureMode.MATERIALIZE_ALL;
512515
continue;
513516
}
514-
throw new GraalError("too many iterations at %s", loop);
517+
if (!tooManyIterationsSeen) {
518+
tooManyIterationsSeen = true;
519+
/*
520+
* The first time we see that we did too many iterations we materialize everything
521+
* before the loop and see if that fixes our problems.
522+
*/
523+
graph.getDebug().dump(DebugContext.VERY_DETAILED_LEVEL, graph, "Too many loop iterations for %s trying to materialize everything before loop and redo loop nest", loop);
524+
currentMode = EffectsClosureMode.MATERIALIZE_ALL;
525+
continue;
526+
} else {
527+
throw new GraalError("too many iterations at %s", loop);
528+
}
515529
}
516530
}
517531

docs/reference-manual/native-image/JFR.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ You can configure the logging for the JFR system with a separate flag `-XX:Fligh
8989
The usage is: `-XX:FlightRecorderLogging=[tag1[+tag2...][*][=level][,...]]`.
9090
For example:
9191
```shell
92-
-XX:FlightRecorderLogging=jfr,system=debug
92+
-XX:FlightRecorderLogging=jfr+system=debug
9393
-XX:FlightRecorderLogging=all=trace
9494
-XX:FlightRecorderLogging=jfr*=error
9595
```

sdk/src/org.graalvm.home.test/src/org/graalvm/home/test/VersionTest.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -48,10 +48,12 @@
4848
import static org.junit.Assert.fail;
4949

5050
import java.util.ArrayList;
51+
import java.util.Arrays;
5152
import java.util.Collections;
5253
import java.util.List;
5354

5455
import org.graalvm.home.Version;
56+
import org.junit.Assert;
5557
import org.junit.Test;
5658

5759
public class VersionTest {
@@ -208,6 +210,40 @@ public void testFormat() {
208210
assertFormat("%%[R%d.%%d]", "23.0", "%[R23.%d]");
209211
}
210212

213+
@Test
214+
public void testGetComponents() {
215+
Version version = Version.create(23, 1, 4);
216+
try {
217+
version.getComponent(-1);
218+
Assert.fail("Should not reach here");
219+
} catch (IllegalArgumentException illegalArgument) {
220+
// expected
221+
}
222+
assertVersionComponents(new int[]{23, 1, 4, 0}, version);
223+
version = Version.create(23, 1);
224+
assertVersionComponents(new int[]{23, 1, 0, 0}, version);
225+
version = Version.create(23);
226+
assertVersionComponents(new int[]{23, 0, 0, 0}, version);
227+
version = Version.create(23, 0, 0);
228+
assertVersionComponents(new int[]{23, 0, 0, 0}, version);
229+
version = Version.parse("23.1.4");
230+
assertVersionComponents(new int[]{23, 1, 4, 0}, version);
231+
version = Version.parse("23.1.4-snapshot");
232+
assertVersionComponents(new int[]{23, 1, 4, 0}, version);
233+
version = Version.parse("23.1.4-dev");
234+
assertVersionComponents(new int[]{23, 1, 4, 0}, version);
235+
version = Version.parse("dev");
236+
assertVersionComponents(new int[]{0, 0, 0, 0}, version);
237+
version = Version.parse("snapshot");
238+
assertVersionComponents(new int[]{0, 0, 0, 0}, version);
239+
}
240+
241+
private static void assertVersionComponents(int[] expectedComponents, Version version) {
242+
for (int i = 0; i < expectedComponents.length; i++) {
243+
assertEquals("Expected " + Arrays.toString(expectedComponents) + "components in " + version, expectedComponents[i], version.getComponent(i));
244+
}
245+
}
246+
211247
private static void assertFormat(String format, String version, String expected) {
212248
Version v = Version.parse(version);
213249
String result = v.format(format);

sdk/src/org.graalvm.home/snapshot.sigtest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ meth public boolean equals(java.lang.Object)
3636
meth public boolean isRelease()
3737
meth public boolean isSnapshot()
3838
meth public int compareTo(org.graalvm.home.Version)
39+
meth public int getComponent(int)
3940
meth public int hashCode()
4041
meth public java.lang.String format(java.lang.String)
4142
meth public java.lang.String toString()

sdk/src/org.graalvm.home/src/org/graalvm/home/Version.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -338,6 +338,32 @@ public String format(String format) {
338338
return String.format(processFormat(format), args);
339339
}
340340

341+
/**
342+
* Retrieves the numeric value of the version component at the specified index.
343+
* <p>
344+
* Version components are indexed as follows:
345+
* <ul>
346+
* <li>{@code componentIndex = 0} represents the major version</li>
347+
* <li>{@code componentIndex = 1} represents the minor version</li>
348+
* <li>{@code componentIndex = 2} represents the update version</li>
349+
* </ul>
350+
* If the specified {@code componentIndex} exceeds the number of available components, the
351+
* method returns {@code 0}. For example, a version {@code 23.1} will return {@code 0} for
352+
* {@code componentIndex = 2}.
353+
* </p>
354+
*
355+
* @param componentIndex the index of the version component to retrieve; must be non-negative
356+
* @throws IllegalArgumentException if {@code componentIndex} is negative
357+
* @since 24.2
358+
* @see Version#create(int...)
359+
*/
360+
public int getComponent(int componentIndex) {
361+
if (componentIndex < 0) {
362+
throw new IllegalArgumentException("componentIndex must be non-negative: " + componentIndex);
363+
}
364+
return componentIndex < versions.length ? versions[componentIndex] : 0;
365+
}
366+
341367
/**
342368
* Parses a GraalVM version from its String raw format. Throws {@link IllegalArgumentException}
343369
* if the passed string is not a valid GraalVM version.

substratevm/src/com.oracle.svm.agent/src/com/oracle/svm/agent/BreakpointInterceptor.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private static boolean forName(JNIEnvironment jni, JNIObjectHandle thread, Break
210210
JNIObjectHandle name = getObjectArgument(thread, 0);
211211
String className = fromJniString(jni, name);
212212
if (className == null) {
213-
return false; /* No point in tracing this. */
213+
return true; /* No point in tracing this. */
214214
}
215215
traceReflectBreakpoint(jni, bp.clazz, nullHandle(), callerClass, bp.specification.methodName, null, state.getFullStackTraceOrNull(), className);
216216
return true;
@@ -573,13 +573,27 @@ private static boolean newArrayInstance0(JNIEnvironment jni, Breakpoint bp, JNIV
573573
return true;
574574
}
575575

576+
private static boolean handleResourceRegistration(JNIEnvironment env, JNIObjectHandle clazz, JNIObjectHandle callerClass, String function, JNIMethodId[] stackTrace, String resourceName,
577+
String moduleName) {
578+
if (resourceName == null) {
579+
return true; /* No point in tracing this: resource path is null */
580+
}
581+
582+
if (moduleName == null) {
583+
traceReflectBreakpoint(env, clazz, nullHandle(), callerClass, function, true, stackTrace, resourceName);
584+
} else {
585+
traceReflectBreakpoint(env, clazz, nullHandle(), callerClass, function, true, stackTrace, moduleName, resourceName);
586+
}
587+
588+
return true;
589+
}
590+
576591
private static boolean findResource(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) {
577592
JNIObjectHandle callerClass = state.getDirectCallerClass();
578593
JNIObjectHandle module = getObjectArgument(thread, 1);
579594
JNIObjectHandle name = getObjectArgument(thread, 2);
580-
traceReflectBreakpoint(jni, nullHandle(), nullHandle(), callerClass, bp.specification.methodName, true, state.getFullStackTraceOrNull(),
581-
fromJniString(jni, module), fromJniString(jni, name));
582-
return true;
595+
596+
return handleResourceRegistration(jni, nullHandle(), callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name), fromJniString(jni, module));
583597
}
584598

585599
private static boolean getResource(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) {
@@ -601,8 +615,8 @@ private static boolean handleGetResources(JNIEnvironment jni, JNIObjectHandle th
601615
selfClazz = nullHandle();
602616
}
603617
}
604-
traceReflectBreakpoint(jni, selfClazz, nullHandle(), callerClass, bp.specification.methodName, true, state.getFullStackTraceOrNull(), fromJniString(jni, name));
605-
return true;
618+
619+
return handleResourceRegistration(jni, selfClazz, callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name), null);
606620
}
607621

608622
private static boolean getSystemResource(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) {
@@ -615,9 +629,9 @@ private static boolean getSystemResources(JNIEnvironment jni, JNIObjectHandle th
615629

616630
private static boolean handleGetSystemResources(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) {
617631
JNIObjectHandle callerClass = state.getDirectCallerClass();
618-
JNIObjectHandle name = getReceiver(thread);
619-
traceReflectBreakpoint(jni, nullHandle(), nullHandle(), callerClass, bp.specification.methodName, true, state.getFullStackTraceOrNull(), fromJniString(jni, name));
620-
return true;
632+
JNIObjectHandle name = getObjectArgument(thread, 0);
633+
634+
return handleResourceRegistration(jni, nullHandle(), callerClass, bp.specification.methodName, state.getFullStackTraceOrNull(), fromJniString(jni, name), null);
621635
}
622636

623637
private static boolean newProxyInstance(JNIEnvironment jni, JNIObjectHandle thread, Breakpoint bp, InterceptedState state) {

substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/trace/ReflectionProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public void processEntry(EconomicMap<String, ?> entry, ConfigurationSet configur
106106
configuration.getOrCreateType(condition, type);
107107
}
108108
}
109+
return;
109110
}
110111
String clazz = (String) entry.get("class");
111112
if (advisor.shouldIgnore(lazyValue(clazz), lazyValue(callerClass))) {

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCEventSupport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public void emitGarbageCollectionEvent(UnsignedWord gcEpoch, GCCause cause, long
7575
JfrNativeEventWriter.beginSmallEvent(data, JfrEvent.GarbageCollection);
7676
JfrNativeEventWriter.putLong(data, startTicks);
7777
JfrNativeEventWriter.putLong(data, duration);
78+
JfrNativeEventWriter.putEventThread(data);
7879
JfrNativeEventWriter.putLong(data, gcEpoch.rawValue());
7980
JfrNativeEventWriter.putLong(data, gcName.getId());
8081
JfrNativeEventWriter.putLong(data, cause.getId());

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/LibGraalCollectionPolicy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public static final class Options {
6363
private UnsignedWord sizeBefore = WordFactory.zero();
6464
private GCCause lastGCCause = null;
6565

66+
@Override
67+
public String getName() {
68+
return "libgraal";
69+
}
70+
6671
/**
6772
* The hinted GC will be triggered only if the used bytes in eden space is greater than
6873
* {@link Options#ExpectedEdenSize}, or if the ratio of used bytes to total allocated bytes of

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.graalvm.nativeimage.c.struct.RawStructure;
5252
import org.graalvm.nativeimage.c.struct.SizeOf;
5353
import org.graalvm.nativeimage.c.type.CCharPointer;
54+
import org.graalvm.nativeimage.impl.ImageSingletonsSupport;
5455
import org.graalvm.word.Pointer;
5556
import org.graalvm.word.PointerBase;
5657
import org.graalvm.word.UnsignedWord;
@@ -170,7 +171,7 @@ public static void printObjectInfo(Log log, Object obj) {
170171
log.string(obj.getClass().getName());
171172

172173
if (obj instanceof String s) {
173-
log.string(": ").string(s, 60);
174+
log.string(": \"").string(s, 60).string("\"");
174175
} else {
175176
int layoutEncoding = DynamicHub.fromClass(obj.getClass()).getLayoutEncoding();
176177

@@ -1282,13 +1283,13 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
12821283

12831284
/*
12841285
* Copy the value to a field in the image heap so that it is safe to access. During
1285-
* image build, it can happen that the singleton does not exist yet. In that case,
1286-
* the value will be copied to the image heap when executing the constructor of the
1287-
* singleton. This is a bit cumbersome but necessary because we can't use a static
1288-
* field. We also need to mark the option as used at run-time (see feature) as the
1289-
* static analysis would otherwise remove the option from the image.
1286+
* the image build, it can happen that the singleton does not exist yet. In that
1287+
* case, the value will be copied to the image heap when executing the constructor
1288+
* of the singleton. This is a bit cumbersome but necessary because we can't use a
1289+
* static field. We also need to mark the option as used at run-time (see feature)
1290+
* as the static analysis would otherwise remove the option from the image.
12901291
*/
1291-
if (ImageSingletons.contains(Options.class)) {
1292+
if (wasConstructorExecuted()) {
12921293
Options.singleton().loopOnFatalError = newValue;
12931294
}
12941295
}
@@ -1301,7 +1302,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
13011302
super.onValueUpdate(values, oldValue, newValue);
13021303

13031304
/* See comment above. */
1304-
if (ImageSingletons.contains(Options.class)) {
1305+
if (wasConstructorExecuted()) {
13051306
Options.singleton().implicitExceptionWithoutStacktraceIsFatal = newValue;
13061307
}
13071308
}
@@ -1329,5 +1330,9 @@ public static boolean shouldLoopOnFatalError() {
13291330
public static boolean implicitExceptionWithoutStacktraceIsFatal() {
13301331
return singleton().implicitExceptionWithoutStacktraceIsFatal;
13311332
}
1333+
1334+
private static boolean wasConstructorExecuted() {
1335+
return (!SubstrateUtil.HOSTED || ImageSingletonsSupport.isInstalled()) && ImageSingletons.contains(Options.class);
1336+
}
13321337
}
13331338
}

0 commit comments

Comments
 (0)