Skip to content

Commit 7aaa527

Browse files
committed
[GR-37501] Move TRUFFLE_API dependency to com.oracle.svm.truffle project.
PullRequest: graal/11821
2 parents bb50c72 + 36afea0 commit 7aaa527

File tree

3 files changed

+33
-36
lines changed

3 files changed

+33
-36
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,6 @@
811811
"sourceDirs": ["src"],
812812
"dependencies": [
813813
"com.oracle.svm.hosted",
814-
"truffle:TRUFFLE_API",
815814
],
816815
"requiresConcealed" : {
817816
"java.base" : [
@@ -882,6 +881,7 @@
882881
"sourceDirs": ["src"],
883882
"dependencies": [
884883
"com.oracle.svm.graal",
884+
"truffle:TRUFFLE_API",
885885
],
886886
"requiresConcealed" : {
887887
"java.base" : [
@@ -902,9 +902,6 @@
902902
"dependencies": [
903903
"com.oracle.svm.truffle",
904904
],
905-
"requires": [
906-
"jdk.unsupported", # workaround to make TRUFFLE_DSL_PROCESSOR work with ECJ
907-
],
908905
"checkstyle": "com.oracle.svm.hosted",
909906
"javaCompliance": "11+",
910907
"annotationProcessors": [

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalFeature.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@
133133
import com.oracle.svm.hosted.phases.StrengthenStampsPhase;
134134
import com.oracle.svm.hosted.phases.SubstrateClassInitializationPlugin;
135135
import com.oracle.svm.hosted.phases.SubstrateGraphBuilderPhase;
136-
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
137136

138137
import jdk.vm.ci.meta.DeoptimizationAction;
139138
import jdk.vm.ci.meta.DeoptimizationReason;
@@ -157,9 +156,6 @@ public static class Options {
157156
@Option(help = "Print call tree of methods available for runtime compilation")//
158157
public static final HostedOptionKey<Boolean> PrintRuntimeCompileMethods = new HostedOptionKey<>(false);
159158

160-
@Option(help = "Print truffle boundaries found during the analysis")//
161-
public static final HostedOptionKey<Boolean> PrintStaticTruffleBoundaries = new HostedOptionKey<>(false);
162-
163159
@Option(help = "Maximum number of methods allowed for runtime compilation.")//
164160
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> MaxRuntimeCompileMethods = new HostedOptionKey<>(new LocatableMultiOptionValue.Strings());
165161

@@ -657,10 +653,6 @@ public void beforeCompilation(BeforeCompilationAccess c) {
657653
printCallTree();
658654
}
659655

660-
if (Options.PrintStaticTruffleBoundaries.getValue()) {
661-
printStaticTruffleBoundaries();
662-
}
663-
664656
int maxMethods = 0;
665657
for (String value : Options.MaxRuntimeCompileMethods.getValue().values()) {
666658
String numberStr = null;
@@ -830,30 +822,6 @@ private void printDeepestLevelPath() {
830822
}
831823
}
832824

833-
private void printStaticTruffleBoundaries() {
834-
HashSet<ResolvedJavaMethod> foundBoundaries = new HashSet<>();
835-
int callSiteCount = 0;
836-
int calleeCount = 0;
837-
for (CallTreeNode node : methods.values()) {
838-
StructuredGraph graph = node.graph;
839-
for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) {
840-
ResolvedJavaMethod targetMethod = callTarget.targetMethod();
841-
TruffleBoundary truffleBoundary = targetMethod.getAnnotation(TruffleBoundary.class);
842-
if (truffleBoundary != null) {
843-
++callSiteCount;
844-
if (foundBoundaries.contains(targetMethod)) {
845-
// nothing to do
846-
} else {
847-
foundBoundaries.add(targetMethod);
848-
System.out.println("Truffle boundary found: " + targetMethod);
849-
calleeCount++;
850-
}
851-
}
852-
}
853-
}
854-
System.out.println(String.format("Number of Truffle call boundaries: %d, number of unique called methods outside the boundary: %d", callSiteCount, calleeCount));
855-
}
856-
857825
private void printCallTree() {
858826
System.out.println("depth;method;Graal nodes;invoked from source;full method name;full name of invoked virtual method");
859827
for (CallTreeNode node : methods.values()) {

substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin;
110110
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin;
111111
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
112+
import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
112113
import org.graalvm.compiler.nodes.spi.Replacements;
113114
import org.graalvm.compiler.options.Option;
114115
import org.graalvm.compiler.options.OptionValues;
@@ -184,6 +185,9 @@ public String getDescription() {
184185
}
185186

186187
public static class Options {
188+
@Option(help = "Print truffle boundaries found during the analysis")//
189+
public static final HostedOptionKey<Boolean> PrintStaticTruffleBoundaries = new HostedOptionKey<>(false);
190+
187191
@Option(help = "Check that CompilerAsserts.neverPartOfCompilation is not reachable for runtime compilation")//
188192
public static final HostedOptionKey<Boolean> TruffleCheckNeverPartOfCompilation = new HostedOptionKey<>(true);
189193

@@ -813,6 +817,10 @@ private static void collectImplementations(HostedType type, Set<HostedType> impl
813817

814818
@Override
815819
public void afterAnalysis(AfterAnalysisAccess access) {
820+
if (Options.PrintStaticTruffleBoundaries.getValue()) {
821+
printStaticTruffleBoundaries();
822+
}
823+
816824
SubstrateTruffleRuntime truffleRuntime = (SubstrateTruffleRuntime) Truffle.getRuntime();
817825
AfterAnalysisAccessImpl config = (AfterAnalysisAccessImpl) access;
818826
truffleRuntime.initializeHostedKnownMethods(config.getMetaAccess());
@@ -844,6 +852,30 @@ public void afterAnalysis(AfterAnalysisAccess access) {
844852
}
845853
}
846854

855+
private static void printStaticTruffleBoundaries() {
856+
HashSet<ResolvedJavaMethod> foundBoundaries = new HashSet<>();
857+
int callSiteCount = 0;
858+
int calleeCount = 0;
859+
for (CallTreeNode node : ImageSingletons.lookup(GraalFeature.class).getRuntimeCompiledMethods().values()) {
860+
StructuredGraph graph = node.getGraph();
861+
for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.TYPE)) {
862+
ResolvedJavaMethod targetMethod = callTarget.targetMethod();
863+
TruffleBoundary truffleBoundary = targetMethod.getAnnotation(TruffleBoundary.class);
864+
if (truffleBoundary != null) {
865+
++callSiteCount;
866+
if (foundBoundaries.contains(targetMethod)) {
867+
// nothing to do
868+
} else {
869+
foundBoundaries.add(targetMethod);
870+
System.out.println("Truffle boundary found: " + targetMethod);
871+
calleeCount++;
872+
}
873+
}
874+
}
875+
}
876+
System.out.printf("Number of Truffle call boundaries: %d, number of unique called methods outside the boundary: %d%n", callSiteCount, calleeCount);
877+
}
878+
847879
@Override
848880
public void registerGraalPhases(Providers providers, SnippetReflectionProvider snippetReflection, Suites suites, boolean hosted) {
849881
if (hosted && TruffleHostInliningPhase.Options.TruffleHostInlining.getValue(HostedOptionValues.singleton()) && suites.getHighTier() instanceof HighTier) {

0 commit comments

Comments
 (0)