diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/CachingPEGraphDecoder.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/CachingPEGraphDecoder.java index f9c8c7f70513..e8b7b733dd43 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/CachingPEGraphDecoder.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/CachingPEGraphDecoder.java @@ -25,6 +25,7 @@ package jdk.graal.compiler.truffle; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; import java.util.function.Supplier; import org.graalvm.collections.EconomicMap; @@ -128,7 +129,7 @@ private EncodedGraph createGraph(ResolvedJavaMethod method) { try (DebugContext.Scope scope = debug.scope("createGraph", graphToEncode)) { Providers p = this.graphCacheProviders; - new PrePartialEvaluationSuite(graphToEncode.getOptions(), truffleTypes, p, canonicalizer, (m) -> buildGraph(m, canonicalizer)).apply(graphToEncode, p); + new PrePartialEvaluationSuite(graphToEncode.getOptions(), truffleTypes, p, canonicalizer, (m) -> buildGraph(m, canonicalizer), Function.identity()).apply(graphToEncode, p); new ConvertDeoptimizeToGuardPhase(canonicalizer).apply(graphToEncode, p); if (GraalOptions.EarlyGVN.getValue(graphToEncode.getOptions())) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/PrePartialEvaluationSuite.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/PrePartialEvaluationSuite.java index 05fa7e8beb09..2c57a7fe2029 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/PrePartialEvaluationSuite.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/PrePartialEvaluationSuite.java @@ -33,6 +33,7 @@ import jdk.graal.compiler.phases.util.Providers; import jdk.graal.compiler.truffle.KnownTruffleTypes; import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; /** * This suite is intended to run on every graph prior to partial evaluation. It is not optional, as @@ -44,10 +45,10 @@ public final class PrePartialEvaluationSuite extends PhaseSuite { @SuppressWarnings("this-escape") public PrePartialEvaluationSuite(OptionValues optionValues, KnownTruffleTypes truffleTypes, Providers providers, CanonicalizerPhase canonicalizer, - Function graphLookup) { + Function graphLookup, Function unwrapType) { // only if Truffle is installed we can apply these phases. - appendPhase(new TruffleEarlyInliningPhase(optionValues, canonicalizer, truffleTypes, providers, graphLookup)); - appendPhase(new TruffleEarlyEscapeAnalysisPhase(canonicalizer, optionValues, truffleTypes)); + appendPhase(new TruffleEarlyInliningPhase(optionValues, canonicalizer, truffleTypes, providers, graphLookup, unwrapType)); + appendPhase(new TruffleEarlyEscapeAnalysisPhase(canonicalizer, optionValues, truffleTypes, unwrapType)); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/TruffleEarlyEscapeAnalysisPhase.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/TruffleEarlyEscapeAnalysisPhase.java index 06f8bb19e219..a3ef1981539e 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/TruffleEarlyEscapeAnalysisPhase.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/TruffleEarlyEscapeAnalysisPhase.java @@ -25,6 +25,7 @@ package jdk.graal.compiler.truffle.phases; import java.util.Map; +import java.util.function.Function; import jdk.graal.compiler.annotation.AnnotationValue; import jdk.graal.compiler.annotation.AnnotationValueSupport; @@ -40,11 +41,12 @@ */ public final class TruffleEarlyEscapeAnalysisPhase extends PartialEscapePhase { - private final KnownTruffleTypes types; + private final ResolvedJavaType unwrappedAnnotationType; - public TruffleEarlyEscapeAnalysisPhase(CanonicalizerPhase canonicalizer, OptionValues options, KnownTruffleTypes truffleTypes) { + public TruffleEarlyEscapeAnalysisPhase(CanonicalizerPhase canonicalizer, OptionValues options, KnownTruffleTypes truffleTypes, + Function unwrapType) { super(false, canonicalizer, options); - this.types = truffleTypes; + this.unwrappedAnnotationType = unwrapType.apply(truffleTypes.CompilerDirectives_EarlyEscapeAnalysis); } @Override @@ -55,7 +57,7 @@ public boolean checkContract() { @Override protected boolean matchGraph(StructuredGraph graph) { Map declaredAnnotationValues = AnnotationValueSupport.getDeclaredAnnotationValues(graph.method()); - if (!declaredAnnotationValues.containsKey(types.CompilerDirectives_EarlyEscapeAnalysis)) { + if (!declaredAnnotationValues.containsKey(unwrappedAnnotationType)) { return false; } // we do not respect the PE only option for Truffle because PE depends on escape analysis diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/TruffleEarlyInliningPhase.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/TruffleEarlyInliningPhase.java index 7f206373a881..209b95dabea0 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/TruffleEarlyInliningPhase.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/TruffleEarlyInliningPhase.java @@ -77,17 +77,18 @@ static class Options { } private final Providers providers; - private final KnownTruffleTypes types; private final Function lookup; - protected final CanonicalizerPhase canonicalizer; + private final ResolvedJavaType unwrappedAnnotationType; + private final CanonicalizerPhase canonicalizer; private final int maxDepth; - public TruffleEarlyInliningPhase(OptionValues options, CanonicalizerPhase canonicalizer, KnownTruffleTypes types, Providers providers, Function lookup) { - this.types = types; + public TruffleEarlyInliningPhase(OptionValues options, CanonicalizerPhase canonicalizer, KnownTruffleTypes types, Providers providers, + Function lookup, Function unwrapType) { this.providers = providers; this.lookup = lookup; this.canonicalizer = canonicalizer; this.maxDepth = Options.TruffleEarlyInliningMaxDepth.getValue(options); + this.unwrappedAnnotationType = unwrapType.apply(types.CompilerDirectives_EarlyInline); } @Override @@ -176,7 +177,7 @@ private boolean shouldInline(Invoke invoke) { return false; } Map declaredAnnotationValues = AnnotationValueSupport.getDeclaredAnnotationValues(targetMethod); - if (!declaredAnnotationValues.containsKey(types.CompilerDirectives_EarlyInline)) { + if (!declaredAnnotationValues.containsKey(unwrappedAnnotationType)) { return false; } String failureMessage = InliningUtil.checkInvokeConditions(invoke); diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleRuntimeCompilationFeature.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleRuntimeCompilationFeature.java index f974dac23e65..b690d32743cb 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleRuntimeCompilationFeature.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleRuntimeCompilationFeature.java @@ -39,6 +39,7 @@ import com.oracle.svm.graal.hosted.runtimecompilation.RuntimeCompilationFeature; import com.oracle.svm.graal.hosted.runtimecompilation.RuntimeCompiledMethodSupport; import com.oracle.svm.hosted.FeatureImpl; +import com.oracle.svm.util.OriginalClassProvider; import jdk.graal.compiler.debug.DebugContext; import jdk.graal.compiler.nodes.StructuredGraph; @@ -82,9 +83,10 @@ protected void applyParsingHookPhases(DebugContext debug, StructuredGraph graph, if (!ImageSingletons.contains(KnownTruffleTypes.class)) { return; } + KnownTruffleTypes truffleTypes = ImageSingletons.lookup(KnownTruffleTypes.class); new PrePartialEvaluationSuite(debug.getOptions(), truffleTypes, - providers, canonicalizer, buildGraph).apply(graph, providers); + providers, canonicalizer, buildGraph, OriginalClassProvider::getOriginalType).apply(graph, providers); } @SuppressWarnings("javadoc")