From 0817477002e2aa4f511a61e21709aa0566bb68f7 Mon Sep 17 00:00:00 2001 From: ol-automation_ww Date: Tue, 24 Oct 2023 21:31:15 +0000 Subject: [PATCH 01/61] update JVMCI to 22+20-jvmci-b01 --- common.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common.json b/common.json index 525cbf950225..af7ae56b05d9 100644 --- a/common.json +++ b/common.json @@ -43,12 +43,12 @@ "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 } + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231020202710-05da5ee692", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231020202710-05da5ee692-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231020202710-05da5ee692-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231020202710-05da5ee692+f4a1b58dac", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231020202710-05da5ee692+f4a1b58dac-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231020202710-05da5ee692+f4a1b58dac-sulong", "platformspecific": true } }, "eclipse": { From b715dfa7d53f75530e89238f5f9b4d2237d7e4b0 Mon Sep 17 00:00:00 2001 From: Marouane El Hallaoui Date: Wed, 25 Oct 2023 09:32:09 +0100 Subject: [PATCH 02/61] update OracleJDK22 --- common.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.json b/common.json index af7ae56b05d9..b05bc38d516b 100644 --- a/common.json +++ b/common.json @@ -42,7 +42,7 @@ "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"]}, + "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-b01-20231020202710-05da5ee692", "platformspecific": true }, "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231020202710-05da5ee692-debug", "platformspecific": true }, "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231020202710-05da5ee692-sulong", "platformspecific": true }, From 65aede5d7f7cd4fd7bd816882dad67c981462eb3 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Wed, 25 Oct 2023 12:40:35 +0200 Subject: [PATCH 03/61] truffle: move nfi.backend.panama out of preview and make it JDK 22 only [GR-49655] --- truffle/mx.truffle/suite.py | 7 +++---- .../oracle/truffle/nfi/backend/panama/ArgumentNode.java | 3 +-- .../truffle/nfi/backend/panama/ClosureArgumentNode.java | 7 +++---- .../oracle/truffle/nfi/backend/panama/NativeString.java | 7 +++---- 4 files changed, 10 insertions(+), 14 deletions(-) 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.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 From 0c2882885dc9dc267c27a44e6e18da40b9280ff9 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Fri, 27 Oct 2023 16:16:27 +0200 Subject: [PATCH 04/61] truffle: run 'Truffle NFI tests with Panama Backend' only on JDK 22 [GR-49655] --- truffle/mx.truffle/mx_truffle.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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'])) From 6b6cb37e268979330c20595c88a349a4eb4fb60d Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Fri, 27 Oct 2023 16:04:02 +0200 Subject: [PATCH 05/61] vm: exclude nfi.backend panama from polybench on JDK 21 [GR-49655] --- vm/ci/ci_common/common-bench.jsonnet | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/vm/ci/ci_common/common-bench.jsonnet b/vm/ci/ci_common/common-bench.jsonnet index a3a8a1428f0c..ab17dc17cd48 100644 --- a/vm/ci/ci_common/common-bench.jsonnet +++ b/vm/ci/ci_common/common-bench.jsonnet @@ -108,10 +108,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], @@ -217,9 +217,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'], From c0996a167d5378420c78e379defe2a386ee815f6 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Wed, 25 Oct 2023 20:24:16 +0200 Subject: [PATCH 06/61] Update labsjdk snapshots --- common.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common.json b/common.json index b05bc38d516b..5ec1be24beeb 100644 --- a/common.json +++ b/common.json @@ -43,12 +43,12 @@ "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": "20", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231020202710-05da5ee692", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231020202710-05da5ee692-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231020202710-05da5ee692-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231020202710-05da5ee692+f4a1b58dac", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231020202710-05da5ee692+f4a1b58dac-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231020202710-05da5ee692+f4a1b58dac-sulong", "platformspecific": true } + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231025124552-ffce44a31e", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231025124552-ffce44a31e-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231025124552-ffce44a31e-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231025124552-ffce44a31e+f4a1b58dac", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231025124552-ffce44a31e+f4a1b58dac-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231025124552-ffce44a31e+f4a1b58dac-sulong", "platformspecific": true } }, "eclipse": { From ca325a4c2a3cf5fbfabc6262b5912ec5b1c5caa8 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Fri, 27 Oct 2023 10:34:51 +0200 Subject: [PATCH 07/61] compiler: update JVMCIVersionCheck --- .../src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..494aa6ea4925 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", 1)); private static final int NA = 0; /** From 180261d41d24888d4439cb56c2813578103f2c01 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 27 Oct 2023 10:52:10 +0200 Subject: [PATCH 08/61] register Array.sort intrinsics (GR-48679) --- .../graal/compiler/hotspot/test/CheckGraalIntrinsics.java | 8 ++++++-- .../hotspot/meta/UnimplementedGraalIntrinsics.java | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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/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", From ba993c76e32b6f171c25be3ecaef06b915d75b9f Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Wed, 25 Oct 2023 21:12:13 +0200 Subject: [PATCH 09/61] svm: Module.ensureNativeAccess signature changed in JDK 22 [GR-49655] --- .../foreign/Target_java_lang_foreign_SymbolLookup.java | 8 +++++++- .../com/oracle/svm/core/jdk/Target_java_lang_Module.java | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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) { From 5a8a6ec9200db060c0144635bf75a959cba22c45 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 26 Oct 2023 10:43:37 +0200 Subject: [PATCH 10/61] svm: adopt "JDK- 8316304: (fs) Add support for BasicFileAttributes.creationTime() for Linux" https://github.com/openjdk/jdk/commit/0275efac882d263f85a723828a95d621f8dadbfb --- .../com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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")); From 5fdd714657689d75580b3092663bd105ea122b60 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Fri, 27 Oct 2023 10:48:35 +0200 Subject: [PATCH 11/61] svm: exclude foreign projects from spotbugs --- substratevm/mx.substratevm/suite.py | 4 ++++ 1 file changed, 4 insertions(+) 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 From 27ce2039309c66a2f751e55bf2868373edb1930e Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Fri, 27 Oct 2023 15:46:22 +0200 Subject: [PATCH 12/61] svm: adopt "JDK-8312522: Implementation of Foreign Function & Memory API" (out of preview) [GR-49655] --- .../ForeignFunctionsConfigurationParser.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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); + } + } } From 22c8c32fd576e81df582b99dc92b6835aba09eda Mon Sep 17 00:00:00 2001 From: Danilo Ansaloni Date: Mon, 30 Oct 2023 19:11:26 +0100 Subject: [PATCH 13/61] Update mx version (GR-49779). --- common.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.json b/common.json index 5ec1be24beeb..6352f64e9669 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": { From 1fa20d3b3f9c87c8fd03eae2ab2b2e7b36634e69 Mon Sep 17 00:00:00 2001 From: Josef Haider Date: Tue, 31 Oct 2023 20:23:33 +0100 Subject: [PATCH 14/61] TRegex: fix Truffle warnings for truffle-inlining, truffle-neverdefault and truffle-cached. --- .../regex/AbstractConstantKeysObject.java | 8 +-- .../oracle/truffle/regex/RegexExecNode.java | 4 +- .../com/oracle/truffle/regex/RegexObject.java | 18 +++--- .../regex/literal/LiteralRegexEngine.java | 10 +-- .../regex/literal/LiteralRegexExecNode.java | 54 ++++++++-------- .../truffle/regex/literal/package-info.java | 45 -------------- .../oracle/truffle/regex/package-info.java | 45 -------------- .../truffle/regex/result/RegexResult.java | 62 ++++++++++--------- .../truffle/regex/result/package-info.java | 45 -------------- .../regex/runtime/nodes/DispatchNode.java | 10 ++- .../regex/runtime/nodes/ExpectStringNode.java | 2 + .../regex/runtime/nodes/ToIntNode.java | 6 +- .../regex/runtime/nodes/ToLongNode.java | 6 +- .../regex/runtime/nodes/package-info.java | 45 -------------- .../tregex/nodes/TRegexExecutorNode.java | 4 +- .../dfa/DFAFindInnerLiteralStateNode.java | 2 +- .../regex/tregex/nodes/dfa/DFAStateNode.java | 3 +- .../nodes/dfa/TRegexDFAExecutorNode.java | 2 +- .../tregex/nodes/input/InputEndsWithNode.java | 14 ++--- .../tregex/nodes/input/InputEqualsNode.java | 13 ++-- .../tregex/nodes/input/InputIndexOfNode.java | 8 ++- .../nodes/input/InputIndexOfStringNode.java | 19 +++--- .../tregex/nodes/input/InputLengthNode.java | 14 +++-- .../tregex/nodes/input/InputReadNode.java | 20 +++--- .../nodes/input/InputRegionMatchesNode.java | 19 +++--- .../nodes/input/InputStartsWithNode.java | 13 ++-- .../tregex/nodes/input/package-info.java | 45 -------------- .../TRegexBacktrackingNFAExecutorNode.java | 4 +- .../regex/tregex/nodes/package-info.java | 45 -------------- .../truffle/api/strings/TruffleString.java | 1 + 30 files changed, 170 insertions(+), 416 deletions(-) delete mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/literal/package-info.java delete mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/package-info.java delete mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/result/package-info.java delete mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/runtime/nodes/package-info.java delete mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/input/package-info.java delete mode 100644 regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/package-info.java 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/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(); } From dbce69c2c385d81cd73fa567117d95126ac5b2ec Mon Sep 17 00:00:00 2001 From: Marouane El Hallaoui Date: Wed, 1 Nov 2023 09:58:22 +0100 Subject: [PATCH 15/61] update labsjdks --- common.json | 12 ++++++------ .../graal/compiler/hotspot/JVMCIVersionCheck.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common.json b/common.json index 6352f64e9669..f17666822a34 100644 --- a/common.json +++ b/common.json @@ -43,12 +43,12 @@ "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": "20", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231025124552-ffce44a31e", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231025124552-ffce44a31e-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+20-jvmci-b01-20231025124552-ffce44a31e-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231025124552-ffce44a31e+f4a1b58dac", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231025124552-ffce44a31e+f4a1b58dac-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+20-jvmci-b01-20231025124552-ffce44a31e+f4a1b58dac-sulong", "platformspecific": true } + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02-20231031145131-46b980eb0d", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02-20231031145131-46b980eb0d-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02-20231031145131-46b980eb0d-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02-20231031145131-46b980eb0d+f4a1b58dac", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02-20231031145131-46b980eb0d+f4a1b58dac-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02-20231031145131-46b980eb0d+f4a1b58dac-sulong", "platformspecific": true } }, "eclipse": { 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 494aa6ea4925..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+20", 1)); + "22", new Version("22+20", 2)); private static final int NA = 0; /** From e6c12dd389609f0eac07aa93d085fa33dd21bce0 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Wed, 12 Jul 2023 18:31:57 +0300 Subject: [PATCH 16/61] Throw exception for null in RuntimeJNIAccess/RuntimeReflection reg. Don't allow null values to be passed to the `register` method of `RuntimeJNIAccess` and `RuntimeReflection`. Since these are public APIs GraalVM should either handle null values (by ignoring them in this case) or throw a `NullPointerException` before creating an asynchronous task to perform the registration in the analysis, which then results in `NullPointerException`s being thrown later when it's no longer possible to understand where the null value originate from. --- .../nativeimage/impl/ReflectionRegistry.java | 8 +- substratevm/mx.substratevm/mx_substratevm.py | 4 +- .../ConditionalConfigurationRegistry.java | 8 ++ .../hosted/reflect/ReflectionDataBuilder.java | 8 ++ .../svm/test/ReflectionRegistrationTest.java | 120 ++++++++++++++++++ 5 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/ReflectionRegistrationTest.java diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java index 4198a895ec06..7f1141b6435d 100644 --- a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java +++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java @@ -46,7 +46,13 @@ public interface ReflectionRegistry { default void register(ConfigurationCondition condition, Class... classes) { - Arrays.stream(classes).forEach(clazz -> register(condition, false, clazz)); + Arrays.stream(classes).forEach(clazz -> { + if (clazz == null) { + throw new NullPointerException("Cannot register null value as class for reflection. " + + "Please ensure that all values you register are not null."); + } + register(condition, false, clazz); + }); } void register(ConfigurationCondition condition, boolean unsafeAllocated, Class clazz); 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/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..e696f21e3031 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 @@ -38,6 +38,14 @@ public abstract class ConditionalConfigurationRegistry { private final Map> pendingReachabilityHandlers = new ConcurrentHashMap<>(); protected void registerConditionalConfiguration(ConfigurationCondition condition, Runnable runnable) { + if (condition == null) { + throw new NullPointerException("Cannot use null value as condition for conditional configuration. " + + "Please ensure that you register a non-null condition."); + } + if (runnable == null) { + throw new NullPointerException("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/reflect/ReflectionDataBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionDataBuilder.java index d7fa9f2f1c37..1a81548280de 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 @@ -272,6 +272,10 @@ public void register(ConfigurationCondition condition, boolean queriedOnly, Exec checkNotSealed(); register(analysisUniverse -> registerConditionalConfiguration(condition, () -> { for (Executable executable : executables) { + if (executable == null) { + throw new NullPointerException("Cannot register null value as executable for reflection. " + + "Please ensure that all values you register are not null."); + } analysisUniverse.getBigbang().postTask(debug -> registerMethod(queriedOnly, executable)); } })); @@ -404,6 +408,10 @@ public void register(ConfigurationCondition condition, boolean finalIsWritable, private void registerInternal(ConfigurationCondition condition, Field... fields) { register(analysisUniverse -> registerConditionalConfiguration(condition, () -> { for (Field field : fields) { + if (field == null) { + throw new NullPointerException("Cannot register null value as field for reflection. " + + "Please ensure that all values you register are not null."); + } analysisUniverse.getBigbang().postTask(debug -> registerField(field)); } })); 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 + } +} From c316d967ec5fcf13b1f307450609147c57f02bc5 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 10 Oct 2023 12:44:42 +0200 Subject: [PATCH 17/61] Sulong: adding some temp debugging print outs --- .../oracle/truffle/llvm/runtime/LLVMContext.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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..d5f386524741 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(); + System.out.println("symbol is: " + symbol.getName()); + System.out.println("id is: " + id); + System.out.println("index is: " + index); + System.out.println("library loaded: " + this.libraryLoaded); + System.out.println("library paths: " + this.libraryPaths); + System.out.println("truffle files: " + this.truffleFiles); + System.out.println("symbolFinalStorage is: " + symbolFinalStorage); 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(); + System.out.println("symbol is: " + symbol.getName()); + System.out.println("id is: " + id); + System.out.println("index is: " + index); + System.out.println("library loaded: " + this.libraryLoaded); + System.out.println("library paths: " + this.libraryPaths); + System.out.println("truffle files: " + this.truffleFiles); + System.out.println("symbolDynamicStorage is: " + symbolDynamicStorage); throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } From 8e49925cb86100a9bdaaa16dfd3cc3024271be57 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 10 Oct 2023 12:45:19 +0200 Subject: [PATCH 18/61] Sulong: minor --- .../src/com/oracle/truffle/llvm/runtime/LLVMContext.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 d5f386524741..f78d373df1ef 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 @@ -818,10 +818,11 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws System.out.println("symbol is: " + symbol.getName()); System.out.println("id is: " + id); System.out.println("index is: " + index); + System.out.println("symbolFinalStorage is: " + symbolFinalStorage); System.out.println("library loaded: " + this.libraryLoaded); System.out.println("library paths: " + this.libraryPaths); System.out.println("truffle files: " + this.truffleFiles); - System.out.println("symbolFinalStorage is: " + symbolFinalStorage); + System.out.println("source cache: " + this.getSourceContext()); throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } else { @@ -832,10 +833,11 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws System.out.println("symbol is: " + symbol.getName()); System.out.println("id is: " + id); System.out.println("index is: " + index); + System.out.println("symbolDynamicStorage is: " + symbolDynamicStorage); System.out.println("library loaded: " + this.libraryLoaded); System.out.println("library paths: " + this.libraryPaths); System.out.println("truffle files: " + this.truffleFiles); - System.out.println("symbolDynamicStorage is: " + symbolDynamicStorage); + System.out.println("source cache: " + this.getSourceContext()); throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } From 0d49b8e967063d04c2fc9217056c7238a1e47e97 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 10 Oct 2023 13:53:41 +0200 Subject: [PATCH 19/61] Sulong: disable test cpp/test021.cpp --- .../cpp/test021.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp index 9c8717aa6b34..d75a4a7a8dc7 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp @@ -42,7 +42,7 @@ int main() { try { throw exc; } catch (exception &e) { - printf("%s\n", e.what()); + //printf("%s\n", e.what()); return 0; } return 1; From bc21bb536a07807d4a7e3788e18675695eeb5a45 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 10 Oct 2023 14:29:57 +0200 Subject: [PATCH 20/61] Sulong: minor --- .../cpp/test021.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp index d75a4a7a8dc7..56a2b17479bf 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp @@ -40,7 +40,7 @@ class fooexception : public exception { int main() { try { - throw exc; + //throw exc; } catch (exception &e) { //printf("%s\n", e.what()); return 0; From 1a744406dd1e127d7872994cbe1a675a2b7ccded Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 10 Oct 2023 15:01:17 +0200 Subject: [PATCH 21/61] Sulong: disable test039 --- .../cpp/test039.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp index 33105208fcb7..370d54513dc1 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp @@ -42,7 +42,7 @@ struct A { }; int main() { - try { + /*try { try { try { A a; @@ -58,6 +58,6 @@ int main() { } catch (A &e) { printf("C2\n"); return 0; - } + }*/ return -1; } From e70622c71b710587dc2eb5fe527886e937c79f4f Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 10 Oct 2023 15:54:25 +0200 Subject: [PATCH 22/61] Sulong: disable test050 --- .../src/com/oracle/truffle/llvm/runtime/LLVMContext.java | 2 -- .../cpp/test028.cpp | 3 ++- .../cpp/test039.cpp | 2 +- .../cpp/test050.cpp | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) 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 f78d373df1ef..09f87b76fbf7 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 @@ -822,7 +822,6 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws System.out.println("library loaded: " + this.libraryLoaded); System.out.println("library paths: " + this.libraryPaths); System.out.println("truffle files: " + this.truffleFiles); - System.out.println("source cache: " + this.getSourceContext()); throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } else { @@ -837,7 +836,6 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws System.out.println("library loaded: " + this.libraryLoaded); System.out.println("library paths: " + this.libraryPaths); System.out.println("truffle files: " + this.truffleFiles); - System.out.println("source cache: " + this.getSourceContext()); throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test028.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test028.cpp index b316715f220d..f57f9aab5659 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test028.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test028.cpp @@ -36,7 +36,8 @@ void foo() throw(int) { int main() { try { - foo(); + //foo(); + return 0; } catch (...) { printf("Caught int exception\n"); } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp index 370d54513dc1..fea9955af2c3 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp @@ -59,5 +59,5 @@ int main() { printf("C2\n"); return 0; }*/ - return -1; + return 0; } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test050.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test050.cpp index e2365fa5a10f..cc2edc72e91a 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test050.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test050.cpp @@ -44,7 +44,7 @@ struct A { }; int main() { - try { + /*try { try { try { A a; @@ -60,6 +60,6 @@ int main() { } catch (A e) { printf("C2\n"); return 0; - } - return -1; + }*/ + return 0; } From efaa8573e4eeae3ba5e3d3060030bd69b115bef2 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 10 Oct 2023 16:25:27 +0200 Subject: [PATCH 23/61] Sulong: disable test040 --- .../cpp/test040.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test040.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test040.cpp index 23436e2b82bd..4bf713d30684 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test040.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test040.cpp @@ -42,7 +42,7 @@ struct A { }; int main() { - try { + /*try { try { try { A a; @@ -58,6 +58,6 @@ int main() { } catch (A e) { printf("C2\n"); return 0; - } - return -1; + }*/ + return 0; } From 89e50a3c6b12a8d1434dd34653cbc81bfbb41fd3 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 11 Oct 2023 10:04:22 +0200 Subject: [PATCH 24/61] Sulong: disable tests048, more debugging print out --- .../truffle/llvm/runtime/LLVMContext.java | 51 +++++++++++++++---- .../cpp/test048.cpp | 6 +-- 2 files changed, 44 insertions(+), 13 deletions(-) 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 09f87b76fbf7..0a173a88952c 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 @@ -814,28 +814,59 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws try { return symbolFinalStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { - exception.enter(); + //exception.enter(); System.out.println("symbol is: " + symbol.getName()); System.out.println("id is: " + id); System.out.println("index is: " + index); - System.out.println("symbolFinalStorage is: " + symbolFinalStorage); - System.out.println("library loaded: " + this.libraryLoaded); - System.out.println("library paths: " + this.libraryPaths); - System.out.println("truffle files: " + this.truffleFiles); + + System.out.println("symbolFinalStorage length is: " + symbolFinalStorage.length + ", when compared against id: " + id); + System.out.println("symbolFinalStorage is: "); + for (int i = 0; i < symbolFinalStorage.length; i++) { + LLVMPointer[] pointers = symbolFinalStorage[i]; + if (id == i) { + System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); + } else { + System.out.println("Length for " + i + " array : " + pointers.length); + } + for (int j = 0; j < pointers.length; j++) { + System.out.println("(" + i + ", " + j + ") : " + pointers[j]); + } + } + + System.out.println("library loaded:") ; + for (int i = 0; i < libraryLoaded.length; i++) { + System.out.println(i + " : " + this.libraryLoaded[i]); + } + throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } else { try { return symbolDynamicStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { - exception.enter(); + //exception.enter(); System.out.println("symbol is: " + symbol.getName()); System.out.println("id is: " + id); System.out.println("index is: " + index); - System.out.println("symbolDynamicStorage is: " + symbolDynamicStorage); - System.out.println("library loaded: " + this.libraryLoaded); - System.out.println("library paths: " + this.libraryPaths); - System.out.println("truffle files: " + this.truffleFiles); + System.out.println("symbolFinalStorage length is: " + symbolDynamicStorage.length + ", when compared against id: " + id); + System.out.println("symbolFinalStorage is: "); + for (int i = 0; i < symbolDynamicStorage.length; i++) { + LLVMPointer[] pointers = symbolDynamicStorage[i]; + if (id == i) { + System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); + } else { + System.out.println("Length for " + i + " array : " + pointers.length); + } + for (int j = 0; j < pointers.length; j++) { + System.out.println("(" + i + ", " + j + ") : " + pointers[j]); + } + } + + System.out.println("library loaded:") ; + for (int i = 0; i < libraryLoaded.length; i++) { + System.out.println(i + " : " + this.libraryLoaded[i]); + } + throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test048.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test048.cpp index 2356c862de07..f7e21613d3bc 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test048.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test048.cpp @@ -44,7 +44,7 @@ struct A { }; int main() { - try { + /*try { try { try { A a; @@ -60,6 +60,6 @@ int main() { } catch (A &e) { printf("C2\n"); return 0; - } - return -1; + }*/ + return 0; } From 60db8ac0c6f01d4e774bfce714b4094bb9a3cbfc Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 11 Oct 2023 10:34:42 +0200 Subject: [PATCH 25/61] Sulong: minor --- .../truffle/llvm/runtime/LLVMContext.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) 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 0a173a88952c..5b8b56e72770 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 @@ -823,13 +823,18 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws System.out.println("symbolFinalStorage is: "); for (int i = 0; i < symbolFinalStorage.length; i++) { LLVMPointer[] pointers = symbolFinalStorage[i]; - if (id == i) { - System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); + if (pointers != null) { + if (id == i) { + System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); + } else { + System.out.println("Length for " + i + " array : " + pointers.length); + } + for (int j = 0; j < pointers.length; j++) { + System.out.println("(" + i + ", " + j + ") : " + pointers[j]); + } + System.out.println(); } else { - System.out.println("Length for " + i + " array : " + pointers.length); - } - for (int j = 0; j < pointers.length; j++) { - System.out.println("(" + i + ", " + j + ") : " + pointers[j]); + System.out.println("Length for " + i + " array : 0"); } } @@ -852,13 +857,18 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws System.out.println("symbolFinalStorage is: "); for (int i = 0; i < symbolDynamicStorage.length; i++) { LLVMPointer[] pointers = symbolDynamicStorage[i]; - if (id == i) { - System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); + if (pointers != null) { + if (id == i) { + System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); + } else { + System.out.println("Length for " + i + " array : " + pointers.length); + } + for (int j = 0; j < pointers.length; j++) { + System.out.print("(" + i + ", " + j + ") : " + pointers[j] + ", "); + } + System.out.println(); } else { - System.out.println("Length for " + i + " array : " + pointers.length); - } - for (int j = 0; j < pointers.length; j++) { - System.out.println("(" + i + ", " + j + ") : " + pointers[j]); + System.out.println("Length for " + i + " array : 0"); } } From eec0748fe18d8657f670f5c7fba90b1c73cae59d Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 11 Oct 2023 10:57:53 +0200 Subject: [PATCH 26/61] disable test044 --- .../cpp/test044.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test044.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test044.cpp index c1180a348fba..3c338af07459 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test044.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test044.cpp @@ -50,8 +50,8 @@ void foo() { int main() { try { - foo(); - return 1; + //foo(); + return 0; } catch (...) { printf("CATCH\n"); return 0; From f2141f9b2f49e1777e437f9bac9feb0926c5c9b6 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 11 Oct 2023 11:25:59 +0200 Subject: [PATCH 27/61] Sulong: disable test049 --- .../cpp/test049.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test049.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test049.cpp index c49841767c8c..f8c8718962a8 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test049.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test049.cpp @@ -44,7 +44,7 @@ struct A { }; int main() { - try { + /*try { try { try { A a; @@ -60,6 +60,6 @@ int main() { } catch (A &e) { printf("C2\n"); return 0; - } - return -1; + }*/ + return 0; } From b5b657d2a79e0722b1f0052fa4b2a03bc76bf716 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 11 Oct 2023 16:40:04 +0200 Subject: [PATCH 28/61] Sulong: enable some tests, add library name to bitcodes --- .../truffle/llvm/runtime/IDGenerater.java | 20 +++++--- .../truffle/llvm/runtime/LLVMContext.java | 48 ++++++++++--------- .../truffle/llvm/runtime/LLVMLanguage.java | 4 +- .../cpp/test021.cpp | 4 +- .../cpp/test028.cpp | 3 +- .../cpp/test039.cpp | 6 +-- .../cpp/test040.cpp | 6 +-- .../cpp/test044.cpp | 4 +- .../cpp/test048.cpp | 6 +-- .../cpp/test049.cpp | 6 +-- .../cpp/test050.cpp | 6 +-- 11 files changed, 60 insertions(+), 53 deletions(-) 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..aefebce387a2 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 @@ -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 5b8b56e72770..5596e47f5a5b 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 @@ -814,35 +814,36 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws try { return symbolFinalStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { - //exception.enter(); + //exception.enter();) System.out.println("symbol is: " + symbol.getName()); System.out.println("id is: " + id); + System.out.println("id name is: " + bitcodeID.getName()); System.out.println("index is: " + index); System.out.println("symbolFinalStorage length is: " + symbolFinalStorage.length + ", when compared against id: " + id); System.out.println("symbolFinalStorage is: "); for (int i = 0; i < symbolFinalStorage.length; i++) { - LLVMPointer[] pointers = symbolFinalStorage[i]; - if (pointers != null) { - if (id == i) { + if (id == i) { + LLVMPointer[] pointers = symbolFinalStorage[i]; + if (pointers != null) { System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); + for (int j = 0; j < pointers.length; j++) { + System.out.println("(" + i + ", " + j + ") : " + pointers[j]); + } } else { - System.out.println("Length for " + i + " array : " + pointers.length); - } - for (int j = 0; j < pointers.length; j++) { - System.out.println("(" + i + ", " + j + ") : " + pointers[j]); + System.out.println("Length for " + i + " array : 0"); } - System.out.println(); - } else { - System.out.println("Length for " + i + " array : 0"); } } - System.out.println("library loaded:") ; + System.out.println("library loaded:"); for (int i = 0; i < libraryLoaded.length; i++) { System.out.println(i + " : " + this.libraryLoaded[i]); } + System.out.println("stack trace:"); + e.printStackTrace(); + throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } else { @@ -852,31 +853,32 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws //exception.enter(); System.out.println("symbol is: " + symbol.getName()); System.out.println("id is: " + id); + System.out.println("id name is: " + bitcodeID.getName()); System.out.println("index is: " + index); System.out.println("symbolFinalStorage length is: " + symbolDynamicStorage.length + ", when compared against id: " + id); System.out.println("symbolFinalStorage is: "); for (int i = 0; i < symbolDynamicStorage.length; i++) { - LLVMPointer[] pointers = symbolDynamicStorage[i]; - if (pointers != null) { - if (id == i) { + if (id == i) { + LLVMPointer[] pointers = symbolDynamicStorage[i]; + if (pointers != null) { System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); + for (int j = 0; j < pointers.length; j++) { + System.out.println("(" + i + ", " + j + ") : " + pointers[j]); + } } else { - System.out.println("Length for " + i + " array : " + pointers.length); + System.out.println("Length for " + i + " array : 0"); } - for (int j = 0; j < pointers.length; j++) { - System.out.print("(" + i + ", " + j + ") : " + pointers[j] + ", "); - } - System.out.println(); - } else { - System.out.println("Length for " + i + " array : 0"); } } - System.out.println("library loaded:") ; + System.out.println("library loaded:"); for (int i = 0; i < libraryLoaded.length; i++) { System.out.println(i + " : " + this.libraryLoaded[i]); } + System.out.println("stack trace:"); + e.printStackTrace(); + 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..a1db697dd414 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 @@ -767,7 +767,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,7 +779,7 @@ 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())); } } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp index 56a2b17479bf..9c8717aa6b34 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test021.cpp @@ -40,9 +40,9 @@ class fooexception : public exception { int main() { try { - //throw exc; + throw exc; } catch (exception &e) { - //printf("%s\n", e.what()); + printf("%s\n", e.what()); return 0; } return 1; diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test028.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test028.cpp index f57f9aab5659..b316715f220d 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test028.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test028.cpp @@ -36,8 +36,7 @@ void foo() throw(int) { int main() { try { - //foo(); - return 0; + foo(); } catch (...) { printf("Caught int exception\n"); } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp index fea9955af2c3..33105208fcb7 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test039.cpp @@ -42,7 +42,7 @@ struct A { }; int main() { - /*try { + try { try { try { A a; @@ -58,6 +58,6 @@ int main() { } catch (A &e) { printf("C2\n"); return 0; - }*/ - return 0; + } + return -1; } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test040.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test040.cpp index 4bf713d30684..23436e2b82bd 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test040.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test040.cpp @@ -42,7 +42,7 @@ struct A { }; int main() { - /*try { + try { try { try { A a; @@ -58,6 +58,6 @@ int main() { } catch (A e) { printf("C2\n"); return 0; - }*/ - return 0; + } + return -1; } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test044.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test044.cpp index 3c338af07459..c1180a348fba 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test044.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test044.cpp @@ -50,8 +50,8 @@ void foo() { int main() { try { - //foo(); - return 0; + foo(); + return 1; } catch (...) { printf("CATCH\n"); return 0; diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test048.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test048.cpp index f7e21613d3bc..2356c862de07 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test048.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test048.cpp @@ -44,7 +44,7 @@ struct A { }; int main() { - /*try { + try { try { try { A a; @@ -60,6 +60,6 @@ int main() { } catch (A &e) { printf("C2\n"); return 0; - }*/ - return 0; + } + return -1; } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test049.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test049.cpp index f8c8718962a8..c49841767c8c 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test049.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test049.cpp @@ -44,7 +44,7 @@ struct A { }; int main() { - /*try { + try { try { try { A a; @@ -60,6 +60,6 @@ int main() { } catch (A &e) { printf("C2\n"); return 0; - }*/ - return 0; + } + return -1; } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test050.cpp b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test050.cpp index cc2edc72e91a..e2365fa5a10f 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test050.cpp +++ b/sulong/tests/com.oracle.truffle.llvm.tests.sulongcpp.native/cpp/test050.cpp @@ -44,7 +44,7 @@ struct A { }; int main() { - /*try { + try { try { try { A a; @@ -60,6 +60,6 @@ int main() { } catch (A e) { printf("C2\n"); return 0; - }*/ - return 0; + } + return -1; } From e794ce04e3723c83f4356334e6314de1439eb3ba Mon Sep 17 00:00:00 2001 From: Paley Li Date: Thu, 12 Oct 2023 16:46:30 +0200 Subject: [PATCH 29/61] Sulong: disable native lookup optimisation --- .../nodes/func/LLVMLookupDispatchTargetNode.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java index 791351bf38c1..4660fff94494 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java @@ -30,17 +30,14 @@ package com.oracle.truffle.llvm.runtime.nodes.func; 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.GenerateAOT; 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.library.CachedLibrary; import com.oracle.truffle.llvm.runtime.LLVMContext; import com.oracle.truffle.llvm.runtime.LLVMFunction; import com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor; -import com.oracle.truffle.llvm.runtime.except.LLVMIllegalSymbolIndexException; import com.oracle.truffle.llvm.runtime.library.internal.LLVMAsForeignLibrary; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; import com.oracle.truffle.llvm.runtime.nodes.memory.load.LLVMDerefHandleGetReceiverNode; @@ -48,7 +45,6 @@ import com.oracle.truffle.llvm.runtime.nodes.others.LLVMAccessGlobalSymbolNodeGen; import com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer; import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer; -import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer; @NodeChild(value = "function", type = LLVMExpressionNode.class) public abstract class LLVMLookupDispatchTargetNode extends LLVMExpressionNode { @@ -94,16 +90,16 @@ protected static LLVMNativePointer doNativeFunctionCached(LLVMNativePointer poin * Try to cache the target symbol if it's always the same one, the reverse lookup is much faster * and doesn't need a TruffleBoundary. */ - @Specialization(guards = {"!isAutoDerefHandle(pointer.asNative())", "cachedSymbol != null"}, replaces = {"doHandleCached", + /*@Specialization(guards = {"!isAutoDerefHandle(pointer.asNative())", "cachedSymbol != null"}, replaces = {"doHandleCached", "doNativeFunctionCached"}, rewriteOn = LLVMIllegalSymbolIndexException.class) protected Object doLookupNativeFunctionCachedSymbol(VirtualFrame frame, LLVMNativePointer pointer, - @Cached("lookupFunctionSymbol(pointer)") LLVMAccessGlobalSymbolNode cachedSymbol) { + @Cached("lookupFunctionSymbol(pointer)") LLVMAccessGlobalSymbolNode cachedSymbol) {*/ /* * The cache will be invalidated if the symbol cannot be found in the symbol table. In which * case the entire specialisation will be rewritten when the context throws an * LLVMIllegalSymbolIndexException. */ - LLVMPointer symbolPointer = cachedSymbol.executeGeneric(frame); + /*LLVMPointer symbolPointer = cachedSymbol.executeGeneric(frame); // guard against uninitialized symbols in multi-context cases if (LLVMManagedPointer.isInstance(symbolPointer)) { @@ -118,7 +114,7 @@ protected Object doLookupNativeFunctionCachedSymbol(VirtualFrame frame, LLVMNati } CompilerDirectives.transferToInterpreterAndInvalidate(); throw new LLVMIllegalSymbolIndexException("mismatching function"); - } + }*/ @Specialization(guards = "!isAutoDerefHandle(pointer.asNative())", replaces = {"doLookupNativeFunctionCachedSymbol", "doHandleCached", "doNativeFunctionCached"}) protected Object doLookup(LLVMNativePointer pointer) { From 76317ac00d26651838a71157da67d34649b78d4a Mon Sep 17 00:00:00 2001 From: Paley Li Date: Thu, 12 Oct 2023 16:52:45 +0200 Subject: [PATCH 30/61] Sulong: minor --- .../llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java index 4660fff94494..688b0c4c9c93 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java @@ -116,7 +116,8 @@ protected Object doLookupNativeFunctionCachedSymbol(VirtualFrame frame, LLVMNati throw new LLVMIllegalSymbolIndexException("mismatching function"); }*/ - @Specialization(guards = "!isAutoDerefHandle(pointer.asNative())", replaces = {"doLookupNativeFunctionCachedSymbol", "doHandleCached", "doNativeFunctionCached"}) + @Specialization(guards = "!isAutoDerefHandle(pointer.asNative())", //replaces = {"doLookupNativeFunctionCachedSymbol", "doHandleCached", "doNativeFunctionCached"}) + replaces = {"doHandleCached", "doNativeFunctionCached"}) protected Object doLookup(LLVMNativePointer pointer) { LLVMFunctionDescriptor descriptor = lookupFunction(pointer); if (descriptor != null) { From be3a2ce43219d28c3e312a65d6f9bab6fe771ea8 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Fri, 13 Oct 2023 12:01:02 +0200 Subject: [PATCH 31/61] Sulong: print out debugging info in test harness --- .../truffle/llvm/tests/util/ProcessUtil.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java index b53ab15298d2..0b3d7a145f7d 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java @@ -36,6 +36,7 @@ import org.graalvm.polyglot.Context.Builder; import org.graalvm.polyglot.Engine; import org.graalvm.polyglot.Value; +import org.junit.Assert; import java.io.ByteArrayOutputStream; import java.io.Closeable; @@ -50,8 +51,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; -import org.junit.Assert; - public class ProcessUtil { private static final int BUFFER_SIZE = 1024; @@ -187,7 +186,16 @@ public ProcessResult run(File bitcodeFile, String[] args, Map op Assert.fail("No main function found."); } if (!evalSourceOnly) { - result = main.execute().asInt(); + try { + result = main.execute().asInt(); + } catch (Exception e) { + System.out.println("Print out.getStdErr(): "); + System.out.println(out.getStdErr()); + System.out.println("***************************************"); + System.out.println("Print out.getStdOut(): "); + System.out.println(out.getStdOut()); + + } } } return new ProcessResult(bitcodeFile.getName(), result, out.getStdErr(), out.getStdOut()); From 4f7708ae0f9fd0a4ed86b8e0d9180d09583a7a9b Mon Sep 17 00:00:00 2001 From: Paley Li Date: Fri, 13 Oct 2023 14:33:55 +0200 Subject: [PATCH 32/61] Sulong: add more debugging info to test harness --- .../truffle/llvm/tests/BaseSuiteHarness.java | 3 ++- .../truffle/llvm/tests/util/ProcessUtil.java | 27 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java index 50d12b5aa7ed..3d3c80032bb7 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java @@ -35,7 +35,6 @@ import com.oracle.truffle.llvm.tests.util.ProcessUtil; import com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult; import com.oracle.truffle.llvm.tests.util.ProcessUtil.TestEngineMode; - import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Engine; import org.junit.AfterClass; @@ -227,6 +226,8 @@ private ProcessResult runReference(Path referenceBinary) { if (retries++ >= MAX_RETRIES) { throw e; } + } catch (IOException e) { + throw new RuntimeException(e); } } } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java index 0b3d7a145f7d..0369bf381978 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java @@ -194,7 +194,6 @@ public ProcessResult run(File bitcodeFile, String[] args, Map op System.out.println("***************************************"); System.out.println("Print out.getStdOut(): "); System.out.println(out.getStdOut()); - } } } @@ -217,7 +216,17 @@ public SeparateProcessEngineMode() throws IOException { @Override public ProcessResult run(File bitcodeFile, String[] args, Map options, boolean evalSourceOnly) throws IOException { - return manager.startTask(bitcodeFile.getAbsolutePath()).get(); + ProcessResult pr = null; + try { + pr = manager.startTask(bitcodeFile.getAbsolutePath()).get(); + } catch (Exception e) { + System.out.println("Print pr.getStdErr(): "); + System.out.println(pr.getStdErr()); + System.out.println("***************************************"); + System.out.println("Print pr.getStdOut(): "); + System.out.println(pr.getStdOutput()); + } + return pr; } @Override @@ -262,16 +271,18 @@ private static List concatOptions(Map options) { return optList; } - public static ProcessResult executeNativeCommand(List command) { + public static ProcessResult executeNativeCommand(List command) throws IOException { if (command == null) { throw new IllegalArgumentException("command is null!"); } ProcessBuilder processBuilder = new ProcessBuilder(command); Process process = null; + StreamReader readError = null; + StreamReader readOutput = null; try { process = processBuilder.start(); - StreamReader readError = StreamReader.read(process.getErrorStream()); - StreamReader readOutput = StreamReader.read(process.getInputStream()); + readError = StreamReader.read(process.getErrorStream()); + readOutput = StreamReader.read(process.getInputStream()); boolean success = process.waitFor(PROCESS_WAIT_TIMEOUT, TimeUnit.MILLISECONDS); if (!success) { throw new TimeoutError(command.toString()); @@ -279,6 +290,12 @@ public static ProcessResult executeNativeCommand(List command) { int llvmResult = process.exitValue(); return new ProcessResult(command.toString(), llvmResult, readError.getResult(), readOutput.getResult()); } catch (Exception e) { + System.out.println("Print readOutput.getResult(): "); + assert readOutput != null; + System.out.println(readOutput.getResult()); + System.out.println("***************************************"); + System.out.println("Print readError.getResult(): "); + System.out.println(readError.getResult()); throw new RuntimeException(command + " ", e); } finally { if (process != null) { From 0674e8307e3f4cd8ce6c78442d890a6b9cdf9fda Mon Sep 17 00:00:00 2001 From: Paley Li Date: Fri, 13 Oct 2023 18:14:22 +0200 Subject: [PATCH 33/61] Sulong: minor --- .../src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java index 0369bf381978..29b9503d1637 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java @@ -194,6 +194,8 @@ public ProcessResult run(File bitcodeFile, String[] args, Map op System.out.println("***************************************"); System.out.println("Print out.getStdOut(): "); System.out.println(out.getStdOut()); + throw new RuntimeException(e); + } } } @@ -225,6 +227,7 @@ public ProcessResult run(File bitcodeFile, String[] args, Map op System.out.println("***************************************"); System.out.println("Print pr.getStdOut(): "); System.out.println(pr.getStdOutput()); + throw new RuntimeException(e); } return pr; } From 15f3be6984488a8d09bdce5c756262efeed42632 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Mon, 16 Oct 2023 16:16:13 +0200 Subject: [PATCH 34/61] Sulong: minor --- .../src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java | 1 + 1 file changed, 1 insertion(+) diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java index 3d3c80032bb7..0377c55baac3 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java @@ -196,6 +196,7 @@ private void runCandidate(Path referenceBinary, ProcessResult referenceResult, P try { result = testEngineMode.run(candidateBinary.toAbsolutePath().toFile(), inputArgs, getContextOptions(candidateBinary.toAbsolutePath().toString()), evaluateSourceOnly()); } catch (Exception e) { + System.out.println("*************Failure in BaseSuiteHarness.runCandidate()*************"); throw fail(getTestName(), new Exception("Candidate binary that failed: " + candidateBinary, e)); } From 2096ac89cccb74cc176ae6dbf88c2e9c1dea873b Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 17 Oct 2023 10:08:04 +0200 Subject: [PATCH 35/61] Sulong: add logging --- sulong/ci/ci.jsonnet | 2 +- sulong/mx.sulong/mx_sulong_gate.py | 2 +- .../src/com/oracle/truffle/llvm/runtime/LLVMContext.java | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sulong/ci/ci.jsonnet b/sulong/ci/ci.jsonnet index 3e4651fbb995..575da3601fb9 100644 --- a/sulong/ci/ci.jsonnet +++ b/sulong/ci/ci.jsonnet @@ -40,7 +40,7 @@ local sc = (import "ci_common/sulong-common.jsonnet"); 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"] }, + 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"], logs+: ["sulong/log.txt"] }, 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" }, diff --git a/sulong/mx.sulong/mx_sulong_gate.py b/sulong/mx.sulong/mx_sulong_gate.py index 119492b4f5b2..ee53b7b6d3af 100644 --- a/sulong/mx.sulong/mx_sulong_gate.py +++ b/sulong/mx.sulong/mx_sulong_gate.py @@ -188,7 +188,7 @@ def _unittest(title, test_suite, tags=None, testClasses=None, unittestArgs=None, _unittest('GCC_Fortran', 'SULONG_GCC_FORTRAN_TEST_SUITE', description="GCC 5.2 test suite (Fortran tests)", testClasses=['GccFortranSuite'], tags=['gcc_fortran']) _unittest('Sulong', 'SULONG_STANDALONE_TEST_SUITES', description="Sulong's internal tests", testClasses='SulongSuite', tags=['sulongStandalone', 'sulongBasic', 'standalone'], # run only a small subset of the tests on the jvm standalone, the startup overhead per test is too high for more - extraUnittestArgs=['-Dsulongtest.testNameFilter=cpp'] if slowStandalone else []) + extraUnittestArgs=['-Dsulongtest.testNameFilter=cpp', '-Dpolyglot.log.llvm.Loader.level=ALL', '-Dpolyglot.log.file=log.txt'] if slowStandalone else ['-Dpolyglot.log.llvm.Loader.level=ALL', '-Dpolyglot.log.file=log.txt']) _unittest('Interop', 'SULONG_EMBEDDED_TEST_SUITES', description="Truffle Language interoperability tests", testClasses=['com.oracle.truffle.llvm.tests.interop.'], tags=['interop', 'sulongBasic', 'sulongWinSupport']) if standaloneMode is None: # can't test with resources in standalone mode 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 5596e47f5a5b..1fa12539b3f0 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,15 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws return symbolFinalStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { //exception.enter();) + + loaderLogger.log(Level.FINEST, "stack trace:"); + 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); + + System.out.println("symbol is: " + symbol.getName()); System.out.println("id is: " + id); System.out.println("id name is: " + bitcodeID.getName()); From 1d8e2545f13c5654e9134528f92301b855e0cfe6 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 17 Oct 2023 10:27:27 +0200 Subject: [PATCH 36/61] Sulong: remove exclude list --- .../darwin/aarch64/tmp-cpp-tests.exclude | 80 ------------------- .../darwin/amd64/tmp-cpp-tests.exclude | 80 ------------------- 2 files changed, 160 deletions(-) delete mode 100644 sulong/tests/configs/SulongSuite/os_arch/darwin/aarch64/tmp-cpp-tests.exclude delete mode 100644 sulong/tests/configs/SulongSuite/os_arch/darwin/amd64/tmp-cpp-tests.exclude 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 From 73e96769869fd6736e62161da781cdfc25419c85 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Mon, 23 Oct 2023 17:08:21 +0200 Subject: [PATCH 37/61] Sulong: more debugging info --- .../llvm/parser/binary/BinaryParser.java | 31 ++++++------- .../truffle/llvm/runtime/LLVMContext.java | 10 +++- .../truffle/llvm/runtime/LibraryLocator.java | 12 ++--- .../com/oracle/truffle/llvm/ParserDriver.java | 2 +- .../initialization/LoadDependencyNode.java | 4 ++ .../llvm/initialization/LoadModulesNode.java | 46 +++++++++++-------- 6 files changed, 63 insertions(+), 42 deletions(-) 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..7999d7e42583 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); } 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/LLVMContext.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMContext.java index 1fa12539b3f0..3bc8dbad02a2 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 @@ -816,7 +816,7 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { //exception.enter();) - loaderLogger.log(Level.FINEST, "stack trace:"); + loaderLogger.log(Level.FINEST, "********************stack trace:***********************"); loaderLogger.log(Level.FINEST, Arrays.toString(e.getStackTrace())); loaderLogger.log(Level.FINEST, "symbol is: " + symbol.getName()); loaderLogger.log(Level.FINEST, "id is: " + id); @@ -860,6 +860,14 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws return symbolDynamicStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { //exception.enter(); + + loaderLogger.log(Level.FINEST, "********************stack trace:***********************"); + 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); + System.out.println("symbol is: " + symbol.getName()); System.out.println("id is: " + id); System.out.println("id name is: " + bitcodeID.getName()); 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..50dcc46ec112 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) { if (loggingEnabled()) { - traceLoader(context, "parse bitcode=%s", path); + traceLoader(context, "parse bitcode=%s (bitcode id=%s)", path, bitcodeID); } } 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..dffaf586581c 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 @@ -120,4 +120,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..cddf8e3a7b29 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 @@ -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; @@ -275,10 +276,34 @@ private LLVMScopeChain loadModule(VirtualFrame frame, LLVMContext context) { throw new LLVMParserException("LoadModulesNode is called with unexpected arguments"); } + /* + * Depenedencies need to be constructed before scoping building to ensure libraries are not garbage collected + * early. + */ + if (LLVMLoadingPhase.BUILD_DEPENDENCY.isActive(phase) && !context.isLibraryAlreadyLoaded(bitcodeID)) { + int id = bitcodeID.getId(); + if (!visited.get(id)) { + visited.set(id); + for (LoadDependencyNode libraryDependency : libraryDependencies) { + CallTarget lib = libraryDependency.execute(); + if (lib != null) { + if (LibraryLocator.loggingEnabled()) { + LibraryLocator.traceStaticInits(context, "building library dependency", libraryDependency.getLibraryName()); + } + callDependencies.call(lib, LLVMLoadingPhase.BUILD_DEPENDENCY, visited, dependencies); + } + } + dependencies.add(this.getCallTarget()); + } + } + /* * The scope is built in parsing order, which requires breadth-first with a que. */ if (LLVMLoadingPhase.BUILD_SCOPES.isActive(phase)) { + if (LLVMLoadingPhase.ALL == phase) { + visited.clear(); + } int id = bitcodeID.getId(); if (!visited.get(id)) { visited.set(id); @@ -302,6 +327,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); @@ -331,24 +359,6 @@ private LLVMScopeChain loadModule(VirtualFrame frame, LLVMContext context) { } } - if (LLVMLoadingPhase.BUILD_DEPENDENCY.isActive(phase)) { - if (LLVMLoadingPhase.ALL == phase) { - visited.clear(); - } - - int id = bitcodeID.getId(); - if (!visited.get(id)) { - visited.set(id); - for (LoadDependencyNode libraryDependency : libraryDependencies) { - CallTarget lib = libraryDependency.execute(); - if (lib != null) { - callDependencies.call(lib, LLVMLoadingPhase.BUILD_DEPENDENCY, visited, dependencies); - } - } - dependencies.add(this.getCallTarget()); - } - } - /* * The order of the initialization nodes is very important. The defined symbols and the * external symbols must be initialized before the global symbols can be initialized. From 9d8b178b9a7feb84d96e0ee58a023ce8aa3e3158 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 24 Oct 2023 09:07:05 +0200 Subject: [PATCH 38/61] Sulong: minor --- .../truffle/llvm/tools/ExtractBitcode.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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..567589d9ac27 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 @@ -29,6 +29,13 @@ */ 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 com.oracle.truffle.llvm.runtime.IDGenerater.BitcodeID; +import org.graalvm.polyglot.io.ByteSequence; + import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -37,13 +44,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 +109,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 + "'"); } From bf2aefce207f99b19ecf7b2f710d09070b0fa5ee Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 24 Oct 2023 14:11:11 +0200 Subject: [PATCH 39/61] Sulong: additional logging info --- .../src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java | 5 +++++ .../com/oracle/truffle/llvm/runtime/LibraryLocator.java | 2 +- .../truffle/llvm/initialization/LoadDependencyNode.java | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) 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 a1db697dd414..89349d8285fc 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 @@ -805,6 +805,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 50dcc46ec112..b13cdd93f4a6 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 @@ -122,7 +122,7 @@ public static void traceSearchPath(LLVMContext context, List paths, Object re public static void traceParseBitcode(LLVMContext context, Object path, IDGenerater.BitcodeID bitcodeID) { if (loggingEnabled()) { - traceLoader(context, "parse bitcode=%s (bitcode id=%s)", path, bitcodeID); + traceLoader(context, "parse bitcode=%s (bitcode id=%s, %s)", path, bitcodeID.getName(), bitcodeID.getId()); } } 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 dffaf586581c..aee1086d8497 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; } From a24fb91d9c7b66e678e54e791431e5310940bbc0 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 24 Oct 2023 14:35:57 +0200 Subject: [PATCH 40/61] Sulong: minor --- .../truffle/llvm/parser/binary/BinaryParser.java | 2 +- .../oracle/truffle/llvm/runtime/LibraryLocator.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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 7999d7e42583..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 @@ -94,7 +94,7 @@ private BinaryParserResult parseInternal(ByteSequence bytes, Source bcSource, LL return null; } if (bcSource != null) { - LibraryLocator.traceParseBitcode(context, bcSource.getPath(), bitcodeID); + 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/LibraryLocator.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LibraryLocator.java index b13cdd93f4a6..8a237757e760 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 @@ -120,9 +120,9 @@ public static void traceSearchPath(LLVMContext context, List paths, Object re } } - public static void traceParseBitcode(LLVMContext context, Object path, IDGenerater.BitcodeID bitcodeID) { + public static void traceParseBitcode(LLVMContext context, Object path, IDGenerater.BitcodeID bitcodeID, Source source) { if (loggingEnabled()) { - traceLoader(context, "parse bitcode=%s (bitcode id=%s, %s)", path, bitcodeID.getName(), bitcodeID.getId()); + 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); } From b686d793c8af5f28ac6f45ed0809e00b47ba61a6 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 24 Oct 2023 15:21:38 +0200 Subject: [PATCH 41/61] Sulong: minor --- .../src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java | 5 +++++ 1 file changed, 5 insertions(+) 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 89349d8285fc..5384db4b1f1e 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 @@ -795,6 +795,11 @@ private void lazyCacheCleanup() { */ LibraryCacheEntry ref = (LibraryCacheEntry) libraryCacheQueue.poll(); if (ref != null) { + if (LibraryLocator.loggingEnabled()) { + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, entry", ref.key.path); + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id name", ref.id.get().getName()); + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", ref.id.get().getId()); + } libraryCache.removeKey(ref.key); } } From e58cbb602e54fb04ddd481cb644e1730d0a0caa7 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 25 Oct 2023 10:13:33 +0200 Subject: [PATCH 42/61] Sulong: minor null check --- .../src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 5384db4b1f1e..8c24805c2d03 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 @@ -797,8 +797,12 @@ private void lazyCacheCleanup() { if (ref != null) { if (LibraryLocator.loggingEnabled()) { LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, entry", ref.key.path); - LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id name", ref.id.get().getName()); - LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", ref.id.get().getId()); + if (ref.id.get() != null) { + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id name", Objects.requireNonNull(ref.id.get()).getName()); + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", Objects.requireNonNull(ref.id.get()).getId()); + } else { + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", ref.id.get()); + } } libraryCache.removeKey(ref.key); } From 5b2d1097eb00d167458f2a9e287511204b64d783 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Thu, 26 Oct 2023 14:55:46 +0200 Subject: [PATCH 43/61] Sulong: switch to internal library locator --- .../src/com/oracle/truffle/llvm/ParserDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 149422c20c33..866b5db7e490 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 @@ -459,7 +459,7 @@ private void processDependencies(String libraryName, boolean isInternal, BinaryP for (String lib : context.preprocessDependencies(binaryParserResult.getLibraries(), libraryName, isInternal)) { // don't add the library itself as one of it's own dependency. if (!libraryName.equals(lib)) { - libraryDependencies.add(LoadDependencyNode.create(lib, binaryParserResult.getLocator(), lib)); + libraryDependencies.add(LoadDependencyNode.create(lib, LLVMContext.InternalLocator.INSTANCE, lib)); } } } From 704bdfb5eeacdcc44dc7b958b665c9de530d63ad Mon Sep 17 00:00:00 2001 From: Paley Li Date: Fri, 27 Oct 2023 13:19:44 +0200 Subject: [PATCH 44/61] Sulong: only clean up entry in language cache that have not been replaced by a new entry --- .../src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java | 8 +++----- .../src/com/oracle/truffle/llvm/ParserDriver.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) 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 8c24805c2d03..fc77b946d66d 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 @@ -783,10 +783,6 @@ protected CallTarget parse(ParsingRequest request) { } } - 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 @@ -804,7 +800,9 @@ private void lazyCacheCleanup() { LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", ref.id.get()); } } - libraryCache.removeKey(ref.key); + if (libraryCache.get(ref.key) == ref) { + libraryCache.removeKey(ref.key); + } } } 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 866b5db7e490..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 @@ -459,7 +459,7 @@ private void processDependencies(String libraryName, boolean isInternal, BinaryP for (String lib : context.preprocessDependencies(binaryParserResult.getLibraries(), libraryName, isInternal)) { // don't add the library itself as one of it's own dependency. if (!libraryName.equals(lib)) { - libraryDependencies.add(LoadDependencyNode.create(lib, LLVMContext.InternalLocator.INSTANCE, lib)); + libraryDependencies.add(LoadDependencyNode.create(lib, binaryParserResult.getLocator(), lib)); } } } From 8aa8800936c75e9e704ea4ce794bc21968506e40 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 31 Oct 2023 12:56:54 +0100 Subject: [PATCH 45/61] Sulong: clean up, remove logging from gate. --- sulong/ci/ci.jsonnet | 2 +- sulong/mx.sulong/mx_sulong_gate.py | 2 +- .../truffle/llvm/runtime/IDGenerater.java | 2 +- .../truffle/llvm/runtime/LLVMContext.java | 88 +++---------------- .../func/LLVMLookupDispatchTargetNode.java | 12 ++- .../truffle/llvm/tools/ExtractBitcode.java | 2 +- .../truffle/llvm/tests/BaseSuiteHarness.java | 4 +- .../truffle/llvm/tests/util/ProcessUtil.java | 42 ++------- 8 files changed, 34 insertions(+), 120 deletions(-) diff --git a/sulong/ci/ci.jsonnet b/sulong/ci/ci.jsonnet index 575da3601fb9..3e4651fbb995 100644 --- a/sulong/ci/ci.jsonnet +++ b/sulong/ci/ci.jsonnet @@ -40,7 +40,7 @@ local sc = (import "ci_common/sulong-common.jsonnet"); 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"], logs+: ["sulong/log.txt"] }, + 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" }, diff --git a/sulong/mx.sulong/mx_sulong_gate.py b/sulong/mx.sulong/mx_sulong_gate.py index ee53b7b6d3af..119492b4f5b2 100644 --- a/sulong/mx.sulong/mx_sulong_gate.py +++ b/sulong/mx.sulong/mx_sulong_gate.py @@ -188,7 +188,7 @@ def _unittest(title, test_suite, tags=None, testClasses=None, unittestArgs=None, _unittest('GCC_Fortran', 'SULONG_GCC_FORTRAN_TEST_SUITE', description="GCC 5.2 test suite (Fortran tests)", testClasses=['GccFortranSuite'], tags=['gcc_fortran']) _unittest('Sulong', 'SULONG_STANDALONE_TEST_SUITES', description="Sulong's internal tests", testClasses='SulongSuite', tags=['sulongStandalone', 'sulongBasic', 'standalone'], # run only a small subset of the tests on the jvm standalone, the startup overhead per test is too high for more - extraUnittestArgs=['-Dsulongtest.testNameFilter=cpp', '-Dpolyglot.log.llvm.Loader.level=ALL', '-Dpolyglot.log.file=log.txt'] if slowStandalone else ['-Dpolyglot.log.llvm.Loader.level=ALL', '-Dpolyglot.log.file=log.txt']) + extraUnittestArgs=['-Dsulongtest.testNameFilter=cpp'] if slowStandalone else []) _unittest('Interop', 'SULONG_EMBEDDED_TEST_SUITES', description="Truffle Language interoperability tests", testClasses=['com.oracle.truffle.llvm.tests.interop.'], tags=['interop', 'sulongBasic', 'sulongWinSupport']) if standaloneMode is None: # can't test with resources in standalone mode 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 aefebce387a2..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. * 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 3bc8dbad02a2..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 @@ -814,88 +814,28 @@ public LLVMPointer getSymbol(LLVMSymbol symbol, BranchProfile exception) throws try { return symbolFinalStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { - //exception.enter();) - - loaderLogger.log(Level.FINEST, "********************stack trace:***********************"); - 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); - - - System.out.println("symbol is: " + symbol.getName()); - System.out.println("id is: " + id); - System.out.println("id name is: " + bitcodeID.getName()); - System.out.println("index is: " + index); - - System.out.println("symbolFinalStorage length is: " + symbolFinalStorage.length + ", when compared against id: " + id); - System.out.println("symbolFinalStorage is: "); - for (int i = 0; i < symbolFinalStorage.length; i++) { - if (id == i) { - LLVMPointer[] pointers = symbolFinalStorage[i]; - if (pointers != null) { - System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); - for (int j = 0; j < pointers.length; j++) { - System.out.println("(" + i + ", " + j + ") : " + pointers[j]); - } - } else { - System.out.println("Length for " + i + " array : 0"); - } - } - } - - System.out.println("library loaded:"); - for (int i = 0; i < libraryLoaded.length; i++) { - System.out.println(i + " : " + this.libraryLoaded[i]); + 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); } - - System.out.println("stack trace:"); - e.printStackTrace(); - throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } else { try { return symbolDynamicStorage[id][index]; } catch (ArrayIndexOutOfBoundsException | NullPointerException e) { - //exception.enter(); - - loaderLogger.log(Level.FINEST, "********************stack trace:***********************"); - 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); - - System.out.println("symbol is: " + symbol.getName()); - System.out.println("id is: " + id); - System.out.println("id name is: " + bitcodeID.getName()); - System.out.println("index is: " + index); - System.out.println("symbolFinalStorage length is: " + symbolDynamicStorage.length + ", when compared against id: " + id); - System.out.println("symbolFinalStorage is: "); - for (int i = 0; i < symbolDynamicStorage.length; i++) { - if (id == i) { - LLVMPointer[] pointers = symbolDynamicStorage[i]; - if (pointers != null) { - System.out.println("Length for " + i + " array : " + pointers.length + ", when compared against index: " + index); - for (int j = 0; j < pointers.length; j++) { - System.out.println("(" + i + ", " + j + ") : " + pointers[j]); - } - } else { - System.out.println("Length for " + i + " array : 0"); - } - } - } - - System.out.println("library loaded:"); - for (int i = 0; i < libraryLoaded.length; i++) { - System.out.println(i + " : " + this.libraryLoaded[i]); + 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); } - - System.out.println("stack trace:"); - e.printStackTrace(); - throw new LLVMIllegalSymbolIndexException("cannot find symbol"); } } diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java index 688b0c4c9c93..524d3355d2cc 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java @@ -30,14 +30,17 @@ package com.oracle.truffle.llvm.runtime.nodes.func; 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.GenerateAOT; 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.library.CachedLibrary; import com.oracle.truffle.llvm.runtime.LLVMContext; import com.oracle.truffle.llvm.runtime.LLVMFunction; import com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor; +import com.oracle.truffle.llvm.runtime.except.LLVMIllegalSymbolIndexException; import com.oracle.truffle.llvm.runtime.library.internal.LLVMAsForeignLibrary; import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode; import com.oracle.truffle.llvm.runtime.nodes.memory.load.LLVMDerefHandleGetReceiverNode; @@ -45,6 +48,7 @@ import com.oracle.truffle.llvm.runtime.nodes.others.LLVMAccessGlobalSymbolNodeGen; import com.oracle.truffle.llvm.runtime.pointer.LLVMManagedPointer; import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer; +import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer; @NodeChild(value = "function", type = LLVMExpressionNode.class) public abstract class LLVMLookupDispatchTargetNode extends LLVMExpressionNode { @@ -90,16 +94,16 @@ protected static LLVMNativePointer doNativeFunctionCached(LLVMNativePointer poin * Try to cache the target symbol if it's always the same one, the reverse lookup is much faster * and doesn't need a TruffleBoundary. */ - /*@Specialization(guards = {"!isAutoDerefHandle(pointer.asNative())", "cachedSymbol != null"}, replaces = {"doHandleCached", + @Specialization(guards = {"!isAutoDerefHandle(pointer.asNative())", "cachedSymbol != null"}, replaces = {"doHandleCached", "doNativeFunctionCached"}, rewriteOn = LLVMIllegalSymbolIndexException.class) protected Object doLookupNativeFunctionCachedSymbol(VirtualFrame frame, LLVMNativePointer pointer, - @Cached("lookupFunctionSymbol(pointer)") LLVMAccessGlobalSymbolNode cachedSymbol) {*/ + @Cached("lookupFunctionSymbol(pointer)") LLVMAccessGlobalSymbolNode cachedSymbol) { /* * The cache will be invalidated if the symbol cannot be found in the symbol table. In which * case the entire specialisation will be rewritten when the context throws an * LLVMIllegalSymbolIndexException. */ - /*LLVMPointer symbolPointer = cachedSymbol.executeGeneric(frame); + LLVMPointer symbolPointer = cachedSymbol.executeGeneric(frame); // guard against uninitialized symbols in multi-context cases if (LLVMManagedPointer.isInstance(symbolPointer)) { @@ -114,7 +118,7 @@ protected Object doLookupNativeFunctionCachedSymbol(VirtualFrame frame, LLVMNati } CompilerDirectives.transferToInterpreterAndInvalidate(); throw new LLVMIllegalSymbolIndexException("mismatching function"); - }*/ + } @Specialization(guards = "!isAutoDerefHandle(pointer.asNative())", //replaces = {"doLookupNativeFunctionCachedSymbol", "doHandleCached", "doNativeFunctionCached"}) replaces = {"doHandleCached", "doNativeFunctionCached"}) 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 567589d9ac27..784d21ec1789 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. * diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java index 0377c55baac3..50d12b5aa7ed 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/BaseSuiteHarness.java @@ -35,6 +35,7 @@ import com.oracle.truffle.llvm.tests.util.ProcessUtil; import com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult; import com.oracle.truffle.llvm.tests.util.ProcessUtil.TestEngineMode; + import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Engine; import org.junit.AfterClass; @@ -196,7 +197,6 @@ private void runCandidate(Path referenceBinary, ProcessResult referenceResult, P try { result = testEngineMode.run(candidateBinary.toAbsolutePath().toFile(), inputArgs, getContextOptions(candidateBinary.toAbsolutePath().toString()), evaluateSourceOnly()); } catch (Exception e) { - System.out.println("*************Failure in BaseSuiteHarness.runCandidate()*************"); throw fail(getTestName(), new Exception("Candidate binary that failed: " + candidateBinary, e)); } @@ -227,8 +227,6 @@ private ProcessResult runReference(Path referenceBinary) { if (retries++ >= MAX_RETRIES) { throw e; } - } catch (IOException e) { - throw new RuntimeException(e); } } } diff --git a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java index 29b9503d1637..b53ab15298d2 100644 --- a/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java +++ b/sulong/tests/com.oracle.truffle.llvm.tests/src/com/oracle/truffle/llvm/tests/util/ProcessUtil.java @@ -36,7 +36,6 @@ import org.graalvm.polyglot.Context.Builder; import org.graalvm.polyglot.Engine; import org.graalvm.polyglot.Value; -import org.junit.Assert; import java.io.ByteArrayOutputStream; import java.io.Closeable; @@ -51,6 +50,8 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; +import org.junit.Assert; + public class ProcessUtil { private static final int BUFFER_SIZE = 1024; @@ -186,17 +187,7 @@ public ProcessResult run(File bitcodeFile, String[] args, Map op Assert.fail("No main function found."); } if (!evalSourceOnly) { - try { - result = main.execute().asInt(); - } catch (Exception e) { - System.out.println("Print out.getStdErr(): "); - System.out.println(out.getStdErr()); - System.out.println("***************************************"); - System.out.println("Print out.getStdOut(): "); - System.out.println(out.getStdOut()); - throw new RuntimeException(e); - - } + result = main.execute().asInt(); } } return new ProcessResult(bitcodeFile.getName(), result, out.getStdErr(), out.getStdOut()); @@ -218,18 +209,7 @@ public SeparateProcessEngineMode() throws IOException { @Override public ProcessResult run(File bitcodeFile, String[] args, Map options, boolean evalSourceOnly) throws IOException { - ProcessResult pr = null; - try { - pr = manager.startTask(bitcodeFile.getAbsolutePath()).get(); - } catch (Exception e) { - System.out.println("Print pr.getStdErr(): "); - System.out.println(pr.getStdErr()); - System.out.println("***************************************"); - System.out.println("Print pr.getStdOut(): "); - System.out.println(pr.getStdOutput()); - throw new RuntimeException(e); - } - return pr; + return manager.startTask(bitcodeFile.getAbsolutePath()).get(); } @Override @@ -274,18 +254,16 @@ private static List concatOptions(Map options) { return optList; } - public static ProcessResult executeNativeCommand(List command) throws IOException { + public static ProcessResult executeNativeCommand(List command) { if (command == null) { throw new IllegalArgumentException("command is null!"); } ProcessBuilder processBuilder = new ProcessBuilder(command); Process process = null; - StreamReader readError = null; - StreamReader readOutput = null; try { process = processBuilder.start(); - readError = StreamReader.read(process.getErrorStream()); - readOutput = StreamReader.read(process.getInputStream()); + StreamReader readError = StreamReader.read(process.getErrorStream()); + StreamReader readOutput = StreamReader.read(process.getInputStream()); boolean success = process.waitFor(PROCESS_WAIT_TIMEOUT, TimeUnit.MILLISECONDS); if (!success) { throw new TimeoutError(command.toString()); @@ -293,12 +271,6 @@ public static ProcessResult executeNativeCommand(List command) throws IO int llvmResult = process.exitValue(); return new ProcessResult(command.toString(), llvmResult, readError.getResult(), readOutput.getResult()); } catch (Exception e) { - System.out.println("Print readOutput.getResult(): "); - assert readOutput != null; - System.out.println(readOutput.getResult()); - System.out.println("***************************************"); - System.out.println("Print readError.getResult(): "); - System.out.println(readError.getResult()); throw new RuntimeException(command + " ", e); } finally { if (process != null) { From 6f824ae5d340f6c7cc06ba9991e4c0ed874b3e42 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 31 Oct 2023 13:13:19 +0100 Subject: [PATCH 46/61] Sulong: revert lookup target node --- .../llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java index 524d3355d2cc..791351bf38c1 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/nodes/func/LLVMLookupDispatchTargetNode.java @@ -120,8 +120,7 @@ protected Object doLookupNativeFunctionCachedSymbol(VirtualFrame frame, LLVMNati throw new LLVMIllegalSymbolIndexException("mismatching function"); } - @Specialization(guards = "!isAutoDerefHandle(pointer.asNative())", //replaces = {"doLookupNativeFunctionCachedSymbol", "doHandleCached", "doNativeFunctionCached"}) - replaces = {"doHandleCached", "doNativeFunctionCached"}) + @Specialization(guards = "!isAutoDerefHandle(pointer.asNative())", replaces = {"doLookupNativeFunctionCachedSymbol", "doHandleCached", "doNativeFunctionCached"}) protected Object doLookup(LLVMNativePointer pointer) { LLVMFunctionDescriptor descriptor = lookupFunction(pointer); if (descriptor != null) { From c4baa69bb315121c53a06377a60003644d76aff0 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Tue, 31 Oct 2023 14:38:45 +0100 Subject: [PATCH 47/61] Sulong: build scope before build dependency --- .../llvm/initialization/LoadModulesNode.java | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) 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 cddf8e3a7b29..d8876c269db8 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 @@ -276,34 +276,10 @@ private LLVMScopeChain loadModule(VirtualFrame frame, LLVMContext context) { throw new LLVMParserException("LoadModulesNode is called with unexpected arguments"); } - /* - * Depenedencies need to be constructed before scoping building to ensure libraries are not garbage collected - * early. - */ - if (LLVMLoadingPhase.BUILD_DEPENDENCY.isActive(phase) && !context.isLibraryAlreadyLoaded(bitcodeID)) { - int id = bitcodeID.getId(); - if (!visited.get(id)) { - visited.set(id); - for (LoadDependencyNode libraryDependency : libraryDependencies) { - CallTarget lib = libraryDependency.execute(); - if (lib != null) { - if (LibraryLocator.loggingEnabled()) { - LibraryLocator.traceStaticInits(context, "building library dependency", libraryDependency.getLibraryName()); - } - callDependencies.call(lib, LLVMLoadingPhase.BUILD_DEPENDENCY, visited, dependencies); - } - } - dependencies.add(this.getCallTarget()); - } - } - /* * The scope is built in parsing order, which requires breadth-first with a que. */ if (LLVMLoadingPhase.BUILD_SCOPES.isActive(phase)) { - if (LLVMLoadingPhase.ALL == phase) { - visited.clear(); - } int id = bitcodeID.getId(); if (!visited.get(id)) { visited.set(id); @@ -359,6 +335,27 @@ private LLVMScopeChain loadModule(VirtualFrame frame, LLVMContext context) { } } + if (LLVMLoadingPhase.BUILD_DEPENDENCY.isActive(phase)) { + if (LLVMLoadingPhase.ALL == phase) { + visited.clear(); + } + + int id = bitcodeID.getId(); + 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); + } + } + dependencies.add(this.getCallTarget()); + } + } + /* * The order of the initialization nodes is very important. The defined symbols and the * external symbols must be initialized before the global symbols can be initialized. From ee67127833f0f0263207f164338412c2f226f09e Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 1 Nov 2023 09:34:04 +0100 Subject: [PATCH 48/61] Sulong: minor --- .../truffle/llvm/runtime/LLVMLanguage.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) 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 fc77b946d66d..d651f963502d 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}, // From d30b2e588afa15f45a75d195d01cc0d3156bead3 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 1 Nov 2023 10:13:03 +0100 Subject: [PATCH 49/61] Sulong: minor --- .../src/com/oracle/truffle/llvm/tools/ExtractBitcode.java | 1 - 1 file changed, 1 deletion(-) 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 784d21ec1789..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 @@ -33,7 +33,6 @@ 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 com.oracle.truffle.llvm.runtime.IDGenerater.BitcodeID; import org.graalvm.polyglot.io.ByteSequence; import java.io.FileInputStream; From 7006195cbe2b99b05adf9584eb896e08f8a92dea Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 1 Nov 2023 13:00:18 +0100 Subject: [PATCH 50/61] Sulong: format --- .../src/com/oracle/truffle/llvm/runtime/LibraryLocator.java | 2 +- .../oracle/truffle/llvm/initialization/LoadDependencyNode.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 8a237757e760..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 @@ -175,7 +175,7 @@ private static void traceLoader(LLVMContext context, String format, Object arg0, @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)); + String.format("lli(%x): " + format, prefix(context), arg0, arg1, arg2, arg3, arg4)); } private static int prefix(LLVMContext context) { 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 aee1086d8497..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 @@ -128,7 +128,7 @@ private CallTarget createNativeLibraryCallTarget(TruffleFile file) { } } - public String getLibraryName(){ + public String getLibraryName() { return libraryName; } } From 4c8dd0aa639aeb1a1e636442331cf456cac3c402 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 1 Nov 2023 15:12:55 +0100 Subject: [PATCH 51/61] Sulong: minor --- .../com/oracle/truffle/llvm/runtime/LLVMLanguage.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 d651f963502d..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 @@ -791,11 +791,12 @@ private void lazyCacheCleanup() { if (ref != null) { if (LibraryLocator.loggingEnabled()) { LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, entry", ref.key.path); - if (ref.id.get() != null) { - LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id name", Objects.requireNonNull(ref.id.get()).getName()); - LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", Objects.requireNonNull(ref.id.get()).getId()); + 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", ref.id.get()); + LibraryLocator.traceStaticInits(getContext(), "LLVMLanguage lazy cached clean up, bitcode id", bitcodeID); } } if (libraryCache.get(ref.key) == ref) { From 3c40f4be03b4920bb89a3b5f85f15bc9b2b51832 Mon Sep 17 00:00:00 2001 From: Paley Li Date: Wed, 1 Nov 2023 15:54:24 +0100 Subject: [PATCH 52/61] Sulong: copyright --- .../com/oracle/truffle/llvm/initialization/LoadModulesNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d8876c269db8..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. * From d621dbd5b1e9f3e3095e05b062b39afc4c6f3588 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 1 Nov 2023 17:43:25 +0100 Subject: [PATCH 53/61] Fix style. --- .../src/org/graalvm/nativeimage/impl/ReflectionRegistry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java index 7f1141b6435d..0179e2db9a95 100644 --- a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java +++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java @@ -49,7 +49,7 @@ default void register(ConfigurationCondition condition, Class... classes) { Arrays.stream(classes).forEach(clazz -> { if (clazz == null) { throw new NullPointerException("Cannot register null value as class for reflection. " + - "Please ensure that all values you register are not null."); + "Please ensure that all values you register are not null."); } register(condition, false, clazz); }); From dd7fb24277c9be1f25539d9d36c97f5d7ad72c0f Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 2 Nov 2023 07:44:54 +0100 Subject: [PATCH 54/61] sdk: update mx import --- sdk/mx.sdk/suite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From 6560ce2fdfbf2ad6ad3179e023ef8beca87aaa43 Mon Sep 17 00:00:00 2001 From: Josef Eisl Date: Thu, 2 Nov 2023 09:35:00 +0100 Subject: [PATCH 55/61] ci: disable darwin-amd64 on JDK latest [GR-49652] --- compiler/ci/ci_common/gate.jsonnet | 9 ++++++--- sdk/ci/ci.jsonnet | 4 +++- sulong/ci/ci.jsonnet | 20 +++++++++++++------- truffle/ci/ci.jsonnet | 5 ++++- 4 files changed, 26 insertions(+), 12 deletions(-) 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/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/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/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, From f94551abad61ae492d9a0b266a07564ab8aff92e Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 2 Nov 2023 14:26:29 +0100 Subject: [PATCH 56/61] Move null checks to the beginning of register methods. Not before the register methods, which can miss cases, nor later on in a runnable. --- .../nativeimage/impl/ReflectionRegistry.java | 8 +------ .../hosted/reflect/ReflectionDataBuilder.java | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java index 0179e2db9a95..4198a895ec06 100644 --- a/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java +++ b/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/impl/ReflectionRegistry.java @@ -46,13 +46,7 @@ public interface ReflectionRegistry { default void register(ConfigurationCondition condition, Class... classes) { - Arrays.stream(classes).forEach(clazz -> { - if (clazz == null) { - throw new NullPointerException("Cannot register null value as class for reflection. " + - "Please ensure that all values you register are not null."); - } - register(condition, false, clazz); - }); + Arrays.stream(classes).forEach(clazz -> register(condition, false, clazz)); } void register(ConfigurationCondition condition, boolean unsafeAllocated, Class clazz); 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 1a81548280de..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,13 +271,10 @@ 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) { - if (executable == null) { - throw new NullPointerException("Cannot register null value as executable for reflection. " + - "Please ensure that all values you register are not null."); - } analysisUniverse.getBigbang().postTask(debug -> registerMethod(queriedOnly, executable)); } })); @@ -401,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); } @@ -408,10 +408,6 @@ public void register(ConfigurationCondition condition, boolean finalIsWritable, private void registerInternal(ConfigurationCondition condition, Field... fields) { register(analysisUniverse -> registerConditionalConfiguration(condition, () -> { for (Field field : fields) { - if (field == null) { - throw new NullPointerException("Cannot register null value as field for reflection. " + - "Please ensure that all values you register are not null."); - } analysisUniverse.getBigbang().postTask(debug -> registerField(field)); } })); @@ -1068,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."; + } } From d996f323b7c6ce796caccff6ae50bd1c2fa5a81f Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 2 Nov 2023 14:27:00 +0100 Subject: [PATCH 57/61] Apply non-null strategy to `JNIAccessFeature`. --- .../svm/hosted/jni/JNIAccessFeature.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) 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."; + } } From 0ba6cc2c33725a482e190525c6f2bd153ec82b2b Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 2 Nov 2023 14:35:01 +0100 Subject: [PATCH 58/61] Use `Objects.requireNonNull()` in `ConditionalConfigurationRegistry`. --- .../svm/hosted/ConditionalConfigurationRegistry.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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 e696f21e3031..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,14 +39,8 @@ public abstract class ConditionalConfigurationRegistry { private final Map> pendingReachabilityHandlers = new ConcurrentHashMap<>(); protected void registerConditionalConfiguration(ConfigurationCondition condition, Runnable runnable) { - if (condition == null) { - throw new NullPointerException("Cannot use null value as condition for conditional configuration. " + - "Please ensure that you register a non-null condition."); - } - if (runnable == null) { - throw new NullPointerException("Cannot use null value as runnable for conditional configuration. " + - "Please ensure that you register a non-null 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(); From f4b3958dc150396a8ad44e9cf37ef5414dc70589 Mon Sep 17 00:00:00 2001 From: Marouane El Hallaoui Date: Thu, 2 Nov 2023 16:07:58 +0100 Subject: [PATCH 59/61] use deployed labsjdks --- common.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common.json b/common.json index f17666822a34..1ae61620baaf 100644 --- a/common.json +++ b/common.json @@ -43,12 +43,12 @@ "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": "20", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02-20231031145131-46b980eb0d", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02-20231031145131-46b980eb0d-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+20-jvmci-b02-20231031145131-46b980eb0d-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02-20231031145131-46b980eb0d+f4a1b58dac", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02-20231031145131-46b980eb0d+f4a1b58dac-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+20-jvmci-b02-20231031145131-46b980eb0d+f4a1b58dac-sulong", "platformspecific": true } + "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": { From d376d2f1d5ad94fae32be07b98763adef8d9e0a5 Mon Sep 17 00:00:00 2001 From: Cosmin Basca Date: Thu, 2 Nov 2023 19:29:20 +0000 Subject: [PATCH 60/61] [GR-21590] Update imports. PullRequest: graalpython/3032 --- vm/mx.vm/suite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/mx.vm/suite.py b/vm/mx.vm/suite.py index ee0c6d430627..73f7a6e2f9d2 100644 --- a/vm/mx.vm/suite.py +++ b/vm/mx.vm/suite.py @@ -65,7 +65,7 @@ }, { "name": "graalpython", - "version": "e902929ead209962d2a4a1697f69054becf7e801", + "version": "9105e899f40095bc5b087c849f8ef902c65aae35", "dynamic": True, "urls": [ {"url": "https://github.com/graalvm/graalpython.git", "kind": "git"}, From fadd2a19cb4f3e1a14e729f2baca6a6d050dfd76 Mon Sep 17 00:00:00 2001 From: Jan Stola Date: Fri, 3 Nov 2023 01:22:22 +0000 Subject: [PATCH 61/61] [GR-49506] Upgrading the underlying Node.js to version 18.18.2. PullRequest: js/2967 --- vm/mx.vm/suite.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/mx.vm/suite.py b/vm/mx.vm/suite.py index 73f7a6e2f9d2..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"}, ]