diff --git a/common.json b/common.json index 525cbf950225..1ae61620baaf 100644 --- a/common.json +++ b/common.json @@ -4,7 +4,7 @@ "Jsonnet files should not include this file directly but use ci/common.jsonnet instead." ], - "mx_version": "6.52.0", + "mx_version": "6.53.2", "COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet", "jdks": { @@ -42,13 +42,13 @@ "labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b22-debug", "platformspecific": true }, "labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b22-sulong", "platformspecific": true }, - "oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "18", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+18-jvmci-b03", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+18-jvmci-b03-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+18-jvmci-b03-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+18-jvmci-b03", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+18-jvmci-b03-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+18-jvmci-b03-sulong", "platformspecific": true } + "oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "20", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}, + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02-sulong", "platformspecific": true } }, "eclipse": { diff --git a/compiler/ci/ci_common/gate.jsonnet b/compiler/ci/ci_common/gate.jsonnet index 88cea5bffccf..ff6c1ac211e4 100644 --- a/compiler/ci/ci_common/gate.jsonnet +++ b/compiler/ci/ci_common/gate.jsonnet @@ -204,12 +204,14 @@ local gates = { "gate-compiler-test-labsjdk-latest-linux-amd64": t("1:00:00") + c.mach5_target, "gate-compiler-test-labsjdk-latest-linux-aarch64": t("1:50:00") + s.avoid_xgene3, - "gate-compiler-test-labsjdk-latest-darwin-amd64": t("1:00:00") + c.mach5_target + s.ram16gb, + # JDK latest only works on MacOS Ventura (GR-49652) + # "gate-compiler-test-labsjdk-latest-darwin-amd64": t("1:00:00") + c.mach5_target + s.ram16gb, "gate-compiler-test-labsjdk-latest-darwin-aarch64": t("1:00:00"), "gate-compiler-test-labsjdk-latest-windows-amd64": t("1:30:00"), "gate-compiler-test_zgc-labsjdk-latest-linux-amd64": t("1:00:00") + c.mach5_target, "gate-compiler-test_zgc-labsjdk-latest-linux-aarch64": t("1:50:00") + s.avoid_xgene3, - "gate-compiler-test_zgc-labsjdk-latest-darwin-amd64": t("1:00:00") + c.mach5_target + s.ram16gb, + # JDK latest only works on MacOS Ventura (GR-49652) + # "gate-compiler-test_zgc-labsjdk-latest-darwin-amd64": t("1:00:00") + c.mach5_target + s.ram16gb, "gate-compiler-test_zgc-labsjdk-latest-darwin-aarch64": t("1:00:00"), # Style jobs need to stay on a JDK compatible with all the style @@ -230,7 +232,8 @@ "gate-compiler-truffle_xcomp-labsjdk-latest-linux-amd64": t("1:30:00"), "gate-compiler-truffle_xcomp_zgc-labsjdk-latest-linux-amd64": t("1:30:00"), - "gate-compiler-bootstrap_lite-labsjdk-latest-darwin-amd64": t("1:00:00") + c.mach5_target, + # JDK latest only works on MacOS Ventura (GR-49652) + # "gate-compiler-bootstrap_lite-labsjdk-latest-darwin-amd64": t("1:00:00") + c.mach5_target, "gate-compiler-bootstrap_full-labsjdk-latest-linux-amd64": s.many_cores + c.mach5_target, "gate-compiler-bootstrap_full_zgc-labsjdk-latest-linux-amd64": s.many_cores + c.mach5_target diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/CheckGraalIntrinsics.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/CheckGraalIntrinsics.java index f109b07a71bc..64ca4910a070 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/CheckGraalIntrinsics.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/CheckGraalIntrinsics.java @@ -28,6 +28,7 @@ import static jdk.graal.compiler.hotspot.HotSpotGraalServices.isIntrinsicSupportedByC2; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; @@ -62,7 +63,7 @@ * Checks the intrinsics implemented by Graal against the set of intrinsics declared by HotSpot. The * purpose of this test is to detect when new intrinsics are added to HotSpot and process them * appropriately in Graal. This will be achieved by working through - * {@link UnimplementedGraalIntrinsics#toBeInvestigated} and * either implementing the intrinsic or + * {@link UnimplementedGraalIntrinsics#toBeInvestigated} and either implementing the intrinsic or * moving it to {@link UnimplementedGraalIntrinsics#ignore}. */ public class CheckGraalIntrinsics extends GraalTest { @@ -145,7 +146,7 @@ public interface Refiner { @Test @SuppressWarnings("try") - public void test() throws ClassNotFoundException { + public void test() throws ClassNotFoundException, NoSuchFieldException { HotSpotProviders providers = rt.getHostBackend().getProviders(); Plugins graphBuilderPlugins = providers.getGraphBuilderPlugins(); InvocationPlugins invocationPlugins = graphBuilderPlugins.getInvocationPlugins(); @@ -162,6 +163,7 @@ public void test() throws ClassNotFoundException { List mischaracterizedAsIgnored = new ArrayList<>(); List notAvailableYetIntrinsified = new ArrayList<>(); + Field toBeInvestigated = UnimplementedGraalIntrinsics.class.getDeclaredField("toBeInvestigated"); for (VMIntrinsicMethod intrinsic : intrinsics) { ResolvedJavaMethod method = resolveIntrinsic(providers.getMetaAccess(), intrinsic); if (method == null) { @@ -196,6 +198,8 @@ public void test() throws ClassNotFoundException { Collections.sort(missing); String missingString = missing.stream().map(s -> '"' + s + '"').collect(Collectors.joining(String.format(",%n "))); errorMsgBuf.format("missing Graal intrinsics for:%n %s%n", missingString); + errorMsgBuf.format("To fix, modify the %s constructor to add them to %s.%n", + UnimplementedGraalIntrinsics.class.getSimpleName(), toBeInvestigated); } if (!mischaracterizedAsToBeInvestigated.isEmpty()) { Collections.sort(mischaracterizedAsToBeInvestigated); 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 8b73e65ffa7c..ad357ae148a9 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 @@ -48,7 +48,7 @@ public final class JVMCIVersionCheck { */ private static final Map JVMCI_MIN_VERSIONS = Map.of( "21", new Version(23, 1, 22), - "22", new Version("22+18", 3)); + "22", new Version("22+20", 2)); private static final int NA = 0; /** diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java index 18f690d8858a..eff867e7c52c 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java @@ -116,8 +116,11 @@ public UnimplementedGraalIntrinsics() { "jdk/jfr/internal/JVM.counterTime()J", "jdk/jfr/internal/JVM.getEventWriter()Ljdk/jfr/internal/event/EventWriter;"); - // JDK-8223347: Integration of Vector API (Incubator) add(toBeInvestigated, // @formatter:off + // JDK-8309130: x86_64 AVX512 intrinsics for Arrays.sort methods (GR-48679) + "java/util/DualPivotQuicksort.partition(Ljava/lang/Class;Ljava/lang/Object;JIIIILjava/util/DualPivotQuicksort$PartitionOperation;)[I", + "java/util/DualPivotQuicksort.sort(Ljava/lang/Class;Ljava/lang/Object;JIILjava/util/DualPivotQuicksort$SortOperation;)V", + // JDK-8223347: Integration of Vector API "jdk/internal/vm/vector/VectorSupport.compressExpandOp(ILjava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;ILjdk/internal/vm/vector/VectorSupport$Vector;Ljdk/internal/vm/vector/VectorSupport$VectorMask;Ljdk/internal/vm/vector/VectorSupport$CompressExpandOperation;)Ljdk/internal/vm/vector/VectorSupport$VectorPayload;", jdk == 21 ? "jdk/internal/vm/vector/VectorSupport.extract(Ljava/lang/Class;Ljava/lang/Class;ILjdk/internal/vm/vector/VectorSupport$Vector;ILjdk/internal/vm/vector/VectorSupport$VecExtractOp;)J": "jdk/internal/vm/vector/VectorSupport.extract(Ljava/lang/Class;Ljava/lang/Class;ILjdk/internal/vm/vector/VectorSupport$VectorPayload;ILjdk/internal/vm/vector/VectorSupport$VecExtractOp;)J", diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/AbstractConstantKeysObject.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/AbstractConstantKeysObject.java index 72a3fbe65a08..b6fd20068bf4 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/AbstractConstantKeysObject.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/AbstractConstantKeysObject.java @@ -95,7 +95,7 @@ public static boolean cacheEquals(AbstractConstantKeysObject receiver, String sy @SuppressWarnings("unused") @Specialization(replaces = "cacheEquals") public static boolean isReadable(AbstractConstantKeysObject receiver, String symbol, - @Cached("createClassProfile()") @Cached.Shared("classProfile") ValueProfile classProfile) { + @Cached(value = "createClassProfile()", inline = false) @Cached.Shared("classProfile") ValueProfile classProfile) { return classProfile.profile(receiver).isMemberReadableImpl(symbol); } } @@ -106,20 +106,20 @@ public abstract static class ReadMember { @Specialization(guards = "symbol == cachedSymbol", limit = "8") public static Object readIdentity(AbstractConstantKeysObject receiver, @SuppressWarnings("unused") String symbol, @Cached("symbol") String cachedSymbol, - @Cached("createClassProfile()") @Cached.Exclusive ValueProfile classProfile) throws UnknownIdentifierException { + @Cached(value = "createClassProfile()", inline = false) @Cached.Exclusive ValueProfile classProfile) throws UnknownIdentifierException { return read(receiver, cachedSymbol, classProfile); } @Specialization(guards = "symbol.equals(cachedSymbol)", limit = "8", replaces = "readIdentity") public static Object readEquals(AbstractConstantKeysObject receiver, @SuppressWarnings("unused") String symbol, @Cached("symbol") String cachedSymbol, - @Cached("createClassProfile()") @Cached.Exclusive ValueProfile classProfile) throws UnknownIdentifierException { + @Cached(value = "createClassProfile()", inline = false) @Cached.Exclusive ValueProfile classProfile) throws UnknownIdentifierException { return read(receiver, cachedSymbol, classProfile); } @Specialization(replaces = "readEquals") public static Object read(AbstractConstantKeysObject receiver, String symbol, - @Cached("createClassProfile()") @Cached.Shared("classProfile") ValueProfile classProfile) throws UnknownIdentifierException { + @Cached(value = "createClassProfile()", inline = false) @Cached.Shared("classProfile") ValueProfile classProfile) throws UnknownIdentifierException { return classProfile.profile(receiver).readMemberImpl(symbol); } } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexExecNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexExecNode.java index 89ab27f2fab0..596397a3c667 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexExecNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexExecNode.java @@ -86,7 +86,7 @@ public final int inputLength(TruffleString input) { CompilerDirectives.transferToInterpreterAndInvalidate(); lengthNode = insert(InputLengthNode.create()); } - return lengthNode.execute(input, getEncoding()); + return lengthNode.execute(this, input, getEncoding()); } public final int inputRead(TruffleString input, int i) { @@ -94,7 +94,7 @@ public final int inputRead(TruffleString input, int i) { CompilerDirectives.transferToInterpreterAndInvalidate(); charAtNode = insert(InputReadNode.create()); } - return charAtNode.execute(input, i, getEncoding()); + return charAtNode.execute(this, input, i, getEncoding()); } private RegexResult adjustIndexAndRun(VirtualFrame frame, TruffleString input, int fromIndex) { diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexObject.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexObject.java index 8168f4f7f552..e7e89b85d0e8 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexObject.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexObject.java @@ -46,6 +46,8 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.ReportPolymorphism; @@ -302,6 +304,7 @@ Object invokeMember(String member, Object[] args, } @ImportStatic(RegexObject.class) + @GenerateInline(false) @GenerateUncached abstract static class InvokeCacheNode extends Node { @@ -312,7 +315,7 @@ abstract Object execute(String symbol, RegexObject receiver, Object input, int f @Specialization(guards = {"symbol == cachedSymbol", "cachedSymbol.equals(PROP_EXEC)"}, limit = N_METHODS) Object execIdentity(String symbol, RegexObject receiver, Object input, int fromIndex, @Cached("symbol") String cachedSymbol, - @Cached ExecCompiledRegexNode execNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { + @Cached @Shared ExecCompiledRegexNode execNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { return execNode.execute(receiver.getExecCallTarget(), input, fromIndex); } @@ -320,7 +323,7 @@ Object execIdentity(String symbol, RegexObject receiver, Object input, int fromI @Specialization(guards = {"symbol.equals(cachedSymbol)", "cachedSymbol.equals(PROP_EXEC)"}, limit = N_METHODS, replaces = "execIdentity") Object execEquals(String symbol, RegexObject receiver, Object input, int fromIndex, @Cached("symbol") String cachedSymbol, - @Cached ExecCompiledRegexNode execNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { + @Cached @Shared ExecCompiledRegexNode execNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { return execNode.execute(receiver.getExecCallTarget(), input, fromIndex); } @@ -328,22 +331,22 @@ Object execEquals(String symbol, RegexObject receiver, Object input, int fromInd @Specialization(guards = {"symbol == cachedSymbol", "cachedSymbol.equals(PROP_EXEC_BOOLEAN)"}, limit = N_METHODS) boolean execBooleanIdentity(String symbol, RegexObject receiver, Object input, int fromIndex, @Cached("symbol") String cachedSymbol, - @Cached ExecCompiledRegexNode execNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { - return execNode.execute(receiver.getExecBooleanCallTarget(), input, fromIndex) != RegexResult.getNoMatchInstance(); + @Cached @Shared ExecCompiledRegexNode execBoolNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { + return execBoolNode.execute(receiver.getExecBooleanCallTarget(), input, fromIndex) != RegexResult.getNoMatchInstance(); } @SuppressWarnings("unused") @Specialization(guards = {"symbol.equals(cachedSymbol)", "cachedSymbol.equals(PROP_EXEC_BOOLEAN)"}, limit = N_METHODS, replaces = "execBooleanIdentity") boolean execBooleanEquals(String symbol, RegexObject receiver, Object input, int fromIndex, @Cached("symbol") String cachedSymbol, - @Cached ExecCompiledRegexNode execNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { - return execNode.execute(receiver.getExecBooleanCallTarget(), input, fromIndex) != RegexResult.getNoMatchInstance(); + @Cached @Shared ExecCompiledRegexNode execBoolNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException { + return execBoolNode.execute(receiver.getExecBooleanCallTarget(), input, fromIndex) != RegexResult.getNoMatchInstance(); } @ReportPolymorphism.Megamorphic @Specialization(replaces = {"execEquals", "execBooleanEquals"}) static Object invokeGeneric(String symbol, RegexObject receiver, Object input, int fromIndex, - @Cached ExecCompiledRegexNode execNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException, UnknownIdentifierException { + @Cached @Shared ExecCompiledRegexNode execNode) throws UnsupportedMessageException, ArityException, UnsupportedTypeException, UnknownIdentifierException { switch (symbol) { case PROP_EXEC: return execNode.execute(receiver.getExecCallTarget(), input, fromIndex); @@ -441,6 +444,7 @@ public String toString() { } @ImportStatic(RegexObject.class) + @GenerateInline(false) @GenerateUncached abstract static class ExecCompiledRegexNode extends Node { diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/LiteralRegexEngine.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/LiteralRegexEngine.java index be9528caf7f9..5ef086763387 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/LiteralRegexEngine.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/LiteralRegexEngine.java @@ -102,18 +102,18 @@ private static LiteralRegexExecNode createLiteralNode(RegexLanguage language, Re } if (caret) { if (dollar) { - return LiteralRegexExecNode.create(language, ast, new Equals(preCalcResultVisitor)); + return LiteralRegexExecNode.create(language, ast, LiteralRegexExecNodeGen.EqualsNodeGen.create(preCalcResultVisitor)); } - return LiteralRegexExecNode.create(language, ast, new StartsWith(preCalcResultVisitor)); + return LiteralRegexExecNode.create(language, ast, LiteralRegexExecNodeGen.StartsWithNodeGen.create(preCalcResultVisitor)); } if (dollar) { - return LiteralRegexExecNode.create(language, ast, new EndsWith(preCalcResultVisitor, ast.getFlags().isSticky())); + return LiteralRegexExecNode.create(language, ast, LiteralRegexExecNodeGen.EndsWithNodeGen.create(preCalcResultVisitor, ast.getFlags().isSticky())); } if (ast.getFlags().isSticky()) { - return LiteralRegexExecNode.create(language, ast, new RegionMatches(preCalcResultVisitor)); + return LiteralRegexExecNode.create(language, ast, LiteralRegexExecNodeGen.RegionMatchesNodeGen.create(preCalcResultVisitor)); } if (preCalcResultVisitor.getLiteral().encodedLength() <= 64) { - return LiteralRegexExecNode.create(language, ast, new IndexOfString(preCalcResultVisitor)); + return LiteralRegexExecNode.create(language, ast, LiteralRegexExecNodeGen.IndexOfStringNodeGen.create(preCalcResultVisitor)); } return null; } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/LiteralRegexExecNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/LiteralRegexExecNode.java index 774beeddac98..606360304788 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/LiteralRegexExecNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/LiteralRegexExecNode.java @@ -241,9 +241,7 @@ protected String getLiteral() { } } - public static final class IndexOfString extends NonEmptyLiteralRegexExecNode { - - @Child InputIndexOfStringNode indexOfStringNode = InputIndexOfStringNode.create(); + public abstract static class IndexOfString extends NonEmptyLiteralRegexExecNode { public IndexOfString(PreCalcResultVisitor preCalcResultVisitor) { super(preCalcResultVisitor); @@ -254,9 +252,10 @@ protected String getImplName() { return "indexOfString"; } - @Override - protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Encoding encoding) { - int start = indexOfStringNode.execute(input, fromIndex, inputLength(input), literal.getLiteralContent(), literal.getMaskContent(), encoding); + @Specialization + protected RegexResult run(TruffleString input, int fromIndex, Encodings.Encoding encoding, + @Cached(inline = true) InputIndexOfStringNode indexOfStringNode) { + int start = indexOfStringNode.execute(this, input, fromIndex, inputLength(input), literal.getLiteralContent(), literal.getMaskContent(), encoding); if (start < 0) { return RegexResult.getNoMatchInstance(); } @@ -264,9 +263,7 @@ protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Enco } } - public static final class StartsWith extends NonEmptyLiteralRegexExecNode { - - @Child InputStartsWithNode startsWithNode = InputStartsWithNode.create(); + public abstract static class StartsWith extends NonEmptyLiteralRegexExecNode { public StartsWith(PreCalcResultVisitor preCalcResultVisitor) { super(preCalcResultVisitor); @@ -277,9 +274,10 @@ protected String getImplName() { return "startsWith"; } - @Override - protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Encoding encoding) { - if (fromIndex == 0 && startsWithNode.execute(input, literal.getLiteralContent(), literal.getMaskContent(), encoding)) { + @Specialization + protected RegexResult run(TruffleString input, int fromIndex, Encodings.Encoding encoding, + @Cached(inline = true) InputStartsWithNode startsWithNode) { + if (fromIndex == 0 && startsWithNode.execute(this, input, literal.getLiteralContent(), literal.getMaskContent(), encoding)) { return createFromStart(0); } else { return RegexResult.getNoMatchInstance(); @@ -287,10 +285,9 @@ protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Enco } } - public static final class EndsWith extends NonEmptyLiteralRegexExecNode { + public abstract static class EndsWith extends NonEmptyLiteralRegexExecNode { private final boolean sticky; - @Child InputEndsWithNode endsWithNode = InputEndsWithNode.create(); public EndsWith(PreCalcResultVisitor preCalcResultVisitor, boolean sticky) { super(preCalcResultVisitor); @@ -302,10 +299,11 @@ protected String getImplName() { return "endsWith"; } - @Override - protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Encoding encoding) { + @Specialization + protected RegexResult run(TruffleString input, int fromIndex, Encodings.Encoding encoding, + @Cached(inline = true) InputEndsWithNode endsWithNode) { int matchStart = inputLength(input) - literalLength; - if ((sticky ? fromIndex == matchStart : fromIndex <= matchStart) && endsWithNode.execute(input, literal.getLiteralContent(), literal.getMaskContent(), encoding)) { + if ((sticky ? fromIndex == matchStart : fromIndex <= matchStart) && endsWithNode.execute(this, input, literal.getLiteralContent(), literal.getMaskContent(), encoding)) { return createFromEnd(inputLength(input)); } else { return RegexResult.getNoMatchInstance(); @@ -313,9 +311,7 @@ protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Enco } } - public static final class Equals extends NonEmptyLiteralRegexExecNode { - - @Child InputEqualsNode equalsNode = InputEqualsNode.create(); + public abstract static class Equals extends NonEmptyLiteralRegexExecNode { public Equals(PreCalcResultVisitor preCalcResultVisitor) { super(preCalcResultVisitor); @@ -326,9 +322,10 @@ protected String getImplName() { return "equals"; } - @Override - protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Encoding encoding) { - if (fromIndex == 0 && equalsNode.execute(input, literal.getLiteralContent(), literal.getMaskContent(), encoding)) { + @Specialization + protected RegexResult run(TruffleString input, int fromIndex, Encodings.Encoding encoding, + @Cached(inline = true) InputEqualsNode equalsNode) { + if (fromIndex == 0 && equalsNode.execute(this, input, literal.getLiteralContent(), literal.getMaskContent(), encoding)) { return createFromStart(0); } else { return RegexResult.getNoMatchInstance(); @@ -336,9 +333,7 @@ protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Enco } } - public static final class RegionMatches extends NonEmptyLiteralRegexExecNode { - - @Child InputRegionMatchesNode regionMatchesNode = InputRegionMatchesNode.create(); + public abstract static class RegionMatches extends NonEmptyLiteralRegexExecNode { public RegionMatches(PreCalcResultVisitor preCalcResultVisitor) { super(preCalcResultVisitor); @@ -349,9 +344,10 @@ protected String getImplName() { return "regionMatches"; } - @Override - protected RegexResult execute(TruffleString input, int fromIndex, Encodings.Encoding encoding) { - if (regionMatchesNode.execute(input, fromIndex, literal.getLiteralContent(), 0, literalLength, literal.getMaskContent(), encoding)) { + @Specialization + protected RegexResult run(TruffleString input, int fromIndex, Encodings.Encoding encoding, + @Cached(inline = true) InputRegionMatchesNode regionMatchesNode) { + if (regionMatchesNode.execute(this, input, fromIndex, literal.getLiteralContent(), 0, literalLength, literal.getMaskContent(), encoding)) { return createFromStart(fromIndex); } else { return RegexResult.getNoMatchInstance(); diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/package-info.java deleted file mode 100644 index d7f750b69c0f..000000000000 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/package-info.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -//TODO GR-42839 fix warnings -@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) -package com.oracle.truffle.regex.literal; - -import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/package-info.java deleted file mode 100644 index 96724d2e95ea..000000000000 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/package-info.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -//TODO GR-42839 fix warnings -@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) -package com.oracle.truffle.regex; - -import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/RegexResult.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/RegexResult.java index 592b683ec114..9cd5a58153d5 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/RegexResult.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/RegexResult.java @@ -47,6 +47,8 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.ReportPolymorphism; @@ -59,7 +61,7 @@ import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.regex.AbstractConstantKeysObject; import com.oracle.truffle.regex.AbstractRegexObject; @@ -239,7 +241,7 @@ static RegexResultGetEndMethod getEndEquals(RegexResult receiver, String symbol, @Specialization(guards = {"symbol == cachedSymbol", "cachedSymbol.equals(PROP_LAST_GROUP)"}, limit = "2") static int lastGroupIdentity(RegexResult receiver, String symbol, @Cached("symbol") String cachedSymbol, - @Cached RegexResultGetLastGroupNode getLastGroupNode) { + @Cached @Shared RegexResultGetLastGroupNode getLastGroupNode) { return getLastGroupNode.execute(receiver); } @@ -247,14 +249,14 @@ static int lastGroupIdentity(RegexResult receiver, String symbol, @Specialization(guards = {"symbol.equals(cachedSymbol)", "cachedSymbol.equals(PROP_LAST_GROUP)"}, limit = "2", replaces = "lastGroupIdentity") static int lastGroupEquals(RegexResult receiver, String symbol, @Cached("symbol") String cachedSymbol, - @Cached RegexResultGetLastGroupNode getLastGroupNode) { + @Cached @Shared RegexResultGetLastGroupNode getLastGroupNode) { return getLastGroupNode.execute(receiver); } @ReportPolymorphism.Megamorphic @Specialization(replaces = {"isMatchEquals", "getStartEquals", "getEndEquals"}) static Object readGeneric(RegexResult receiver, String symbol, - @Cached RegexResultGetLastGroupNode getLastGroupNode) throws UnknownIdentifierException { + @Cached @Shared RegexResultGetLastGroupNode getLastGroupNode) throws UnknownIdentifierException { switch (symbol) { case PROP_IS_MATCH: return receiver != getNoMatchInstance(); @@ -428,47 +430,48 @@ Object invokeMember(String member, Object[] args, @ImportStatic(RegexResult.class) @GenerateUncached + @GenerateInline(false) abstract static class InvokeCacheNode extends Node { abstract Object execute(RegexResult receiver, String symbol, int groupNumber) throws UnknownIdentifierException; @SuppressWarnings("unused") @Specialization(guards = {"symbol == cachedSymbol", "cachedSymbol.equals(PROP_GET_START)"}, limit = "2") - Object getStartIdentity(RegexResult receiver, String symbol, int groupNumber, + static Object getStartIdentity(RegexResult receiver, String symbol, int groupNumber, @Cached("symbol") String cachedSymbol, - @Cached RegexResultGetStartNode getStartNode) { + @Cached @Shared RegexResultGetStartNode getStartNode) { return getStartNode.execute(receiver, groupNumber); } @SuppressWarnings("unused") @Specialization(guards = {"symbol.equals(cachedSymbol)", "cachedSymbol.equals(PROP_GET_START)"}, limit = "2", replaces = "getStartIdentity") - Object getStartEquals(RegexResult receiver, String symbol, int groupNumber, + static Object getStartEquals(RegexResult receiver, String symbol, int groupNumber, @Cached("symbol") String cachedSymbol, - @Cached RegexResultGetStartNode getStartNode) { + @Cached @Shared RegexResultGetStartNode getStartNode) { return getStartNode.execute(receiver, groupNumber); } @SuppressWarnings("unused") @Specialization(guards = {"symbol == cachedSymbol", "cachedSymbol.equals(PROP_GET_END)"}, limit = "2") - Object getEndIdentity(RegexResult receiver, String symbol, int groupNumber, + static Object getEndIdentity(RegexResult receiver, String symbol, int groupNumber, @Cached("symbol") String cachedSymbol, - @Cached RegexResultGetEndNode getEndNode) { + @Cached @Shared RegexResultGetEndNode getEndNode) { return getEndNode.execute(receiver, groupNumber); } @SuppressWarnings("unused") @Specialization(guards = {"symbol.equals(cachedSymbol)", "cachedSymbol.equals(PROP_GET_END)"}, limit = "2", replaces = "getEndIdentity") - Object getEndEquals(RegexResult receiver, String symbol, int groupNumber, + static Object getEndEquals(RegexResult receiver, String symbol, int groupNumber, @Cached("symbol") String cachedSymbol, - @Cached RegexResultGetEndNode getEndNode) { + @Cached @Shared RegexResultGetEndNode getEndNode) { return getEndNode.execute(receiver, groupNumber); } @ReportPolymorphism.Megamorphic @Specialization(replaces = {"getStartEquals", "getEndEquals"}) static Object invokeGeneric(RegexResult receiver, String symbol, int groupNumber, - @Cached RegexResultGetStartNode getStartNode, - @Cached RegexResultGetEndNode getEndNode) throws UnknownIdentifierException { + @Cached @Shared RegexResultGetStartNode getStartNode, + @Cached @Shared RegexResultGetEndNode getEndNode) throws UnknownIdentifierException { switch (symbol) { case PROP_GET_START: return getStartNode.execute(receiver, groupNumber); @@ -493,65 +496,64 @@ public void debugForceEvaluation() { private static final int INVALID_RESULT_INDEX = -1; + @GenerateInline(false) @GenerateUncached abstract static class RegexResultGetEndNode extends Node { abstract int execute(Object receiver, int groupNumber); @Specialization - static int doResult(RegexResult receiver, int groupNumber, - @Cached BranchProfile lazyProfile, + int doResult(RegexResult receiver, int groupNumber, + @Cached InlinedBranchProfile lazyProfile, @Cached DispatchNode getIndicesCall) { if (receiver.result == null) { assert receiver.lazyCallTarget != null; - lazyProfile.enter(); - getIndicesCall.execute(receiver.lazyCallTarget, receiver); + lazyProfile.enter(this); + getIndicesCall.execute(this, receiver.lazyCallTarget, receiver); } int i = Group.groupNumberToBoundaryIndexEnd(groupNumber); return i < 0 || i >= receiver.result.length ? INVALID_RESULT_INDEX : receiver.result[i]; } } + @GenerateInline(false) @GenerateUncached public abstract static class RegexResultGetStartNode extends Node { public abstract int execute(Object receiver, int groupNumber); @Specialization - static int doResult(RegexResult receiver, int groupNumber, - @Cached BranchProfile lazyProfile, + int doResult(RegexResult receiver, int groupNumber, + @Cached InlinedBranchProfile lazyProfile, @Cached DispatchNode getIndicesCall) { if (receiver.result == null) { assert receiver.lazyCallTarget != null; - lazyProfile.enter(); - getIndicesCall.execute(receiver.lazyCallTarget, receiver); + lazyProfile.enter(this); + getIndicesCall.execute(this, receiver.lazyCallTarget, receiver); } int i = Group.groupNumberToBoundaryIndexStart(groupNumber); return i < 0 || i >= receiver.result.length ? INVALID_RESULT_INDEX : receiver.result[i]; } - public static RegexResultGetStartNode create() { - return RegexResultFactory.RegexResultGetStartNodeGen.create(); - } - public static RegexResultGetStartNode getUncached() { return RegexResultFactory.RegexResultGetStartNodeGen.getUncached(); } } + @GenerateInline(false) @GenerateUncached public abstract static class RegexResultGetLastGroupNode extends Node { public abstract int execute(Object receiver); @Specialization - static int doResult(RegexResult receiver, - @Cached BranchProfile lazyProfile, + int doResult(RegexResult receiver, + @Cached InlinedBranchProfile lazyProfile, @Cached DispatchNode getIndicesCall) { if (receiver.result == null) { assert receiver.lazyCallTarget != null; - lazyProfile.enter(); - getIndicesCall.execute(receiver.lazyCallTarget, receiver); + lazyProfile.enter(this); + getIndicesCall.execute(this, receiver.lazyCallTarget, receiver); } return receiver.getLastGroup(); } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/package-info.java deleted file mode 100644 index 2f67873c98ab..000000000000 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/package-info.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -//TODO GR-42839 fix warnings -@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) -package com.oracle.truffle.regex.result; - -import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/DispatchNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/DispatchNode.java index 0317ab1716f9..f140856b9aa0 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/DispatchNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/DispatchNode.java @@ -42,6 +42,8 @@ import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.DirectCallNode; @@ -49,13 +51,15 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.regex.result.RegexResult; +@GenerateInline +@GenerateCached(false) @GenerateUncached public abstract class DispatchNode extends Node { - public abstract Object execute(CallTarget receiver, RegexResult result); + public abstract Object execute(Node node, CallTarget receiver, RegexResult result); @SuppressWarnings("unused") - @Specialization(guards = {"target == cachedTarget"}) + @Specialization(guards = {"target == cachedTarget"}, limit = "4") static Object doDirect(CallTarget target, RegexResult result, @Cached("target") CallTarget cachedTarget, @Cached("create(cachedTarget)") DirectCallNode callNode) { @@ -64,7 +68,7 @@ static Object doDirect(CallTarget target, RegexResult result, @Specialization(replaces = "doDirect") static Object doIndirect(CallTarget target, RegexResult result, - @Cached IndirectCallNode callNode) { + @Cached(inline = false) IndirectCallNode callNode) { return callNode.call(target, result); } } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ExpectStringNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ExpectStringNode.java index 06ee221afeaa..434664347156 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ExpectStringNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ExpectStringNode.java @@ -43,6 +43,7 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -52,6 +53,7 @@ import com.oracle.truffle.api.strings.TruffleString; @GenerateUncached +@GenerateInline(false) public abstract class ExpectStringNode extends Node { public abstract TruffleString execute(Object arg, TruffleString.Encoding encoding); diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ToIntNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ToIntNode.java index 2e3cd6ad4b60..40d5d6db2b47 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ToIntNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ToIntNode.java @@ -41,6 +41,7 @@ package com.oracle.truffle.regex.runtime.nodes; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -50,6 +51,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateUncached +@GenerateInline(false) public abstract class ToIntNode extends Node { public abstract int execute(Object arg) throws UnsupportedTypeException; @@ -68,8 +70,4 @@ static int doBoxed(Object arg, @CachedLibrary("arg") InteropLibrary args) throws throw UnsupportedTypeException.create(new Object[]{arg}); } } - - public static ToIntNode create() { - return ToIntNodeGen.create(); - } } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ToLongNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ToLongNode.java index c58ef96b7350..bf9221ebba41 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ToLongNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/ToLongNode.java @@ -41,6 +41,7 @@ package com.oracle.truffle.regex.runtime.nodes; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropLibrary; @@ -50,6 +51,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateUncached +@GenerateInline(false) public abstract class ToLongNode extends Node { public abstract long execute(Object arg) throws UnsupportedTypeException; @@ -73,8 +75,4 @@ static long doBoxed(Object arg, @CachedLibrary("arg") InteropLibrary args) throw throw UnsupportedTypeException.create(new Object[]{arg}); } } - - public static ToLongNode create() { - return ToLongNodeGen.create(); - } } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/package-info.java deleted file mode 100644 index 9027ed06d7fc..000000000000 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/package-info.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -//TODO GR-42839 fix warnings -@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) -package com.oracle.truffle.regex.runtime.nodes; - -import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/TRegexExecutorNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/TRegexExecutorNode.java index 221cdad5446e..c4a4d33aae0e 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/TRegexExecutorNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/TRegexExecutorNode.java @@ -120,7 +120,7 @@ public int getInputLength(TRegexExecutorLocals locals) { CompilerDirectives.transferToInterpreterAndInvalidate(); lengthNode = insert(InputLengthNode.create()); } - return lengthNode.execute(locals.getInput(), getEncoding()); + return lengthNode.execute(this, locals.getInput(), getEncoding()); } /** @@ -273,7 +273,7 @@ public int inputReadRaw(TRegexExecutorLocals locals, int index, boolean forward) CompilerDirectives.transferToInterpreterAndInvalidate(); charAtNode = insert(InputReadNode.create()); } - return charAtNode.execute(locals.getInput(), forward ? index : index - 1, getEncoding()); + return charAtNode.execute(this, locals.getInput(), forward ? index : index - 1, getEncoding()); } public void inputAdvance(TRegexExecutorLocals locals) { diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/DFAFindInnerLiteralStateNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/DFAFindInnerLiteralStateNode.java index 143912a34735..54b0fbef41e7 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/DFAFindInnerLiteralStateNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/DFAFindInnerLiteralStateNode.java @@ -67,7 +67,7 @@ public DFAAbstractStateNode createNodeSplitCopy(short copyID) { } int executeInnerLiteralSearch(TRegexDFAExecutorLocals locals, TRegexDFAExecutorNode executor) { - return executor.getIndexOfStringNode().execute(locals.getInput(), locals.getIndex(), executor.getMaxIndex(locals), innerLiteral.getLiteralContent(), + return executor.getIndexOfStringNode().execute(executor, locals.getInput(), locals.getIndex(), executor.getMaxIndex(locals), innerLiteral.getLiteralContent(), innerLiteral.getMaskContent(), executor.getEncoding()); } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/DFAStateNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/DFAStateNode.java index 1cef5c9ac628..a402c5faade9 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/DFAStateNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/DFAStateNode.java @@ -44,6 +44,7 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.regex.tregex.nodes.TRegexExecutorLocals; import com.oracle.truffle.regex.tregex.nodes.TRegexExecutorNode; @@ -183,7 +184,7 @@ void beforeFindSuccessor(TRegexDFAExecutorLocals locals, TRegexDFAExecutorNode e /** * Gets called after every call to - * {@link InputIndexOfNode#execute(TruffleString, int, int, TruffleString.CodePointSet, Encodings.Encoding)}, + * {@link InputIndexOfNode#execute(Node, TruffleString, int, int, TruffleString.CodePointSet, Encodings.Encoding)}, * which we call an {@code indexOf}-operation. * * @param preLoopIndex the starting index of the {@code indexOf}-operation. diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/TRegexDFAExecutorNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/TRegexDFAExecutorNode.java index f1455be972ce..271a4fb6b134 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/TRegexDFAExecutorNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/dfa/TRegexDFAExecutorNode.java @@ -395,7 +395,7 @@ public Object execute(VirtualFrame frame, final TRegexExecutorLocals abstractLoc CompilerAsserts.partialEvaluationConstant(indexOfNodeId); CompilerAsserts.partialEvaluationConstant(indexOfNode); CompilerAsserts.partialEvaluationConstant(indexOfParameter); - int indexOfResult = indexOfNode.execute(locals.getInput(), locals.getIndex(), getMaxIndex(locals), indexOfParameter, getEncoding()); + int indexOfResult = indexOfNode.execute(this, locals.getInput(), locals.getIndex(), getMaxIndex(locals), indexOfParameter, getEncoding()); int postLoopIndex = indexOfResult < 0 ? getMaxIndex(locals) : indexOfResult; state.afterIndexOf(locals, this, locals.getIndex(), postLoopIndex, codeRange); assert locals.getIndex() == postLoopIndex; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputEndsWithNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputEndsWithNode.java index 1c0e5f8468fd..b8ec04a8d2bb 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputEndsWithNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputEndsWithNode.java @@ -43,22 +43,20 @@ import static com.oracle.truffle.regex.tregex.string.Encodings.Encoding; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; +@GenerateInline public abstract class InputEndsWithNode extends Node { - - public static InputEndsWithNode create() { - return InputEndsWithNodeGen.create(); - } - - public abstract boolean execute(TruffleString input, TruffleString suffix, TruffleString.WithMask mask, Encoding encoding); + public abstract boolean execute(Node node, TruffleString input, TruffleString suffix, TruffleString.WithMask mask, Encoding encoding); @Specialization(guards = "mask == null") public boolean doTString(TruffleString input, TruffleString suffix, @SuppressWarnings("unused") TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.RegionEqualByteIndexNode regionEqualsNode) { + @Cached(inline = false) @Shared TruffleString.RegionEqualByteIndexNode regionEqualsNode) { int len1 = input.byteLength(encoding.getTStringEncoding()); int len2 = suffix.byteLength(encoding.getTStringEncoding()); return len1 >= len2 && regionEqualsNode.execute(input, len1 - len2, suffix, 0, len2, encoding.getTStringEncoding()); @@ -66,7 +64,7 @@ public boolean doTString(TruffleString input, TruffleString suffix, @SuppressWar @Fallback public boolean doTStringMask(TruffleString input, TruffleString suffix, TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.RegionEqualByteIndexNode regionEqualsNode) { + @Cached(inline = false) @Shared TruffleString.RegionEqualByteIndexNode regionEqualsNode) { int len1 = input.byteLength(encoding.getTStringEncoding()); int len2 = suffix.byteLength(encoding.getTStringEncoding()); return len1 >= len2 && regionEqualsNode.execute(input, len1 - len2, mask, 0, len2, encoding.getTStringEncoding()); diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputEqualsNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputEqualsNode.java index 42ac3ad96192..d70c03013305 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputEqualsNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputEqualsNode.java @@ -43,22 +43,21 @@ import static com.oracle.truffle.regex.tregex.string.Encodings.Encoding; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; +@GenerateInline public abstract class InputEqualsNode extends Node { - public static InputEqualsNode create() { - return InputEqualsNodeGen.create(); - } - - public abstract boolean execute(TruffleString input, TruffleString string, TruffleString.WithMask mask, Encoding encoding); + public abstract boolean execute(Node node, TruffleString input, TruffleString string, TruffleString.WithMask mask, Encoding encoding); @Specialization(guards = "mask == null") public boolean doTString(TruffleString input, TruffleString string, @SuppressWarnings("unused") TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.RegionEqualByteIndexNode equalsNode) { + @Cached(inline = false) @Shared TruffleString.RegionEqualByteIndexNode equalsNode) { int len1 = input.byteLength(encoding.getTStringEncoding()); int len2 = string.byteLength(encoding.getTStringEncoding()); return len1 == len2 && equalsNode.execute(input, 0, string, 0, len2, encoding.getTStringEncoding()); @@ -66,7 +65,7 @@ public boolean doTString(TruffleString input, TruffleString string, @SuppressWar @Fallback public boolean doTStringMask(TruffleString input, TruffleString string, TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.RegionEqualByteIndexNode equalsNode) { + @Cached(inline = false) @Shared TruffleString.RegionEqualByteIndexNode equalsNode) { int len1 = input.byteLength(encoding.getTStringEncoding()); int len2 = string.byteLength(encoding.getTStringEncoding()); return len1 == len2 && equalsNode.execute(input, 0, mask, 0, len2, encoding.getTStringEncoding()); diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputIndexOfNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputIndexOfNode.java index 30c8f2bd5c02..6dddb6d187b7 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputIndexOfNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputIndexOfNode.java @@ -42,22 +42,26 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.regex.tregex.string.Encodings.Encoding; +@GenerateInline public abstract class InputIndexOfNode extends Node { - public abstract int execute(TruffleString input, int fromIndex, int maxIndex, TruffleString.CodePointSet codePointSet, Encoding encoding); + public abstract int execute(Node node, TruffleString input, int fromIndex, int maxIndex, TruffleString.CodePointSet codePointSet, Encoding encoding); @Specialization public int doTString(TruffleString input, int fromIndex, int maxIndex, TruffleString.CodePointSet codePointSet, Encoding encoding, - @Cached TruffleString.ByteIndexOfCodePointSetNode indexOfNode) { + @Cached(inline = false) TruffleString.ByteIndexOfCodePointSetNode indexOfNode) { CompilerAsserts.partialEvaluationConstant(codePointSet); return indexOfNode.execute(input, fromIndex << encoding.getStride(), maxIndex << encoding.getStride(), codePointSet) >> encoding.getStride(); } + @NeverDefault public static InputIndexOfNode create() { return InputIndexOfNodeGen.create(); } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputIndexOfStringNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputIndexOfStringNode.java index d9b6a5f5f9df..98b9a1332400 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputIndexOfStringNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputIndexOfStringNode.java @@ -43,22 +43,22 @@ import static com.oracle.truffle.regex.tregex.string.Encodings.Encoding; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; +@GenerateInline public abstract class InputIndexOfStringNode extends Node { - public static InputIndexOfStringNode create() { - return InputIndexOfStringNodeGen.create(); - } - - public abstract int execute(TruffleString input, int fromIndex, int maxIndex, TruffleString match, TruffleString.WithMask mask, Encoding encoding); + public abstract int execute(Node node, TruffleString input, int fromIndex, int maxIndex, TruffleString match, TruffleString.WithMask mask, Encoding encoding); @Specialization(guards = "mask == null") public int doTString(TruffleString input, int fromIndex, int maxIndex, TruffleString match, @SuppressWarnings("unused") TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.ByteIndexOfStringNode indexOfStringNode) { + @Cached(inline = false) @Shared TruffleString.ByteIndexOfStringNode indexOfStringNode) { int fromByteIndex = fromIndex << encoding.getStride(); if (fromByteIndex >= input.byteLength(encoding.getTStringEncoding())) { return -1; @@ -68,11 +68,16 @@ public int doTString(TruffleString input, int fromIndex, int maxIndex, TruffleSt @Fallback public int doTStringMask(TruffleString input, int fromIndex, int maxIndex, @SuppressWarnings("unused") TruffleString match, TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.ByteIndexOfStringNode indexOfStringNode) { + @Cached(inline = false) @Shared TruffleString.ByteIndexOfStringNode indexOfStringNode) { int fromByteIndex = fromIndex << encoding.getStride(); if (fromByteIndex >= input.byteLength(encoding.getTStringEncoding())) { return -1; } return indexOfStringNode.execute(input, mask, fromByteIndex, maxIndex << encoding.getStride(), encoding.getTStringEncoding()) >> encoding.getStride(); } + + @NeverDefault + public static InputIndexOfStringNode create() { + return InputIndexOfStringNodeGen.create(); + } } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputLengthNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputLengthNode.java index baa7823afd5e..e150d1af7360 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputLengthNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputLengthNode.java @@ -40,23 +40,27 @@ */ package com.oracle.truffle.regex.tregex.nodes.input; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.regex.tregex.string.Encodings; @GenerateUncached +@GenerateInline public abstract class InputLengthNode extends Node { - public static InputLengthNode create() { - return InputLengthNodeGen.create(); - } - - public abstract int execute(TruffleString input, Encodings.Encoding encoding); + public abstract int execute(Node node, TruffleString input, Encodings.Encoding encoding); @Specialization static int doTString(TruffleString input, Encodings.Encoding encoding) { return input.byteLength(encoding.getTStringEncoding()) >> encoding.getStride(); } + + @NeverDefault + public static InputLengthNode create() { + return InputLengthNodeGen.create(); + } } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputReadNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputReadNode.java index 068e21b44b93..1bf801e9f66a 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputReadNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputReadNode.java @@ -41,8 +41,10 @@ package com.oracle.truffle.regex.tregex.nodes.input; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -50,30 +52,32 @@ import com.oracle.truffle.regex.tregex.string.Encodings.Encoding; @GenerateUncached +@GenerateInline @ImportStatic(Encodings.class) public abstract class InputReadNode extends Node { - public static InputReadNode create() { - return InputReadNodeGen.create(); - } - - public abstract int execute(TruffleString input, int index, Encoding encoding); + public abstract int execute(Node node, TruffleString input, int index, Encoding encoding); @Specialization(guards = {"encoding != UTF_16", "encoding != UTF_32", "encoding != UTF_16_RAW"}) static int doTStringUTF8(TruffleString input, int index, Encoding encoding, - @Cached TruffleString.ReadByteNode readRawNode) { + @Cached(inline = false) TruffleString.ReadByteNode readRawNode) { return readRawNode.execute(input, index, encoding.getTStringEncoding()); } @Specialization(guards = "encoding == UTF_16 || encoding == UTF_16_RAW") static int doTStringUTF16(TruffleString input, int index, @SuppressWarnings("unused") Encoding encoding, - @Cached TruffleString.ReadCharUTF16Node readRawNode) { + @Cached(inline = false) TruffleString.ReadCharUTF16Node readRawNode) { return readRawNode.execute(input, index); } @Specialization(guards = "encoding == UTF_32") static int doTStringUTF32(TruffleString input, int index, @SuppressWarnings("unused") Encoding encoding, - @Cached TruffleString.CodePointAtIndexNode readRawNode) { + @Cached(inline = false) TruffleString.CodePointAtIndexNode readRawNode) { return readRawNode.execute(input, index, TruffleString.Encoding.UTF_32); } + + @NeverDefault + public static InputReadNode create() { + return InputReadNodeGen.create(); + } } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputRegionMatchesNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputRegionMatchesNode.java index ff9a02f98e23..f4106c58626c 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputRegionMatchesNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputRegionMatchesNode.java @@ -43,22 +43,22 @@ import static com.oracle.truffle.regex.tregex.string.Encodings.Encoding; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; +@GenerateInline public abstract class InputRegionMatchesNode extends Node { - public static InputRegionMatchesNode create() { - return InputRegionMatchesNodeGen.create(); - } - - public abstract boolean execute(TruffleString input, int fromIndex1, TruffleString match, int fromIndex2, int length, TruffleString.WithMask mask, Encoding encoding); + public abstract boolean execute(Node node, TruffleString input, int fromIndex1, TruffleString match, int fromIndex2, int length, TruffleString.WithMask mask, Encoding encoding); @Specialization(guards = "mask == null") public boolean doTString(TruffleString input, int fromIndex1, TruffleString match, int fromIndex2, int length, @SuppressWarnings("unused") TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.RegionEqualByteIndexNode regionEqualsNode) { + @Cached(inline = false) @Shared TruffleString.RegionEqualByteIndexNode regionEqualsNode) { int fromByteIndexA = fromIndex1 << encoding.getStride(); int fromByteIndexB = fromIndex2 << encoding.getStride(); int byteLength = length << encoding.getStride(); @@ -68,11 +68,16 @@ public boolean doTString(TruffleString input, int fromIndex1, TruffleString matc @Fallback public boolean doTStringMask(TruffleString input, int fromIndex1, @SuppressWarnings("unused") TruffleString match, int fromIndex2, int length, TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.RegionEqualByteIndexNode regionEqualsNode) { + @Cached(inline = false) @Shared TruffleString.RegionEqualByteIndexNode regionEqualsNode) { int fromByteIndexA = fromIndex1 << encoding.getStride(); int fromByteIndexB = fromIndex2 << encoding.getStride(); int byteLength = length << encoding.getStride(); return input.byteLength(encoding.getTStringEncoding()) >= fromByteIndexA + byteLength && regionEqualsNode.execute(input, fromByteIndexA, mask, fromByteIndexB, byteLength, encoding.getTStringEncoding()); } + + @NeverDefault + public static InputRegionMatchesNode create() { + return InputRegionMatchesNodeGen.create(); + } } diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputStartsWithNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputStartsWithNode.java index a0d9f7e2531e..5c9b285f2641 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputStartsWithNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/InputStartsWithNode.java @@ -43,22 +43,21 @@ import static com.oracle.truffle.regex.tregex.string.Encodings.Encoding; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; +@GenerateInline public abstract class InputStartsWithNode extends Node { - public static InputStartsWithNode create() { - return InputStartsWithNodeGen.create(); - } - - public abstract boolean execute(TruffleString input, TruffleString prefix, TruffleString.WithMask mask, Encoding encoding); + public abstract boolean execute(Node node, TruffleString input, TruffleString prefix, TruffleString.WithMask mask, Encoding encoding); @Specialization(guards = "mask == null") public boolean doTString(TruffleString input, TruffleString prefix, @SuppressWarnings("unused") TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.RegionEqualByteIndexNode regionEqualsNode) { + @Cached(inline = false) @Shared TruffleString.RegionEqualByteIndexNode regionEqualsNode) { int len1 = input.byteLength(encoding.getTStringEncoding()); int len2 = prefix.byteLength(encoding.getTStringEncoding()); return len1 >= len2 && regionEqualsNode.execute(input, 0, prefix, 0, len2, encoding.getTStringEncoding()); @@ -66,7 +65,7 @@ public boolean doTString(TruffleString input, TruffleString prefix, @SuppressWar @Fallback public boolean doTStringMask(TruffleString input, TruffleString prefix, TruffleString.WithMask mask, Encoding encoding, - @Cached TruffleString.RegionEqualByteIndexNode regionEqualsNode) { + @Cached(inline = false) @Shared TruffleString.RegionEqualByteIndexNode regionEqualsNode) { int len1 = input.byteLength(encoding.getTStringEncoding()); int len2 = prefix.byteLength(encoding.getTStringEncoding()); return len1 >= len2 && regionEqualsNode.execute(input, 0, mask, 0, len2, encoding.getTStringEncoding()); diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/package-info.java deleted file mode 100644 index a20a30af5cf6..000000000000 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/package-info.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -//TODO GR-42839 fix warnings -@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) -package com.oracle.truffle.regex.tregex.nodes.input; - -import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/nfa/TRegexBacktrackingNFAExecutorNode.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/nfa/TRegexBacktrackingNFAExecutorNode.java index f74d36b5ab10..9fc1fee4b98a 100644 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/nfa/TRegexBacktrackingNFAExecutorNode.java +++ b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/nfa/TRegexBacktrackingNFAExecutorNode.java @@ -1112,7 +1112,7 @@ private boolean matchBackReferenceSimple(TRegexBacktrackingNFAExecutorLocals loc if (isForward() ? index + backrefLength > inputLength : index - backrefLength < 0) { return false; } - return regionMatchesNode.execute(locals.getInput(), backrefStart, locals.getInput(), isForward() ? index : index - backrefLength, backrefLength, null, getEncoding()); + return regionMatchesNode.execute(this, locals.getInput(), backrefStart, locals.getInput(), isForward() ? index : index - backrefLength, backrefLength, null, getEncoding()); } private int matchBackReferenceGeneric(TRegexBacktrackingNFAExecutorLocals locals, PureNFAState backReference, TruffleString.CodeRange codeRange) { @@ -1151,7 +1151,7 @@ private int findInnerLiteral(TRegexBacktrackingNFAExecutorLocals locals) { CompilerDirectives.transferToInterpreterAndInvalidate(); indexOfNode = insert(InputIndexOfStringNode.create()); } - return indexOfNode.execute(locals.getInput(), locals.getIndex(), locals.getMaxIndex(), innerLiteral.getLiteralContent(), innerLiteral.getMaskContent(), getEncoding()); + return indexOfNode.execute(this, locals.getInput(), locals.getIndex(), locals.getMaxIndex(), innerLiteral.getLiteralContent(), innerLiteral.getMaskContent(), getEncoding()); } private boolean inputBoundsCheck(int i, int min, int max) { diff --git a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/package-info.java b/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/package-info.java deleted file mode 100644 index 080020fc85af..000000000000 --- a/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/package-info.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * The Universal Permissive License (UPL), Version 1.0 - * - * Subject to the condition set forth below, permission is hereby granted to any - * person obtaining a copy of this software, associated documentation and/or - * data (collectively the "Software"), free of charge and under any and all - * copyright rights in the Software, and any and all patent rights owned or - * freely licensable by each licensor hereunder covering either (i) the - * unmodified Software as contributed to or provided by such licensor, or (ii) - * the Larger Works (as defined below), to deal in both - * - * (a) the Software, and - * - * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if - * one is included with the Software each a "Larger Work" to which the Software - * is contributed by such licensors), - * - * without restriction, including without limitation the rights to copy, create - * derivative works of, display, perform, and distribute the Software and make, - * use, sell, offer for sale, import, export, have made, and have sold the - * Software and the Larger Work(s), and to sublicense the foregoing rights on - * either these or other terms. - * - * This license is subject to the following condition: - * - * The above copyright notice and either this complete permission notice or at a - * minimum a reference to the UPL must be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -//TODO GR-42839 fix warnings -@SuppressPackageWarnings({"truffle-inlining", "truffle-sharing", "truffle-neverdefault", "truffle-limit"}) -package com.oracle.truffle.regex.tregex.nodes; - -import com.oracle.truffle.api.dsl.SuppressPackageWarnings; diff --git a/sdk/ci/ci.jsonnet b/sdk/ci/ci.jsonnet index 2090ddd90637..562a140c284d 100644 --- a/sdk/ci/ci.jsonnet +++ b/sdk/ci/ci.jsonnet @@ -20,7 +20,9 @@ builds: [ common.linux_amd64 + common.oraclejdkLatest + sdk_gate + common.deps.eclipse + common.deps.jdt, common.linux_amd64 + common.oraclejdk21 + sdk_gate + common.deps.eclipse + common.deps.jdt + common.mach5_target, - common.darwin_amd64 + common.oraclejdkLatest + sdk_gate, + # JDK latest only works on MacOS Ventura (GR-49652) + # common.darwin_amd64 + common.oraclejdkLatest + sdk_gate, + common.darwin_aarch64 + common.oraclejdkLatest + sdk_gate, common.darwin_amd64 + common.oraclejdk21 + sdk_gate + common.mach5_target, ] } diff --git a/sdk/mx.sdk/suite.py b/sdk/mx.sdk/suite.py index 7485b70ed686..11538cddee8d 100644 --- a/sdk/mx.sdk/suite.py +++ b/sdk/mx.sdk/suite.py @@ -39,7 +39,7 @@ # SOFTWARE. # suite = { - "mxversion": "6.52.0", + "mxversion": "6.53.2", "name" : "sdk", "version" : "24.0.0", "release" : False, diff --git a/substratevm/mx.substratevm/mx_substratevm.py b/substratevm/mx.substratevm/mx_substratevm.py index 3c873193198e..62becf0a6ad1 100644 --- a/substratevm/mx.substratevm/mx_substratevm.py +++ b/substratevm/mx.substratevm/mx_substratevm.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2023, 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 @@ -315,7 +315,7 @@ def native_image_func(args, **kwargs): yield native_image_func native_image_context.hosted_assertions = ['-J-ea', '-J-esa'] -_native_unittest_features = '--features=com.oracle.svm.test.ImageInfoTest$TestFeature,com.oracle.svm.test.ServiceLoaderTest$TestFeature,com.oracle.svm.test.SecurityServiceTest$TestFeature' +_native_unittest_features = '--features=com.oracle.svm.test.ImageInfoTest$TestFeature,com.oracle.svm.test.ServiceLoaderTest$TestFeature,com.oracle.svm.test.SecurityServiceTest$TestFeature,com.oracle.svm.test.ReflectionRegistrationTest$TestFeature' IMAGE_ASSERTION_FLAGS = svm_experimental_options(['-H:+VerifyGraalGraphs', '-H:+VerifyPhases']) diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index 8e6ac153e19d..bd0c59e74f79 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -691,6 +691,8 @@ "checkstyle": "com.oracle.svm.hosted", "workingSets": "SVM", "jacoco" : "include", + # disable SpotBugs as long JDK 22 is unsupported [GR-49566] + "spotbugs" : "false", }, "com.oracle.svm.hosted.foreign": { @@ -719,6 +721,8 @@ "checkstyle": "com.oracle.svm.hosted", "workingSets": "SVM", "jacoco" : "include", + # disable SpotBugs as long JDK 22 is unsupported [GR-49566] + "spotbugs" : "false", }, # Native libraries below explicitly set _FORTIFY_SOURCE to 0. This constant controls how glibc handles some diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java index 17e260eef861..ffda625c7dd8 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/Target_java_lang_foreign_SymbolLookup.java @@ -49,6 +49,7 @@ import com.oracle.svm.core.jdk.Target_java_lang_Module; import com.oracle.svm.core.snippets.KnownIntrinsics; +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.internal.foreign.MemorySessionImpl; import jdk.internal.foreign.Utils; import jdk.internal.loader.NativeLibrary; @@ -134,7 +135,12 @@ static void ensureNativeAccess(Class currentClass, Class owner, String met */ Target_java_lang_Module module = SubstrateUtil.cast(currentClass != null ? currentClass.getModule() : ClassLoader.getSystemClassLoader().getUnnamedModule(), Target_java_lang_Module.class); - module.ensureNativeAccess(owner, methodName); + if (JavaVersionUtil.JAVA_SPEC <= 21) { + module.ensureNativeAccess(owner, methodName); + } else { + module.ensureNativeAccess(owner, methodName, currentClass); + } + } static LookupNativeLibraries createNativeLibraries(BiConsumer loadLibraryFunc, List libDescs) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java index 8650317eb5b6..0b0794e28266 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java @@ -35,14 +35,20 @@ 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.annotate.TargetElement; import com.oracle.svm.core.jdk.resources.ResourceStorageEntry; @SuppressWarnings("unused") @TargetClass(value = java.lang.Module.class) public final class Target_java_lang_Module { @Alias + @TargetElement(onlyWith = JDK21OrEarlier.class) public native void ensureNativeAccess(Class owner, String methodName); + @Alias + @TargetElement(onlyWith = JDK22OrLater.class) + public native void ensureNativeAccess(Class owner, String methodName, Class currentClass); + @SuppressWarnings("static-method") @Substitute private InputStream getResourceAsStream(String resourceName) { diff --git a/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsConfigurationParser.java b/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsConfigurationParser.java index 227c6ce5b55f..d87ce5fe3282 100644 --- a/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsConfigurationParser.java +++ b/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/ForeignFunctionsConfigurationParser.java @@ -37,6 +37,10 @@ import org.graalvm.nativeimage.impl.RuntimeForeignAccessSupport; import com.oracle.svm.core.configure.ConfigurationParser; +import com.oracle.svm.core.util.VMError; +import com.oracle.svm.util.ReflectionUtil; + +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; @Platforms(Platform.HOSTED_ONLY.class) public class ForeignFunctionsConfigurationParser extends ConfigurationParser { @@ -99,10 +103,20 @@ private List parseOptions(Object options) { } if (map.containsKey(DOWNCALL_OPTION_TRIVIAL)) { if (asBoolean(map.get(DOWNCALL_OPTION_TRIVIAL, ""), DOWNCALL_OPTION_TRIVIAL)) { - res.add(Linker.Option.isTrivial()); + res.add(OPTION_CRITICAL); } } return res; } + + private static final Linker.Option OPTION_CRITICAL; + + static { + try { + OPTION_CRITICAL = (Linker.Option) ReflectionUtil.lookupMethod(Linker.Option.class, JavaVersionUtil.JAVA_SPEC >= 22 ? "critical" : "isTrivial").invoke(null); + } catch (ReflectiveOperationException ex) { + throw VMError.shouldNotReachHere(ex); + } + } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConditionalConfigurationRegistry.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConditionalConfigurationRegistry.java index dab90726dfbf..8af9e717078f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConditionalConfigurationRegistry.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConditionalConfigurationRegistry.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; @@ -38,6 +39,8 @@ public abstract class ConditionalConfigurationRegistry { private final Map> pendingReachabilityHandlers = new ConcurrentHashMap<>(); protected void registerConditionalConfiguration(ConfigurationCondition condition, Runnable runnable) { + Objects.requireNonNull(condition, "Cannot use null value as condition for conditional configuration. Please ensure that you register a non-null condition."); + Objects.requireNonNull(runnable, "Cannot use null value as runnable for conditional configuration. Please ensure that you register a non-null runnable."); if (ConfigurationCondition.alwaysTrue().equals(condition)) { /* analysis optimization to include new types as early as possible */ runnable.run(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java index 08384d7a5b47..236eec27d5ee 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java @@ -38,6 +38,8 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; + /** * Registration of classes, methods, and fields accessed via JNI by C code of the JDK. */ @@ -144,9 +146,12 @@ private static void registerUnixNativeDispatcherInit(DuringAnalysisAccess a) { RuntimeJNIAccess.register(fields(a, "sun.nio.fs.UnixFileAttributes", "st_mode", "st_ino", "st_dev", "st_rdev", "st_nlink", "st_uid", "st_gid", "st_size", "st_atime_sec", "st_atime_nsec", "st_mtime_sec", "st_mtime_nsec", "st_ctime_sec", "st_ctime_nsec")); - if (isDarwin()) { + if (isDarwin() || JavaVersionUtil.JAVA_SPEC >= 22 && isLinux()) { RuntimeJNIAccess.register(fields(a, "sun.nio.fs.UnixFileAttributes", "st_birthtime_sec")); } + if (JavaVersionUtil.JAVA_SPEC >= 22 && isLinux()) { + RuntimeJNIAccess.register(fields(a, "sun.nio.fs.UnixFileAttributes", "st_birthtime_nsec")); + } RuntimeJNIAccess.register(clazz(a, "sun.nio.fs.UnixFileStoreAttributes")); RuntimeJNIAccess.register(fields(a, "sun.nio.fs.UnixFileStoreAttributes", "f_frsize", "f_blocks", "f_bfree", "f_bavail")); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java index 85ce7145b778..fee9606ad777 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAccessFeature.java @@ -34,6 +34,7 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Predicate; @@ -42,9 +43,6 @@ import org.graalvm.collections.EconomicSet; import org.graalvm.collections.Equivalence; import org.graalvm.collections.UnmodifiableMapCursor; -import jdk.graal.compiler.api.replacements.Fold; -import jdk.graal.compiler.options.Option; -import jdk.graal.compiler.word.WordTypes; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.nativeimage.hosted.Feature; @@ -98,6 +96,9 @@ import com.oracle.svm.hosted.substitute.SubstitutionReflectivityFilter; import com.oracle.svm.util.ReflectionUtil; +import jdk.graal.compiler.api.replacements.Fold; +import jdk.graal.compiler.options.Option; +import jdk.graal.compiler.word.WordTypes; import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; import jdk.vm.ci.meta.ResolvedJavaMethod; @@ -202,18 +203,21 @@ private class JNIRuntimeAccessibilitySupportImpl extends ConditionalConfiguratio @Override public void register(ConfigurationCondition condition, boolean unsafeAllocated, Class clazz) { assert !unsafeAllocated : "unsafeAllocated can be only set via Unsafe.allocateInstance, not via JNI."; + Objects.requireNonNull(clazz, () -> nullErrorMessage("class")); abortIfSealed(); registerConditionalConfiguration(condition, () -> newClasses.add(clazz)); } @Override - public void register(ConfigurationCondition condition, boolean queriedOnly, Executable... methods) { + public void register(ConfigurationCondition condition, boolean queriedOnly, Executable... executables) { + requireNonNull(executables, "executable"); abortIfSealed(); - registerConditionalConfiguration(condition, () -> newMethods.addAll(Arrays.asList(methods))); + registerConditionalConfiguration(condition, () -> newMethods.addAll(Arrays.asList(executables))); } @Override public void register(ConfigurationCondition condition, boolean finalIsWritable, Field... fields) { + requireNonNull(fields, "field"); abortIfSealed(); registerConditionalConfiguration(condition, () -> registerFields(finalIsWritable, fields)); } @@ -622,4 +626,14 @@ private static boolean anyFieldMatches(ResolvedJavaType sub, String name) { return false; } } + + private static void requireNonNull(Object[] values, String kind) { + for (Object value : values) { + Objects.requireNonNull(value, () -> nullErrorMessage(kind)); + } + } + + private static String nullErrorMessage(String kind) { + return "Cannot register null value as " + kind + " for JNI access. Please ensure that all values you register are not null."; + } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java index d7fa9f2f1c37..3c959bd9f521 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java @@ -56,6 +56,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.Callable; @@ -166,6 +167,7 @@ private void setQueryFlag(Class clazz, int flag) { @Override public void register(ConfigurationCondition condition, boolean unsafeInstantiated, Class clazz) { + Objects.requireNonNull(clazz, () -> nullErrorMessage("class")); checkNotSealed(); register(analysisUniverse -> registerConditionalConfiguration(condition, () -> analysisUniverse.getBigbang().postTask(debug -> registerClass(clazz, unsafeInstantiated)))); @@ -269,6 +271,7 @@ public void registerAllSignersQuery(ConfigurationCondition condition, Class c @Override public void register(ConfigurationCondition condition, boolean queriedOnly, Executable... executables) { + requireNonNull(executables, "executable"); checkNotSealed(); register(analysisUniverse -> registerConditionalConfiguration(condition, () -> { for (Executable executable : executables) { @@ -397,6 +400,7 @@ public void registerConstructorLookup(ConfigurationCondition condition, Class @Override public void register(ConfigurationCondition condition, boolean finalIsWritable, Field... fields) { + requireNonNull(fields, "field"); checkNotSealed(); registerInternal(condition, fields); } @@ -1060,4 +1064,14 @@ public int getReflectionMethodsCount() { public int getReflectionFieldsCount() { return registeredFields.size(); } + + private static void requireNonNull(Object[] values, String kind) { + for (Object value : values) { + Objects.requireNonNull(value, () -> nullErrorMessage(kind)); + } + } + + private static String nullErrorMessage(String kind) { + return "Cannot register null value as " + kind + " for reflection. Please ensure that all values you register are not null."; + } } diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/ReflectionRegistrationTest.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/ReflectionRegistrationTest.java new file mode 100644 index 000000000000..555cc683657d --- /dev/null +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/ReflectionRegistrationTest.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2023, Red Hat Inc. 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.test; + +import com.oracle.svm.hosted.FeatureImpl; +import com.oracle.svm.hosted.substitute.SubstitutionReflectivityFilter; +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.hosted.Feature; +import org.graalvm.nativeimage.hosted.RuntimeReflection; +import org.graalvm.nativeimage.impl.RuntimeReflectionSupport; +import org.junit.Test; + +import java.lang.reflect.Executable; +import java.lang.reflect.Field; + +/** + * Tests the {@link RuntimeReflection}. + */ +public class ReflectionRegistrationTest { + + public static class TestFeature implements Feature { + + @SuppressWarnings("unused")// + int unusedVariableOne = 1; + @SuppressWarnings("unused")// + int unusedVariableTwo = 2; + + @Override + public void beforeAnalysis(final BeforeAnalysisAccess access) { + try { + RuntimeReflection.register((Class) null); + assert false; + } catch (NullPointerException e) { + assert e.getMessage().startsWith("Cannot register null value"); + } + try { + RuntimeReflection.register((Executable) null); + assert false; + } catch (NullPointerException e) { + assert e.getMessage().startsWith("Cannot register null value"); + } + try { + RuntimeReflection.register((Field) null); + assert false; + } catch (NullPointerException e) { + assert e.getMessage().startsWith("Cannot register null value"); + } + + try { + ImageSingletons.lookup(RuntimeReflectionSupport.class).register(null, this.getClass()); + assert false; + } catch (NullPointerException e) { + assert e.getMessage().startsWith("Cannot use null value"); + } + + try { + ImageSingletons.lookup(RuntimeReflectionSupport.class).register(null, true, this.getClass().getMethods()); + assert false; + } catch (NullPointerException e) { + assert e.getMessage().startsWith("Cannot use null value"); + } + + try { + ImageSingletons.lookup(RuntimeReflectionSupport.class).register(null, true, this.getClass().getFields()); + assert false; + } catch (NullPointerException e) { + assert e.getMessage().startsWith("Cannot use null value"); + } + + FeatureImpl.BeforeAnalysisAccessImpl impl = (FeatureImpl.BeforeAnalysisAccessImpl) access; + try { + SubstitutionReflectivityFilter.shouldExclude((Class) null, impl.getMetaAccess(), impl.getUniverse()); + assert false; + } catch (NullPointerException e) { + // expected + } + try { + SubstitutionReflectivityFilter.shouldExclude((Executable) null, impl.getMetaAccess(), impl.getUniverse()); + assert false; + } catch (NullPointerException e) { + // expected + } + try { + SubstitutionReflectivityFilter.shouldExclude((Field) null, impl.getMetaAccess(), impl.getUniverse()); + assert false; + } catch (NullPointerException e) { + // expected + } + } + + } + + @Test + public void test() { + // nothing to do + } +} diff --git a/sulong/ci/ci.jsonnet b/sulong/ci/ci.jsonnet index 3e4651fbb995..9ccde9b76aec 100644 --- a/sulong/ci/ci.jsonnet +++ b/sulong/ci/ci.jsonnet @@ -39,8 +39,9 @@ local sc = (import "ci_common/sulong-common.jsonnet"); sc.weekly + $.sulong + sc.labsjdkLatest + sc.linux_amd64 + sc.llvm6 + sc.requireGMP + sc.requireGCC + sc.gateTags(basicTags) + { name: "weekly-sulong-basic-nwcc-llvm-v60-jdk-latest-linux-amd64" }, sc.weekly + $.sulong + sc.labsjdkLatest + sc.linux_amd64 + sc.llvm8 + sc.requireGMP + sc.requireGCC + sc.gateTags(basicTags) + { name: "weekly-sulong-basic-nwcc-llvm-v80-jdk-latest-linux-amd64" }, - sc.weekly + $.sulong + sc.labsjdkLatest + sc.darwin_amd64 + sc.llvm4 + sc.gateTags(basicTags) + { name: "weekly-sulong-basic-nwcc-llvm-v40-jdk-latest-darwin-amd64", timelimit: "0:45:00" }, - sc.gate + $.sulong + sc.labsjdkLatest + sc.darwin_amd64 + sc.llvmBundled + sc.gateTags(basicTagsToolchain) + { name: "gate-sulong-basic-nwcc-llvm-toolchain-jdk-latest-darwin-amd64", timelimit: "0:45:00", capabilities+: ["!darwin_bigsur", "ram16gb"] }, + # JDK latest only works on MacOS Ventura (GR-49652) + # sc.weekly + $.sulong + sc.labsjdkLatest + sc.darwin_amd64 + sc.llvm4 + sc.gateTags(basicTags) + { name: "weekly-sulong-basic-nwcc-llvm-v40-jdk-latest-darwin-amd64", timelimit: "0:45:00" }, + # sc.gate + $.sulong + sc.labsjdkLatest + sc.darwin_amd64 + sc.llvmBundled + sc.gateTags(basicTagsToolchain) + { name: "gate-sulong-basic-nwcc-llvm-toolchain-jdk-latest-darwin-amd64", timelimit: "0:45:00", capabilities+: ["!darwin_bigsur", "ram16gb"] }, sc.gate + $.sulong + sc.labsjdkLatest + sc.linux_amd64 + sc.llvmBundled + sc.requireGMP + sc.requireGCC + sc.gateTags(basicTagsToolchain) + { name: "gate-sulong-basic-nwcc-llvm-toolchain-jdk-latest-linux-amd64" }, sc.gate + $.sulong + sc.labsjdk21 + sc.linux_amd64 + sc.llvmBundled + sc.requireGMP + sc.requireGCC + sc.gateTags(basicTagsToolchain) + { name: "gate-sulong-basic-nwcc-llvm-toolchain-jdk21-linux-amd64" }, @@ -67,19 +68,22 @@ local sc = (import "ci_common/sulong-common.jsonnet"); ], [ [sc.linux_amd64, [sc.labsjdkLatest]], - [sc.darwin_amd64, [sc.labsjdkLatest]], + # JDK latest only works on MacOS Ventura (GR-49652) + # [sc.darwin_amd64, [sc.labsjdkLatest]], [sc.windows_amd64 + { capabilities+: ["windows_server_2016"] /* work around native-image bug GR-48515 */ }, [sc.labsjdkLatest]], [sc.linux_aarch64, [sc.labsjdkLatest]], [sc.darwin_aarch64, [sc.labsjdkLatest]], ], [ { name: "gate-sulong-test-ce-standalones-jvm-jdk-latest-linux-amd64", timelimit: "1:00:00" }, - { name: "daily-sulong-test-ce-standalones-jvm-jdk-latest-darwin-amd64", timelimit: "1:00:00", targets: [] } + sc.daily, + # JDK latest only works on MacOS Ventura (GR-49652) + # { name: "daily-sulong-test-ce-standalones-jvm-jdk-latest-darwin-amd64", timelimit: "1:00:00", targets: [] } + sc.daily, { name: "gate-sulong-test-ce-standalones-jvm-jdk-latest-windows-amd64", timelimit: "1:00:00" }, { name: "gate-sulong-test-ce-standalones-jvm-jdk-latest-linux-aarch64", timelimit: "1:00:00" }, { name: "gate-sulong-test-ce-standalones-jvm-jdk-latest-darwin-aarch64", timelimit: "1:00:00" }, { name: "gate-sulong-test-ce-standalones-native-jdk-latest-linux-amd64", timelimit: "1:00:00" }, - { name: "daily-sulong-test-ce-standalones-native-jdk-latest-darwin-amd64", timelimit: "1:00:00", targets: [] } + sc.daily, + # JDK latest only works on MacOS Ventura (GR-49652) + # { name: "daily-sulong-test-ce-standalones-native-jdk-latest-darwin-amd64", timelimit: "1:00:00", targets: [] } + sc.daily, { name: "gate-sulong-test-ce-standalones-native-jdk-latest-windows-amd64", timelimit: "1:00:00" }, { name: "gate-sulong-test-ce-standalones-native-jdk-latest-linux-aarch64", timelimit: "1:00:00" }, { name: "gate-sulong-test-ce-standalones-native-jdk-latest-darwin-aarch64", timelimit: "1:00:00" }, @@ -89,14 +93,16 @@ local sc = (import "ci_common/sulong-common.jsonnet"); sc.mapPrototypePlatformName([sc.weekly + $.sulong + sc.coverage($.regular_builds)], [ [sc.linux_amd64, [sc.labsjdkLatest]], - [sc.darwin_amd64, [sc.labsjdkLatest]], + # JDK latest only works on MacOS Ventura (GR-49652) + # [sc.darwin_amd64, [sc.labsjdkLatest]], [sc.windows_amd64, [sc.labsjdkLatest]], [sc.linux_aarch64, [sc.labsjdkLatest]], [sc.darwin_aarch64, [sc.labsjdkLatest]], ], [ { name: "weekly-sulong-coverage-jdk-latest-linux-amd64", timelimit: "1:00:00" }, - { name: "weekly-sulong-coverage-jdk-latest-darwin-amd64", timelimit: "1:00:00" }, + # JDK latest only works on MacOS Ventura (GR-49652) + # { name: "weekly-sulong-coverage-jdk-latest-darwin-amd64", timelimit: "1:00:00" }, { name: "weekly-sulong-coverage-jdk-latest-windows-amd64", timelimit: "1:00:00" }, { name: "weekly-sulong-coverage-jdk-latest-linux-aarch64", timelimit: "1:00:00" }, { name: "weekly-sulong-coverage-jdk-latest-darwin-aarch64", timelimit: "1:00:00" }, diff --git a/sulong/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/binary/BinaryParser.java b/sulong/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/binary/BinaryParser.java index be98b91e16a7..ebec74188b58 100644 --- a/sulong/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/binary/BinaryParser.java +++ b/sulong/projects/com.oracle.truffle.llvm.parser/src/com/oracle/truffle/llvm/parser/binary/BinaryParser.java @@ -29,21 +29,12 @@ */ package com.oracle.truffle.llvm.parser.binary; -import java.nio.file.InvalidPathException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; - -import com.oracle.truffle.llvm.parser.coff.PEFile; -import com.oracle.truffle.llvm.parser.coff.WindowsLibraryLocator; - -import org.graalvm.polyglot.io.ByteSequence; - import com.oracle.truffle.api.source.Source; import com.oracle.truffle.llvm.parser.coff.CoffFile; -import com.oracle.truffle.llvm.parser.coff.PEExportSymbolsMapper; import com.oracle.truffle.llvm.parser.coff.CoffFile.ImageSectionHeader; +import com.oracle.truffle.llvm.parser.coff.PEExportSymbolsMapper; +import com.oracle.truffle.llvm.parser.coff.PEFile; +import com.oracle.truffle.llvm.parser.coff.WindowsLibraryLocator; import com.oracle.truffle.llvm.parser.elf.ElfDynamicSection; import com.oracle.truffle.llvm.parser.elf.ElfFile; import com.oracle.truffle.llvm.parser.elf.ElfLibraryLocator; @@ -54,9 +45,17 @@ import com.oracle.truffle.llvm.parser.scanner.BitStream; import com.oracle.truffle.llvm.runtime.DefaultLibraryLocator; import com.oracle.truffle.llvm.runtime.ExportSymbolsMapper; +import com.oracle.truffle.llvm.runtime.IDGenerater.BitcodeID; import com.oracle.truffle.llvm.runtime.LLVMContext; import com.oracle.truffle.llvm.runtime.LibraryLocator; import com.oracle.truffle.llvm.runtime.Magic; +import org.graalvm.polyglot.io.ByteSequence; + +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; /** * Parses a binary {@linkplain ByteSequence file} and returns the embedded {@linkplain ByteSequence @@ -82,11 +81,11 @@ public static Magic getMagic(BitStream b) { } } - public static BinaryParserResult parse(ByteSequence bytes, Source bcSource, LLVMContext context) { - return new BinaryParser().parseInternal(bytes, bcSource, context); + public static BinaryParserResult parse(ByteSequence bytes, Source bcSource, LLVMContext context, BitcodeID bitcodeID) { + return new BinaryParser().parseInternal(bytes, bcSource, context, bitcodeID); } - private BinaryParserResult parseInternal(ByteSequence bytes, Source bcSource, LLVMContext context) { + private BinaryParserResult parseInternal(ByteSequence bytes, Source bcSource, LLVMContext context, BitcodeID bitcodeID) { assert bytes != null; ByteSequence bitcode = parseBitcode(bytes, bcSource); @@ -95,7 +94,7 @@ private BinaryParserResult parseInternal(ByteSequence bytes, Source bcSource, LL return null; } if (bcSource != null) { - LibraryLocator.traceParseBitcode(context, bcSource.getPath()); + LibraryLocator.traceParseBitcode(context, bcSource.getPath(), bitcodeID, bcSource); } return new BinaryParserResult(libraries, paths, bitcode, locator, exportSymbolsMapper, bcSource, libraryName); } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/IDGenerater.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/IDGenerater.java index 6e77230ecd78..d20408fec569 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/IDGenerater.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/IDGenerater.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. * * All rights reserved. * @@ -39,19 +39,25 @@ public final class IDGenerater { private final ReferenceQueue refQueue = new ReferenceQueue<>(); private final IDReference first = new IDReference(); - public static final BitcodeID INVALID_ID = new BitcodeID(-1); + public static final BitcodeID INVALID_ID = new BitcodeID(-1, ""); public static final class BitcodeID { private final int id; + private final String name; - private BitcodeID(int id) { + private BitcodeID(int id, String name) { this.id = id; + this.name = name; } public int getId() { return id; } + public String getName() { + return name; + } + public boolean same(BitcodeID other) { return this.id == other.getId(); } @@ -96,19 +102,19 @@ private static synchronized void remove(IDReference allocation) { allocation.prev = null; } - public BitcodeID generateID() { + public BitcodeID generateID(String name) { IDReference ref = (IDReference) refQueue.poll(); if (ref != null) { // To see if any ids are really being reused. It is possible to log all reused ids with // the TruffleLogger. remove(ref); - return createID(ref.id); + return createID(ref.id, name); } - return createID(nextID.getAndIncrement()); + return createID(nextID.getAndIncrement(), name); } - private BitcodeID createID(int id) { - BitcodeID bitcodeID = new BitcodeID(id); + private BitcodeID createID(int id, String name) { + BitcodeID bitcodeID = new BitcodeID(id, name); IDReference ref = new IDReference(bitcodeID); add(ref); return bitcodeID; diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMContext.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMContext.java index 44ddf1d3c098..1101e7da8b02 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMContext.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMContext.java @@ -815,6 +815,13 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws return symbolFinalStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { exception.enter(); + if (LibraryLocator.loggingEnabled()) { + loaderLogger.log(Level.FINEST, Arrays.toString(e.getStackTrace())); + loaderLogger.log(Level.FINEST, "symbol is: " + symbol.getName()); + loaderLogger.log(Level.FINEST, "id is: " + id); + loaderLogger.log(Level.FINEST, "id name is: " + bitcodeID.getName()); + loaderLogger.log(Level.FINEST, "index is: " + index); + } throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } else { @@ -822,6 +829,13 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws return symbolDynamicStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { exception.enter(); + if (LibraryLocator.loggingEnabled()) { + loaderLogger.log(Level.FINEST, Arrays.toString(e.getStackTrace())); + loaderLogger.log(Level.FINEST, "symbol is: " + symbol.getName()); + loaderLogger.log(Level.FINEST, "id is: " + id); + loaderLogger.log(Level.FINEST, "id name is: " + bitcodeID.getName()); + loaderLogger.log(Level.FINEST, "index is: " + index); + } throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java index 3964f4e29797..d2e96ddb2ce4 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java @@ -29,16 +29,6 @@ */ package com.oracle.truffle.llvm.runtime; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; - import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerAsserts; @@ -87,13 +77,21 @@ import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer; import com.oracle.truffle.llvm.runtime.target.TargetTriple; import com.oracle.truffle.llvm.runtime.types.Type; - import org.graalvm.collections.EconomicMap; -import org.graalvm.collections.MapCursor; import org.graalvm.collections.Pair; import org.graalvm.options.OptionDescriptors; import org.graalvm.options.OptionValues; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + @TruffleLanguage.Registration(id = LLVMLanguage.ID, name = LLVMLanguage.NAME, internal = false, interactive = false, defaultMimeType = LLVMLanguage.LLVM_BITCODE_MIME_TYPE, // byteMimeTypes = {LLVMLanguage.LLVM_BITCODE_MIME_TYPE, LLVMLanguage.LLVM_ELF_SHARED_MIME_TYPE, LLVMLanguage.LLVM_ELF_EXEC_MIME_TYPE, LLVMLanguage.LLVM_MACHO_MIME_TYPE, LLVMLanguage.LLVM_MS_DOS_MIME_TYPE}, // @@ -767,7 +765,7 @@ protected CallTarget parse(ParsingRequest request) { synchronized (libraryCacheLock) { CallTarget cached = getCachedLibrary(source); if (cached == null) { - BitcodeID id = idGenerater.generateID(); + BitcodeID id = idGenerater.generateID(source.getName()); cached = getCapability(Loader.class).load(getContext(), source, id); LibraryCacheEntry entry = new LibraryCacheEntry(this, source, cached, id); if (entry.isCachable()) { @@ -779,14 +777,10 @@ protected CallTarget parse(ParsingRequest request) { } } else { // just get the id here and give it to the parserDriver - return getCapability(Loader.class).load(getContext(), source, idGenerater.generateID()); + return getCapability(Loader.class).load(getContext(), source, idGenerater.generateID(source.getName())); } } - public MapCursor getLibraryCache() { - return libraryCache.getEntries(); - } - private void lazyCacheCleanup() { /* * Just lazily clean up one entry. We do this on every lookup. Under the assumption that @@ -795,7 +789,19 @@ private void lazyCacheCleanup() { */ LibraryCacheEntry ref = (LibraryCacheEntry) libraryCacheQueue.poll(); if (ref != null) { - libraryCache.removeKey(ref.key); + if (LibraryLocator.loggingEnabled()) { + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, entry", ref.key.path); + BitcodeID bitcodeID = ref.id.get(); + if (bitcodeID != null) { + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id name", bitcodeID.getName()); + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", bitcodeID.getId()); + } else { + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", bitcodeID); + } + } + if (libraryCache.get(ref.key) == ref) { + libraryCache.removeKey(ref.key); + } } } @@ -805,6 +811,11 @@ public CallTarget getCachedLibrary(Source source) { lazyCacheCleanup(); LibraryCacheKey key = new LibraryCacheKey(source); LibraryCacheEntry entry = libraryCache.get(key); + if (LibraryLocator.loggingEnabled()) { + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage get cached library, source name", source.getName()); + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage get cached library, source", source); + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage get cached library, entry", entry); + } if (entry == null) { return null; } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LibraryLocator.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LibraryLocator.java index 6717768ceae7..6e7cab40715a 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LibraryLocator.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LibraryLocator.java @@ -29,16 +29,16 @@ */ package com.oracle.truffle.llvm.runtime; -import java.io.IOException; -import java.util.List; -import java.util.logging.Level; - import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.Source.SourceBuilder; +import java.io.IOException; +import java.util.List; +import java.util.logging.Level; + /** * Encapsulates logic for locating libraries. */ @@ -120,9 +120,9 @@ public static void traceSearchPath(LLVMContext context, List paths, Object re } } - public static void traceParseBitcode(LLVMContext context, Object path) { + public static void traceParseBitcode(LLVMContext context, Object path, IDGenerater.BitcodeID bitcodeID, Source source) { if (loggingEnabled()) { - traceLoader(context, "parse bitcode=%s", path); + traceLoader(context, "parse bitcode=%s (bitcode id=%s, %s) (source = %s, %s)", path, bitcodeID.getName(), bitcodeID.getId(), source.getName(), source.toString()); } } @@ -172,6 +172,12 @@ private static void traceLoader(LLVMContext context, String format, Object arg0, String.format("lli(%x): " + format, prefix(context), arg0, arg1, arg2)); } + @CompilerDirectives.TruffleBoundary + private static void traceLoader(LLVMContext context, String format, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) { + LLVMContext.loaderLogger().log(LOADER_LOGGING_LEVEL, + String.format("lli(%x): " + format, prefix(context), arg0, arg1, arg2, arg3, arg4)); + } + private static int prefix(LLVMContext context) { return System.identityHashCode(context); } diff --git a/sulong/projects/com.oracle.truffle.llvm.tools/src/com/oracle/truffle/llvm/tools/ExtractBitcode.java b/sulong/projects/com.oracle.truffle.llvm.tools/src/com/oracle/truffle/llvm/tools/ExtractBitcode.java index d385babe04e7..c2b39764c009 100644 --- a/sulong/projects/com.oracle.truffle.llvm.tools/src/com/oracle/truffle/llvm/tools/ExtractBitcode.java +++ b/sulong/projects/com.oracle.truffle.llvm.tools/src/com/oracle/truffle/llvm/tools/ExtractBitcode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. * * All rights reserved. * @@ -29,6 +29,12 @@ */ package com.oracle.truffle.llvm.tools; +import com.oracle.truffle.llvm.parser.binary.BinaryParser; +import com.oracle.truffle.llvm.parser.binary.BinaryParserResult; +import com.oracle.truffle.llvm.parser.coff.WindowsLibraryLocator; +import com.oracle.truffle.llvm.parser.scanner.LLVMScanner; +import org.graalvm.polyglot.io.ByteSequence; + import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -37,13 +43,6 @@ import java.io.PrintStream; import java.util.Arrays; -import com.oracle.truffle.llvm.parser.binary.BinaryParser; -import com.oracle.truffle.llvm.parser.binary.BinaryParserResult; -import com.oracle.truffle.llvm.parser.coff.WindowsLibraryLocator; -import com.oracle.truffle.llvm.parser.scanner.LLVMScanner; - -import org.graalvm.polyglot.io.ByteSequence; - public final class ExtractBitcode { private static class ArrayByteSequence implements ByteSequence { @@ -109,7 +108,7 @@ public static void main(String[] args) { InputStream in = inName.equals("-") ? System.in : new FileInputStream(inName); OutputStream out = outName.equals("-") ? System.out : new FileOutputStream(outName); ByteSequence bytes = readFully(in); - BinaryParserResult result = BinaryParser.parse(bytes, null, null); + BinaryParserResult result = BinaryParser.parse(bytes, null, null, null); if (result == null) { throw new IOException("No bitcode found in file '" + inName + "'"); } diff --git a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/ParserDriver.java b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/ParserDriver.java index 7e88eb6bdb3a..149422c20c33 100644 --- a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/ParserDriver.java +++ b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/ParserDriver.java @@ -439,7 +439,7 @@ private void createDebugInfo(ModelModule model, LLVMSymbolReadResolver symbolRes * @return the parser result corresponding to {@code lib} */ private LLVMParserResult parseLibraryWithSource(Source source, ByteSequence bytes) { - BinaryParserResult binaryParserResult = BinaryParser.parse(bytes, source, context); + BinaryParserResult binaryParserResult = BinaryParser.parse(bytes, source, context, bitcodeID); if (binaryParserResult != null) { context.addLibraryPaths(binaryParserResult.getLibraryPaths()); processDependencies(binaryParserResult.getLibraryName(), source.isInternal(), binaryParserResult); diff --git a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadDependencyNode.java b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadDependencyNode.java index 3379aea10be5..32feb6f82dd3 100644 --- a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadDependencyNode.java +++ b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadDependencyNode.java @@ -66,6 +66,10 @@ public static LoadDependencyNode create(String libraryName, LibraryLocator libra public CallTarget execute() { LLVMContext context = getContext(); CallTarget callTarget = context.getCalltargetFromCache(libraryName); + if (LibraryLocator.loggingEnabled()) { + LibraryLocator.traceStaticInits(context, "load dependency execute, loading library", libraryLocator); + LibraryLocator.traceStaticInits(context, "load dependency execute, call target is", callTarget); + } if (callTarget != null) { return callTarget; } else { @@ -90,6 +94,9 @@ private CallTarget parse(LLVMContext context) { return createNativeLibraryCallTarget(nativeFile); } else { CallTarget cached = getLanguage().getCachedLibrary(source); + if (LibraryLocator.loggingEnabled()) { + LibraryLocator.traceStaticInits(context, "load dependency execute, cached library", cached); + } if (cached != null) { return cached; } @@ -120,4 +127,8 @@ private CallTarget createNativeLibraryCallTarget(TruffleFile file) { return loadNative.getCallTarget(); } } + + public String getLibraryName() { + return libraryName; + } } diff --git a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadModulesNode.java b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadModulesNode.java index b418730cacf6..7a6661ce8b82 100644 --- a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadModulesNode.java +++ b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/initialization/LoadModulesNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. * * All rights reserved. * @@ -51,6 +51,7 @@ import com.oracle.truffle.llvm.runtime.LLVMScopeChain; import com.oracle.truffle.llvm.runtime.LLVMSymbol; import com.oracle.truffle.llvm.runtime.LLVMUnsupportedException; +import com.oracle.truffle.llvm.runtime.LibraryLocator; import com.oracle.truffle.llvm.runtime.SulongLibrary; import com.oracle.truffle.llvm.runtime.SulongLibrary.CachedMainFunction; import com.oracle.truffle.llvm.runtime.except.LLVMParserException; @@ -302,6 +303,9 @@ private LLVMScopeChain loadModule(VirtualFrame frame, LLVMContext context) { } for (int i = 0; i < libraryDependencies.length; i++) { + if (LibraryLocator.loggingEnabled()) { + LibraryLocator.traceStaticInits(context, "building scope", libraryDependencies[i].getLibraryName()); + } CallTarget callTarget = libraryDependencies[i].execute(); if (callTarget != null) { queAdd(que, callTarget); @@ -340,6 +344,9 @@ private LLVMScopeChain loadModule(VirtualFrame frame, LLVMContext context) { if (!visited.get(id)) { visited.set(id); for (LoadDependencyNode libraryDependency : libraryDependencies) { + if (LibraryLocator.loggingEnabled()) { + LibraryLocator.traceStaticInits(context, "building library dependency", libraryDependency.getLibraryName()); + } CallTarget lib = libraryDependency.execute(); if (lib != null) { callDependencies.call(lib, LLVMLoadingPhase.BUILD_DEPENDENCY, visited, dependencies); diff --git a/sulong/tests/configs/SulongSuite/os_arch/darwin/aarch64/tmp-cpp-tests.exclude b/sulong/tests/configs/SulongSuite/os_arch/darwin/aarch64/tmp-cpp-tests.exclude deleted file mode 100644 index dc192bba7d4e..000000000000 --- a/sulong/tests/configs/SulongSuite/os_arch/darwin/aarch64/tmp-cpp-tests.exclude +++ /dev/null @@ -1,80 +0,0 @@ -cpp/test038.cpp.dir -cpp/hello.cpp.dir -cpp/test031.cpp.dir -cpp/test021.cpp.dir -cpp/test053.cpp.dir -cpp/test043.cpp.dir -cpp/testStaticReferenceInitGlobal.cpp.dir -cpp/test020.cpp.dir -cpp/test030.cpp.dir -cpp/test042.cpp.dir -cpp/test052.cpp.dir -cpp/test006.cpp.dir -cpp/test016.cpp.dir -cpp/test039.cpp.dir -cpp/test029.cpp.dir -cpp/test050.cpp.dir -cpp/test040.cpp.dir -cpp/test032.cpp.dir -cpp/test022.cpp.dir -cpp/test014.cpp.dir -cpp/test004.cpp.dir -cpp/test049.cpp.dir -cpp/test005.cpp.dir -cpp/test015.cpp.dir -cpp/test048.cpp.dir -cpp/test041.cpp.dir -cpp/test051.cpp.dir -cpp/test023.cpp.dir -cpp/test033.cpp.dir -cpp/test044.cpp.dir -cpp/test036.cpp.dir -cpp/test026.cpp.dir -cpp/testRuntimeError.cpp.dir -cpp/test009.cpp.dir -cpp/test019.cpp.dir -cpp/test010.cpp.dir -cpp/test011.cpp.dir -cpp/test045.cpp.dir -cpp/test027.cpp.dir -cpp/test037.cpp.dir -cpp/test018.cpp.dir -cpp/test008.cpp.dir -cpp/test013.cpp.dir -cpp/test003.cpp.dir -cpp/test035.cpp.dir -cpp/test025.cpp.dir -cpp/test047.cpp.dir -cpp/testStdOnce.cpp.dir -cpp/test024.cpp.dir -cpp/test034.cpp.dir -cpp/test046.cpp.dir -cpp/builtin/arithmetic/arithmetic_umul_i64.c.dir -cpp/builtin/arithmetic/arithmetic_smul_i64.c.dir -cpp/builtin/arithmetic/arithmetic_umul_i8.c.dir -cpp/builtin/arithmetic/arithmetic_uadd_i32.c.dir -cpp/builtin/arithmetic/arithmetic_uadd_i16.c.dir -cpp/builtin/arithmetic/arithmetic_ssub_i64.c.dir -cpp/builtin/arithmetic/arithmetic_sadd_i16.c.dir -cpp/builtin/arithmetic/arithmetic_sadd_i32.c.dir -cpp/builtin/arithmetic/arithmetic_smul_i8.c.dir -cpp/builtin/arithmetic/arithmetic_usub_i64.c.dir -cpp/builtin/arithmetic/arithmetic_uadd_i8.c.dir -cpp/builtin/arithmetic/arithmetic_ssub_i32.c.dir -cpp/builtin/arithmetic/arithmetic_ssub_i16.c.dir -cpp/builtin/arithmetic/arithmetic_uadd_i64.c.dir -cpp/builtin/arithmetic/arithmetic_usub_i16.c.dir -cpp/builtin/arithmetic/arithmetic_usub_i32.c.dir -cpp/builtin/arithmetic/arithmetic_sadd_i64.c.dir -cpp/builtin/arithmetic/arithmetic_ssub_i8.c.dir -cpp/builtin/arithmetic/arithmetic_umul_i32.c.dir -cpp/builtin/arithmetic/arithmetic_sadd_i8.c.dir -cpp/builtin/arithmetic/arithmetic_umul_i16.c.dir -cpp/builtin/arithmetic/arithmetic_smul_i16.c.dir -cpp/builtin/arithmetic/arithmetic_smul_i32.c.dir -cpp/builtin/arithmetic/arithmetic_usub_i8.c.dir -cpp/builtin/clz.c.dir -cpp/testStaticReferenceInitFunction.cpp.dir -cpp/test017.cpp.dir -cpp/test007.cpp.dir -cpp/test028.cpp.dir diff --git a/sulong/tests/configs/SulongSuite/os_arch/darwin/amd64/tmp-cpp-tests.exclude b/sulong/tests/configs/SulongSuite/os_arch/darwin/amd64/tmp-cpp-tests.exclude deleted file mode 100644 index dc192bba7d4e..000000000000 --- a/sulong/tests/configs/SulongSuite/os_arch/darwin/amd64/tmp-cpp-tests.exclude +++ /dev/null @@ -1,80 +0,0 @@ -cpp/test038.cpp.dir -cpp/hello.cpp.dir -cpp/test031.cpp.dir -cpp/test021.cpp.dir -cpp/test053.cpp.dir -cpp/test043.cpp.dir -cpp/testStaticReferenceInitGlobal.cpp.dir -cpp/test020.cpp.dir -cpp/test030.cpp.dir -cpp/test042.cpp.dir -cpp/test052.cpp.dir -cpp/test006.cpp.dir -cpp/test016.cpp.dir -cpp/test039.cpp.dir -cpp/test029.cpp.dir -cpp/test050.cpp.dir -cpp/test040.cpp.dir -cpp/test032.cpp.dir -cpp/test022.cpp.dir -cpp/test014.cpp.dir -cpp/test004.cpp.dir -cpp/test049.cpp.dir -cpp/test005.cpp.dir -cpp/test015.cpp.dir -cpp/test048.cpp.dir -cpp/test041.cpp.dir -cpp/test051.cpp.dir -cpp/test023.cpp.dir -cpp/test033.cpp.dir -cpp/test044.cpp.dir -cpp/test036.cpp.dir -cpp/test026.cpp.dir -cpp/testRuntimeError.cpp.dir -cpp/test009.cpp.dir -cpp/test019.cpp.dir -cpp/test010.cpp.dir -cpp/test011.cpp.dir -cpp/test045.cpp.dir -cpp/test027.cpp.dir -cpp/test037.cpp.dir -cpp/test018.cpp.dir -cpp/test008.cpp.dir -cpp/test013.cpp.dir -cpp/test003.cpp.dir -cpp/test035.cpp.dir -cpp/test025.cpp.dir -cpp/test047.cpp.dir -cpp/testStdOnce.cpp.dir -cpp/test024.cpp.dir -cpp/test034.cpp.dir -cpp/test046.cpp.dir -cpp/builtin/arithmetic/arithmetic_umul_i64.c.dir -cpp/builtin/arithmetic/arithmetic_smul_i64.c.dir -cpp/builtin/arithmetic/arithmetic_umul_i8.c.dir -cpp/builtin/arithmetic/arithmetic_uadd_i32.c.dir -cpp/builtin/arithmetic/arithmetic_uadd_i16.c.dir -cpp/builtin/arithmetic/arithmetic_ssub_i64.c.dir -cpp/builtin/arithmetic/arithmetic_sadd_i16.c.dir -cpp/builtin/arithmetic/arithmetic_sadd_i32.c.dir -cpp/builtin/arithmetic/arithmetic_smul_i8.c.dir -cpp/builtin/arithmetic/arithmetic_usub_i64.c.dir -cpp/builtin/arithmetic/arithmetic_uadd_i8.c.dir -cpp/builtin/arithmetic/arithmetic_ssub_i32.c.dir -cpp/builtin/arithmetic/arithmetic_ssub_i16.c.dir -cpp/builtin/arithmetic/arithmetic_uadd_i64.c.dir -cpp/builtin/arithmetic/arithmetic_usub_i16.c.dir -cpp/builtin/arithmetic/arithmetic_usub_i32.c.dir -cpp/builtin/arithmetic/arithmetic_sadd_i64.c.dir -cpp/builtin/arithmetic/arithmetic_ssub_i8.c.dir -cpp/builtin/arithmetic/arithmetic_umul_i32.c.dir -cpp/builtin/arithmetic/arithmetic_sadd_i8.c.dir -cpp/builtin/arithmetic/arithmetic_umul_i16.c.dir -cpp/builtin/arithmetic/arithmetic_smul_i16.c.dir -cpp/builtin/arithmetic/arithmetic_smul_i32.c.dir -cpp/builtin/arithmetic/arithmetic_usub_i8.c.dir -cpp/builtin/clz.c.dir -cpp/testStaticReferenceInitFunction.cpp.dir -cpp/test017.cpp.dir -cpp/test007.cpp.dir -cpp/test028.cpp.dir diff --git a/truffle/ci/ci.jsonnet b/truffle/ci/ci.jsonnet index fbc0e474112a..3a8ae27bbd85 100644 --- a/truffle/ci/ci.jsonnet +++ b/truffle/ci/ci.jsonnet @@ -109,10 +109,13 @@ [ linux_amd64 + jdk + sigtest + guard, linux_amd64 + jdk + simple_tool_maven_project_gate + common.mach5_target, - darwin_amd64 + jdk + truffle_weekly + gate_lite + guard, + # JDK latest only works on MacOS Ventura (GR-49652) + # darwin_amd64 + jdk + truffle_weekly + gate_lite + guard, ] for jdk in [common.oraclejdk21, common.oraclejdkLatest] ]) + [ + # JDK latest only works on MacOS Ventura (GR-49652) + darwin_amd64 + common.oraclejdk21 + truffle_weekly + gate_lite + guard, # The simple_language_maven_project_gate uses native-image, so we must run on labsjdk rather than oraclejdk linux_amd64 + common.labsjdk21 + simple_language_maven_project_gate, linux_amd64 + common.labsjdkLatest + simple_language_maven_project_gate, diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index 923ea2eb59b8..061264a0e7a8 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -293,14 +293,12 @@ def _truffle_gate_runner(args, tasks): if t: sigtest(['--check', 'binary']) with Task('Truffle UnitTests', tasks) as t: if t: unittest(list(['--suite', 'truffle', '--enable-timing', '--verbose', '--max-class-failures=25'])) - if jdk.javaCompliance >= '21': + if jdk.javaCompliance >= '22': with Task('Truffle NFI tests with Panama Backend', tasks) as t: if t: testPath = mx.distribution('TRUFFLE_TEST_NATIVE').output args = ['-Dnative.test.backend=panama', '-Dnative.test.path.panama=' + testPath] # testlibArg = mx_subst.path_substitutions.substitute('-Dnative.test.path.panama=') - if mx.project('com.oracle.truffle.nfi.backend.panama').javaPreviewNeeded: - args += ['--enable-preview'] unittest(args + ['com.oracle.truffle.nfi.test', '--enable-timing', '--verbose']) with Task('TruffleString UnitTests without Java String Compaction', tasks) as t: if t: unittest(list(['-XX:-CompactStrings', '--suite', 'truffle', '--enable-timing', '--verbose', '--max-class-failures=25', 'com.oracle.truffle.api.strings.test'])) diff --git a/truffle/mx.truffle/suite.py b/truffle/mx.truffle/suite.py index 5dc5da7d4293..1ca718b40da9 100644 --- a/truffle/mx.truffle/suite.py +++ b/truffle/mx.truffle/suite.py @@ -829,15 +829,14 @@ "com.oracle.truffle.nfi.backend.panama" : { "subDir" : "src", "sourceDirs" : ["src"], - "javaPreviewNeeded" : "21+", "dependencies" : [ "com.oracle.truffle.nfi.backend.spi", ], "checkstyle" : "com.oracle.truffle.api", - "javaCompliance" : "21+", + "javaCompliance" : "22+", "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "workingSets" : "Truffle", - # disable SpotBugs as long is panama is preview [GR-49448] + # disable SpotBugs as long JDK 22 is unsupported [GR-49566] "spotbugs" : "false", }, @@ -1606,7 +1605,7 @@ "name" : "com.oracle.truffle.truffle_nfi_panama", }, "subDir" : "src", - "javaCompliance" : "21+", + "javaCompliance" : "22+", "dependencies" : [ "com.oracle.truffle.nfi.backend.panama", ], diff --git a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java index 147893bbfec3..d66971b3b4a4 100644 --- a/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java +++ b/truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java @@ -3879,6 +3879,7 @@ int indexOfUncached(AbstractTruffleString a, int fromByteIndex, int toByteIndex, * * @since 23.0 */ + @NeverDefault public static ByteIndexOfCodePointSetNode create() { return TruffleStringFactory.ByteIndexOfCodePointSetNodeGen.create(); } diff --git a/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/ArgumentNode.java b/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/ArgumentNode.java index e24885cbcb45..213368de8fc4 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/ArgumentNode.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/ArgumentNode.java @@ -229,12 +229,11 @@ abstract static class ToSTRINGNode extends ArgumentNode { } @Specialization(limit = "3") - @SuppressWarnings("preview") Object doConvert(Object value, @CachedLibrary("value") InteropLibrary interop) throws UnsupportedTypeException { PanamaNFIContext ctx = PanamaNFIContext.get(this); try { - return ctx.getContextArena().allocateUtf8String(interop.asString(value)); + return ctx.getContextArena().allocateFrom(interop.asString(value)); } catch (UnsupportedMessageException ex) { throw UnsupportedTypeException.create(new Object[]{value}); } diff --git a/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/ClosureArgumentNode.java b/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/ClosureArgumentNode.java index 40cccf04755e..26769a1c4b42 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/ClosureArgumentNode.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/ClosureArgumentNode.java @@ -40,14 +40,14 @@ */ package com.oracle.truffle.nfi.backend.panama; +import java.lang.foreign.MemorySegment; + import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -import java.lang.foreign.MemorySegment; - abstract class ClosureArgumentNode extends Node { public abstract Object execute(VirtualFrame frame); @@ -117,9 +117,8 @@ Object doNull(@SuppressWarnings("unused") Object arg) { } @Fallback - @SuppressWarnings("preview") Object doString(Object arg) { - return ((MemorySegment) arg).getUtf8String(0); + return ((MemorySegment) arg).getString(0); } } } diff --git a/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/NativeString.java b/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/NativeString.java index 51a507ddc411..90061d69c357 100644 --- a/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/NativeString.java +++ b/truffle/src/com.oracle.truffle.nfi.backend.panama/src/com/oracle/truffle/nfi/backend/panama/NativeString.java @@ -40,6 +40,8 @@ */ package com.oracle.truffle.nfi.backend.panama; +import java.lang.foreign.MemorySegment; + import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.interop.InteropLibrary; @@ -47,8 +49,6 @@ import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import java.lang.foreign.MemorySegment; - @ExportLibrary(InteropLibrary.class) class NativeString implements TruffleObject { @@ -69,9 +69,8 @@ boolean isString() { } @ExportMessage - @SuppressWarnings("preview") String asString() { - return MemorySegment.ofAddress(this.nativePointer).getUtf8String(0); + return MemorySegment.ofAddress(this.nativePointer).getString(0); } @ExportMessage diff --git a/vm/ci/ci_common/common-bench.jsonnet b/vm/ci/ci_common/common-bench.jsonnet index c79e172d5232..eed07f557ae9 100644 --- a/vm/ci/ci_common/common-bench.jsonnet +++ b/vm/ci/ci_common/common-bench.jsonnet @@ -109,10 +109,10 @@ local repo_config = import '../../../ci/repo-configuration.libsonnet'; base_cmd:: ['mx', '--env', env], bench_cmd:: self.base_cmd + ['benchmark'] + (if (is_gate) then ['--fail-fast'] else []), interpreter_bench_cmd(vmConfig):: self.bench_cmd + - (if std.startsWith(vmConfig, 'jvm-') then + (if std.startsWith(vmConfig, 'jvm-') && self.jdk_version >= 22 then ['polybench:~r[(compiler/.*)|(warmup/.*)]'] else - ['polybench:~r[(compiler/.*)|(warmup/.*)|(.*panama.*)]'] # panama NFI backend only supported in JVM mode + ['polybench:~r[(compiler/.*)|(warmup/.*)|(.*panama.*)]'] # panama NFI backend only supported in JVM mode and on JDK 22+ [GR-49655] ) + ['--results-file', self.result_file, '--', '--polybench-vm=graalvm-${VM_ENV}', '--polybench-vm-config=' + vmConfig], compiler_bench_cmd(vmConfig):: self.bench_cmd + ['polybench:*[compiler/dispatch.js]', '--results-file', self.result_file, '--', '--polybench-vm=graalvm-${VM_ENV}', '--polybench-vm-config=' + vmConfig], warmup_bench_cmd(vmConfig):: self.bench_cmd + ['--fork-count-file', 'ci/ci_common/benchmark-forks.json', 'polybench:r[warmup/.*]', '--results-file', self.result_file, '--', '--polybench-vm=graalvm-${VM_ENV}', '--polybench-vm-config=' + vmConfig], @@ -218,9 +218,14 @@ local repo_config = import '../../../ci/repo-configuration.libsonnet'; vm_bench_polybench_nfi: { base_cmd:: ['mx', '--env', 'polybench-nfi-${VM_ENV}'], - bench_cmd_jvm:: self.base_cmd + ['benchmark', 'polybench:r[nfi/.*]', '--results-file', self.result_file, '--', '--polybench-vm=graalvm-${VM_ENV}', '--polybench-vm-config=jvm-standard'], - # Panama is not supported on native-image, once supported we can run [nfi/.*] like on jvm above (GR-46740) - bench_cmd_native:: self.base_cmd + ['benchmark', 'polybench:r[nfi/(downcall|upcall)_(many|prim|simple|env|void).*]', '--results-file', self.result_file, '--', '--polybench-vm=graalvm-${VM_ENV}', '--polybench-vm-config=native-standard'], + local nfi_panama = 'polybench:r[nfi/.*]', + local nfi_no_panama = 'polybench:r[nfi/(downcall|upcall)_(many|prim|simple|env|void).*]', + # Panama is only supported on JDK 22+ + local nfi_jvm = if self.jdk_version <= 22 then nfi_no_panama else nfi_panama, + # Panama is not supported on native-image, once supported we use nfi_jvm (GR-46740) + local nfi_ni = nfi_no_panama, + bench_cmd_jvm:: self.base_cmd + ['benchmark', nfi_jvm, '--results-file', self.result_file, '--', '--polybench-vm=graalvm-${VM_ENV}', '--polybench-vm-config=jvm-standard'], + bench_cmd_native:: self.base_cmd + ['benchmark', nfi_ni, '--results-file', self.result_file, '--', '--polybench-vm=graalvm-${VM_ENV}', '--polybench-vm-config=native-standard'], setup+: [ self.base_cmd + ['build'], self.base_cmd + ['build', '--dependencies=POLYBENCH_BENCHMARKS'], diff --git a/vm/mx.vm/suite.py b/vm/mx.vm/suite.py index ee0c6d430627..ff5b5b5ee3d1 100644 --- a/vm/mx.vm/suite.py +++ b/vm/mx.vm/suite.py @@ -33,7 +33,7 @@ "name": "graal-nodejs", "subdir": True, "dynamic": True, - "version": "95767f4db8df01a69fc77ba69335c9ce09a1165d", + "version": "0caaded94e1197d04d43324b95da107931249173", "urls" : [ {"url" : "https://github.com/graalvm/graaljs.git", "kind" : "git"}, ] @@ -42,7 +42,7 @@ "name": "graal-js", "subdir": True, "dynamic": True, - "version": "95767f4db8df01a69fc77ba69335c9ce09a1165d", + "version": "0caaded94e1197d04d43324b95da107931249173", "urls": [ {"url": "https://github.com/graalvm/graaljs.git", "kind" : "git"}, ] @@ -65,7 +65,7 @@ }, { "name": "graalpython", - "version": "e902929ead209962d2a4a1697f69054becf7e801", + "version": "9105e899f40095bc5b087c849f8ef902c65aae35", "dynamic": True, "urls": [ {"url": "https://github.com/graalvm/graalpython.git", "kind": "git"},