diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index 27c95627f2e8..91701e72e2ae 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -811,7 +811,6 @@ "sourceDirs": ["src"], "dependencies": [ "com.oracle.svm.hosted", - "truffle:TRUFFLE_API", ], "requiresConcealed" : { "java.base" : [ @@ -882,6 +881,7 @@ "sourceDirs": ["src"], "dependencies": [ "com.oracle.svm.graal", + "truffle:TRUFFLE_API", ], "requiresConcealed" : { "java.base" : [ @@ -902,9 +902,6 @@ "dependencies": [ "com.oracle.svm.truffle", ], - "requires": [ - "jdk.unsupported", # workaround to make TRUFFLE_DSL_PROCESSOR work with ECJ - ], "checkstyle": "com.oracle.svm.hosted", "javaCompliance": "11+", "annotationProcessors": [ diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalFeature.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalFeature.java index a3e73fd1bdaf..63e1f187a716 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalFeature.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalFeature.java @@ -133,7 +133,6 @@ import com.oracle.svm.hosted.phases.StrengthenStampsPhase; import com.oracle.svm.hosted.phases.SubstrateClassInitializationPlugin; import com.oracle.svm.hosted.phases.SubstrateGraphBuilderPhase; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import jdk.vm.ci.meta.DeoptimizationAction; import jdk.vm.ci.meta.DeoptimizationReason; @@ -157,9 +156,6 @@ public static class Options { @Option(help = "Print call tree of methods available for runtime compilation")// public static final HostedOptionKey PrintRuntimeCompileMethods = new HostedOptionKey<>(false); - @Option(help = "Print truffle boundaries found during the analysis")// - public static final HostedOptionKey PrintStaticTruffleBoundaries = new HostedOptionKey<>(false); - @Option(help = "Maximum number of methods allowed for runtime compilation.")// public static final HostedOptionKey MaxRuntimeCompileMethods = new HostedOptionKey<>(new LocatableMultiOptionValue.Strings()); @@ -657,10 +653,6 @@ public void beforeCompilation(BeforeCompilationAccess c) { printCallTree(); } - if (Options.PrintStaticTruffleBoundaries.getValue()) { - printStaticTruffleBoundaries(); - } - int maxMethods = 0; for (String value : Options.MaxRuntimeCompileMethods.getValue().values()) { String numberStr = null; @@ -830,30 +822,6 @@ private void printDeepestLevelPath() { } } - private void printStaticTruffleBoundaries() { - HashSet foundBoundaries = new HashSet<>(); - int callSiteCount = 0; - int calleeCount = 0; - for (CallTreeNode node : methods.values()) { - StructuredGraph graph = node.graph; - for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) { - ResolvedJavaMethod targetMethod = callTarget.targetMethod(); - TruffleBoundary truffleBoundary = targetMethod.getAnnotation(TruffleBoundary.class); - if (truffleBoundary != null) { - ++callSiteCount; - if (foundBoundaries.contains(targetMethod)) { - // nothing to do - } else { - foundBoundaries.add(targetMethod); - System.out.println("Truffle boundary found: " + targetMethod); - calleeCount++; - } - } - } - } - System.out.println(String.format("Number of Truffle call boundaries: %d, number of unique called methods outside the boundary: %d", callSiteCount, calleeCount)); - } - private void printCallTree() { System.out.println("depth;method;Graal nodes;invoked from source;full method name;full name of invoked virtual method"); for (CallTreeNode node : methods.values()) { diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java index b67f63960231..10605fbe28c0 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java @@ -109,6 +109,7 @@ import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin; import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin; import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins; +import org.graalvm.compiler.nodes.java.MethodCallTargetNode; import org.graalvm.compiler.nodes.spi.Replacements; import org.graalvm.compiler.options.Option; import org.graalvm.compiler.options.OptionValues; @@ -184,6 +185,9 @@ public String getDescription() { } public static class Options { + @Option(help = "Print truffle boundaries found during the analysis")// + public static final HostedOptionKey PrintStaticTruffleBoundaries = new HostedOptionKey<>(false); + @Option(help = "Check that CompilerAsserts.neverPartOfCompilation is not reachable for runtime compilation")// public static final HostedOptionKey TruffleCheckNeverPartOfCompilation = new HostedOptionKey<>(true); @@ -813,6 +817,10 @@ private static void collectImplementations(HostedType type, Set impl @Override public void afterAnalysis(AfterAnalysisAccess access) { + if (Options.PrintStaticTruffleBoundaries.getValue()) { + printStaticTruffleBoundaries(); + } + SubstrateTruffleRuntime truffleRuntime = (SubstrateTruffleRuntime) Truffle.getRuntime(); AfterAnalysisAccessImpl config = (AfterAnalysisAccessImpl) access; truffleRuntime.initializeHostedKnownMethods(config.getMetaAccess()); @@ -844,6 +852,30 @@ public void afterAnalysis(AfterAnalysisAccess access) { } } + private static void printStaticTruffleBoundaries() { + HashSet foundBoundaries = new HashSet<>(); + int callSiteCount = 0; + int calleeCount = 0; + for (CallTreeNode node : ImageSingletons.lookup(GraalFeature.class).getRuntimeCompiledMethods().values()) { + StructuredGraph graph = node.getGraph(); + for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) { + ResolvedJavaMethod targetMethod = callTarget.targetMethod(); + TruffleBoundary truffleBoundary = targetMethod.getAnnotation(TruffleBoundary.class); + if (truffleBoundary != null) { + ++callSiteCount; + if (foundBoundaries.contains(targetMethod)) { + // nothing to do + } else { + foundBoundaries.add(targetMethod); + System.out.println("Truffle boundary found: " + targetMethod); + calleeCount++; + } + } + } + } + System.out.printf("Number of Truffle call boundaries: %d, number of unique called methods outside the boundary: %d%n", callSiteCount, calleeCount); + } + @Override public void registerGraalPhases(Providers providers, SnippetReflectionProvider snippetReflection, Suites suites, boolean hosted) { if (hosted && TruffleHostInliningPhase.Options.TruffleHostInlining.getValue(HostedOptionValues.singleton()) && suites.getHighTier() instanceof HighTier) {