diff --git a/common.json b/common.json index d811baf1cf2e3..c075ba2ca0bbd 100644 --- a/common.json +++ b/common.json @@ -8,7 +8,7 @@ "COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet", "jdks": { - "galahad-jdk": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+25-2038", "platformspecific": true, "extrabundles": ["static-libs"]}, + "galahad-jdk": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+26-2139", "platformspecific": true, "extrabundles": ["static-libs"]}, "oraclejdk11": {"name": "jpg-jdk", "version": "11.0.11", "build_id": "jdk-11.0.11+9", "platformspecific": true, "extrabundles": ["static-libs"] }, @@ -45,13 +45,13 @@ "labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true }, "graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.3", "platformspecific": true }, - "oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+25", "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01-sulong", "platformspecific": true } + "oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+26", "platformspecific": true, "extrabundles": ["static-libs"]}, + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+26-jvmci-b01", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+26-jvmci-b01-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+26-jvmci-b01-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+26-jvmci-b01", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+26-jvmci-b01-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+26-jvmci-b01-sulong", "platformspecific": true } }, "eclipse": { diff --git a/compiler/src/jdk.graal.compiler.hotspot.jdk23.test/src/jdk/graal/compiler/hotspot/jdk23/test/VectorizedHashCodeTest.java b/compiler/src/jdk.graal.compiler.hotspot.jdk23.test/src/jdk/graal/compiler/hotspot/jdk23/test/VectorizedHashCodeTest.java index b84312aefabf0..65ebce73b4931 100644 --- a/compiler/src/jdk.graal.compiler.hotspot.jdk23.test/src/jdk/graal/compiler/hotspot/jdk23/test/VectorizedHashCodeTest.java +++ b/compiler/src/jdk.graal.compiler.hotspot.jdk23.test/src/jdk/graal/compiler/hotspot/jdk23/test/VectorizedHashCodeTest.java @@ -24,6 +24,7 @@ */ package jdk.graal.compiler.hotspot.jdk23.test; +import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.Set; @@ -40,20 +41,31 @@ @AddExports({"java.base/jdk.internal.util"}) public class VectorizedHashCodeTest extends GraalCompilerTest { + private static int getField(String name) { + try { + var arraysSupport = Class.forName("jdk.internal.util.ArraysSupport"); + Field f = arraysSupport.getDeclaredField(name); + f.setAccessible(true); + return f.getInt(null); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + @Test public void testJDKConstantValue() { - Assert.assertEquals(ArraysSupport.T_BOOLEAN, VectorizedHashCodeInvocationPlugin.T_BOOLEAN); - Assert.assertEquals(ArraysSupport.T_CHAR, VectorizedHashCodeInvocationPlugin.T_CHAR); - Assert.assertEquals(ArraysSupport.T_BYTE, VectorizedHashCodeInvocationPlugin.T_BYTE); - Assert.assertEquals(ArraysSupport.T_SHORT, VectorizedHashCodeInvocationPlugin.T_SHORT); - Assert.assertEquals(ArraysSupport.T_INT, VectorizedHashCodeInvocationPlugin.T_INT); + Assert.assertEquals(getField("T_BOOLEAN"), VectorizedHashCodeInvocationPlugin.T_BOOLEAN); + Assert.assertEquals(getField("T_CHAR"), VectorizedHashCodeInvocationPlugin.T_CHAR); + Assert.assertEquals(getField("T_BYTE"), VectorizedHashCodeInvocationPlugin.T_BYTE); + Assert.assertEquals(getField("T_SHORT"), VectorizedHashCodeInvocationPlugin.T_SHORT); + Assert.assertEquals(getField("T_INT"), VectorizedHashCodeInvocationPlugin.T_INT); } // @formatter:off private static String[] tests = {"", " ", "a", "abcdefg", - "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. -- Charles Dickens, Tale of Two Cities", - "C'était le meilleur des temps, c'était le pire des temps, c'était l'âge de la sagesse, c'était l'âge de la folie, c'était l'époque de la croyance, c'était l'époque de l'incrédulité, c'était la saison de la Lumière, c'était C'était la saison des Ténèbres, c'était le printemps de l'espoir, c'était l'hiver du désespoir, nous avions tout devant nous, nous n'avions rien devant nous, nous allions tous directement au Ciel, nous allions tous directement dans l'autre sens bref, la période ressemblait tellement à la période actuelle, que certaines de ses autorités les plus bruyantes ont insisté pour qu'elle soit reçue, pour le bien ou pour le mal, au degré superlatif de la comparaison seulement. -- Charles Dickens, Tale of Two Cities (in French)", - "禅道修行を志した雲水は、一般に参禅のしきたりを踏んだうえで一人の師につき、各地にある専門道場と呼ばれる養成寺院に入門し、与えられた公案に取り組むことになる。公案は、師家(老師)から雲水が悟りの境地へと進んで行くために手助けとして課す問題であり、悟りの境地に達していない人には容易に理解し難い難問だが、屁理屈や詭弁が述べられているわけではなく、頓知や謎かけとも異なる。" + "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only. -- Charles Dickens, Tale of Two Cities", + "C'était le meilleur des temps, c'était le pire des temps, c'était l'âge de la sagesse, c'était l'âge de la folie, c'était l'époque de la croyance, c'était l'époque de l'incrédulité, c'était la saison de la Lumière, c'était C'était la saison des Ténèbres, c'était le printemps de l'espoir, c'était l'hiver du désespoir, nous avions tout devant nous, nous n'avions rien devant nous, nous allions tous directement au Ciel, nous allions tous directement dans l'autre sens bref, la période ressemblait tellement à la période actuelle, que certaines de ses autorités les plus bruyantes ont insisté pour qu'elle soit reçue, pour le bien ou pour le mal, au degré superlatif de la comparaison seulement. -- Charles Dickens, Tale of Two Cities (in French)", + "禅道修行を志した雲水は、一般に参禅のしきたりを踏んだうえで一人の師につき、各地にある専門道場と呼ばれる養成寺院に入門し、与えられた公案に取り組むことになる。公案は、師家(老師)から雲水が悟りの境地へと進んで行くために手助けとして課す問題であり、悟りの境地に達していない人には容易に理解し難い難問だが、屁理屈や詭弁が述べられているわけではなく、頓知や謎かけとも異なる。" }; // @formatter:on @@ -89,7 +101,7 @@ private void testHash(String method, Function f, Function a, a -> a.length / 2); } - public static int hashBooleanArray(Object array, int fromIndex, int length, int initialValue) { - return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_BOOLEAN); + public static int hashBooleanArray(byte[] array, int fromIndex, int length, int initialValue) { + return ArraysSupport.hashCode(array, fromIndex, length, initialValue); } @Test @@ -124,7 +136,7 @@ public void testHashBooleanArray() { } public static int hashCharArray(char[] array, int fromIndex, int length, int initialValue) { - return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_CHAR); + return ArraysSupport.hashCode(array, fromIndex, length, initialValue); } @Test @@ -139,7 +151,7 @@ public void testHashCharArray() { } public static int hashShortArray(short[] array, int fromIndex, int length, int initialValue) { - return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_SHORT); + return ArraysSupport.hashCode(array, fromIndex, length, initialValue); } @Test @@ -154,7 +166,7 @@ public void testHashShortArray() { } public static int hashIntArray(int[] array, int fromIndex, int length, int initialValue) { - return ArraysSupport.vectorizedHashCode(array, fromIndex, length, initialValue, ArraysSupport.T_INT); + return ArraysSupport.hashCode(array, fromIndex, length, initialValue); } @Test diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java index 247aa12d2e95c..f73391fbd8a0e 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java @@ -55,8 +55,8 @@ public final class JVMCIVersionCheck { private static final Map> JVMCI_MIN_VERSIONS = Map.of( "21", Map.of(DEFAULT_VENDOR_ENTRY, createLegacyVersion(23, 1, 33)), "23", Map.of( - "Oracle Corporation", createLabsJDKVersion("23+25", 1), - DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("23+25", 1))); + "Oracle Corporation", createLabsJDKVersion("23+26", 1), + DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("23+26", 1))); private static final int NA = 0; /** * Minimum Java release supported by Graal. diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java index a842822bcb848..43ef7cb0b02c0 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java @@ -208,7 +208,7 @@ protected void reset() { } @Override - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/windows/os_windows.cpp#L5457-L5499") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L5672-L5714") protected void park(boolean isAbsolute, long time) { assert time >= 0 && !(isAbsolute && time == 0) : "must not be called otherwise"; @@ -256,7 +256,7 @@ private static int toDword(long value) { } @Override - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/windows/os_windows.cpp#L5501-L5504") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L5716-L5719") protected void unpark() { StackOverflowCheck.singleton().makeYellowZoneAvailable(); try { diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java index 49c4273397ba3..50544324bce26 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java @@ -55,7 +55,7 @@ public long getThreadCpuTime(IsolateThread isolateThread, boolean includeSystemT return getThreadCpuTime(hThread, includeSystemTime); } - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+10/src/hotspot/os/windows/os_windows.cpp#L4722-L4738") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L4960-L4976") @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) private static long getThreadCpuTime(HANDLE hThread, boolean includeSystemTime) { FILETIME create = StackValue.get(FILETIME.class); diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUtils.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUtils.java index 9c823502a4cce..f9ec40546b45c 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUtils.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUtils.java @@ -171,8 +171,8 @@ static void writeBytes(FileDescriptor descriptor, byte[] bytes, int off, int len /** Retrieve a nanosecond counter for elapsed time measurement. */ @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-22+22/src/hotspot/os/windows/os_windows.cpp#L976-L983") - @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-22+22/src/hotspot/os/windows/os_windows.cpp#L1081-L1087") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L1089-L1096") + @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-23+26/src/hotspot/os/windows/os_windows.cpp#L1194-L1200") public static long getNanoCounter() { if (performanceFrequency == 0L) { CLongPointer count = StackValue.get(CLongPointer.class); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKContainerSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKContainerSubstitutions.java index e7771fee6b0e8..c1b39b19bce1e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKContainerSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKContainerSubstitutions.java @@ -35,10 +35,11 @@ import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.jfr.Name_jdk_jfr_internal_JDKEvents_helper; -@TargetClass(className = "jdk.jfr.internal.instrument.JDKEvents") +@TargetClass(classNameProvider = Name_jdk_jfr_internal_JDKEvents_helper.class) @Platforms(LINUX.class) -final class Target_jdk_jfr_internal_instrument_JDKEvents { +final class Target_jdk_jfr_internal_JDKEvents { @Alias // @RecomputeFieldValue(kind = Kind.Reset) // private static Target_jdk_internal_platform_Metrics containerMetrics; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Name_jdk_jfr_internal_JDKEvents_helper.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Name_jdk_jfr_internal_JDKEvents_helper.java new file mode 100644 index 0000000000000..0bf0117657fbc --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Name_jdk_jfr_internal_JDKEvents_helper.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.jfr; + +import java.util.function.Function; + +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + +import com.oracle.svm.core.annotate.TargetClass; + +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; + +@Platforms(Platform.HOSTED_ONLY.class) +public final class Name_jdk_jfr_internal_JDKEvents_helper implements Function { + + @Override + public String apply(TargetClass annotation) { + if (JavaVersionUtil.JAVA_SPEC >= 23) { + return "jdk.jfr.internal.JDKEvents"; + } else { + return "jdk.jfr.internal.instrument.JDKEvents"; + } + } +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_instrument_JDKEvents.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_instrument_JDKEvents.java index a18d50e941c02..f6cb76b489b23 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_instrument_JDKEvents.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_instrument_JDKEvents.java @@ -33,16 +33,20 @@ import jdk.jfr.events.ActiveRecordingEvent; import jdk.jfr.events.ActiveSettingEvent; -@TargetClass(className = "jdk.jfr.internal.instrument.JDKEvents", onlyWith = HasJfrSupport.class) +@TargetClass(classNameProvider = Name_jdk_jfr_internal_JDKEvents_helper.class, onlyWith = HasJfrSupport.class) final class Target_jdk_jfr_internal_instrument_JDKEvents { - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) private static Class[] eventClasses = { + @Alias // + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) // + private static Class[] eventClasses = { ActiveSettingEvent.class, ActiveRecordingEvent.class }; // This is a list of the classes with instrumentation code that should be applied. - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) private static Class[] instrumentationClasses = new Class[]{}; + @Alias // + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) // + @TargetElement(onlyWith = JDK21OrEarlier.class) private static Class[] instrumentationClasses = new Class[]{}; @Alias // @TargetElement(onlyWith = JDK21OrEarlier.class) // diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java index 2aaf4cbab9477..f90898ed1777f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Target_java_lang_ScopedValue.java @@ -25,27 +25,16 @@ package com.oracle.svm.core.thread; import java.util.concurrent.Callable; -import java.util.function.BooleanSupplier; - -import jdk.graal.compiler.serviceprovider.JavaVersionUtil; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.annotate.Alias; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import com.oracle.svm.core.jdk.ModuleNative; +import com.oracle.svm.core.annotate.TargetElement; +import com.oracle.svm.core.jdk.JDK21OrEarlier; +import com.oracle.svm.core.jdk.JDK23OrLater; -@Platforms(Platform.HOSTED_ONLY.class) -final class ScopedValuesEnabled implements BooleanSupplier { - @Override - public boolean getAsBoolean() { - return JavaVersionUtil.JAVA_SPEC >= 21 || (JavaVersionUtil.JAVA_SPEC >= 20 && ModuleNative.bootLayerContainsModule("jdk.incubator.concurrent")); - } -} - -@TargetClass(className = "java.lang.ScopedValue", onlyWith = ScopedValuesEnabled.class) +@TargetClass(className = "java.lang.ScopedValue") final class Target_java_lang_ScopedValue { @Substitute static Target_java_lang_ScopedValue_Snapshot scopedValueBindings() { @@ -58,15 +47,20 @@ static Target_java_lang_ScopedValue_Snapshot scopedValueBindings() { } } +@TargetClass(className = "java.lang.ScopedValue", innerClass = "CallableOp", onlyWith = JDK23OrLater.class) +final class Target_java_lang_ScopedValue_CallableOp { +} + /** * Substituted to directly call {@link Target_java_lang_Thread#setScopedValueBindings} for forced * inlining. */ -@TargetClass(className = "java.lang.ScopedValue", innerClass = "Carrier", onlyWith = ScopedValuesEnabled.class) +@TargetClass(className = "java.lang.ScopedValue", innerClass = "Carrier") final class Target_java_lang_ScopedValue_Carrier { @Alias int bitmask; @Substitute + @TargetElement(onlyWith = JDK21OrEarlier.class) @Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false) private R runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Callable op) throws Exception { Target_java_lang_Thread.setScopedValueBindings(newSnapshot); @@ -78,6 +72,19 @@ private R runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Callabl } } + @Substitute + @TargetElement(onlyWith = JDK23OrLater.class) + @Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false) + private R runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Target_java_lang_ScopedValue_CallableOp op) throws Exception { + Target_java_lang_Thread.setScopedValueBindings(newSnapshot); + try { + return Target_jdk_internal_vm_ScopedValueContainer.call(op); + } finally { + Target_java_lang_Thread.setScopedValueBindings(newSnapshot.prev); + Target_java_lang_ScopedValue_Cache.invalidate(bitmask); + } + } + @Substitute @Uninterruptible(reason = "Ensure no safepoint actions can disrupt reverting scoped value bindings.", calleeMustBe = false) private void runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Runnable op) { @@ -91,16 +98,21 @@ private void runWith(Target_java_lang_ScopedValue_Snapshot newSnapshot, Runnable } } -@TargetClass(className = "jdk.internal.vm.ScopedValueContainer", onlyWith = ScopedValuesEnabled.class) +@TargetClass(className = "jdk.internal.vm.ScopedValueContainer") final class Target_jdk_internal_vm_ScopedValueContainer { @Alias + @TargetElement(onlyWith = JDK21OrEarlier.class) static native V call(Callable op) throws Exception; + @Alias + @TargetElement(onlyWith = JDK23OrLater.class) + static native V call(Target_java_lang_ScopedValue_CallableOp op) throws Exception; + @Alias static native void run(Runnable op); } -@TargetClass(className = "java.lang.ScopedValue", innerClass = "Snapshot", onlyWith = ScopedValuesEnabled.class) +@TargetClass(className = "java.lang.ScopedValue", innerClass = "Snapshot") final class Target_java_lang_ScopedValue_Snapshot { // Checkstyle: stop @Alias // @@ -111,7 +123,7 @@ final class Target_java_lang_ScopedValue_Snapshot { Target_java_lang_ScopedValue_Snapshot prev; } -@TargetClass(className = "java.lang.ScopedValue", innerClass = "Cache", onlyWith = ScopedValuesEnabled.class) +@TargetClass(className = "java.lang.ScopedValue", innerClass = "Cache") final class Target_java_lang_ScopedValue_Cache { @Alias static native void invalidate(int toClearBits);