|
42 | 42 |
|
43 | 43 | import com.oracle.graal.pointsto.api.PointstoOptions; |
44 | 44 | import com.oracle.graal.pointsto.flow.AnalysisParsedGraph; |
| 45 | +import com.oracle.graal.pointsto.infrastructure.OriginalClassProvider; |
45 | 46 | import com.oracle.graal.pointsto.meta.HostedProviders; |
46 | 47 | import com.oracle.graal.pointsto.util.CompletionExecutor; |
47 | 48 | import com.oracle.graal.pointsto.util.CompletionExecutor.DebugContextRunnable; |
| 49 | +import com.oracle.graal.pointsto.util.GraalAccess; |
48 | 50 | import com.oracle.svm.common.meta.MultiMethod; |
49 | 51 | import com.oracle.svm.core.SubstrateOptions; |
50 | 52 | import com.oracle.svm.core.Uninterruptible; |
|
137 | 139 | import jdk.vm.ci.code.site.Infopoint; |
138 | 140 | import jdk.vm.ci.meta.MetaAccessProvider; |
139 | 141 | import jdk.vm.ci.meta.ResolvedJavaMethod; |
| 142 | +import jdk.vm.ci.meta.ResolvedJavaType; |
140 | 143 | import jdk.vm.ci.meta.VMConstant; |
141 | 144 |
|
142 | 145 | public class CompileQueue { |
@@ -182,6 +185,9 @@ protected PhaseSuite<HighTierContext> getAfterParseSuite() { |
182 | 185 |
|
183 | 186 | private final boolean printMethodHistogram = NativeImageOptions.PrintMethodHistogram.getValue(); |
184 | 187 | private final boolean optionAOTTrivialInline = SubstrateOptions.AOTTrivialInline.getValue(); |
| 188 | + private final boolean allowFoldMethods = NativeImageOptions.AllowFoldMethods.getValue(); |
| 189 | + |
| 190 | + private final ResolvedJavaType generatedFoldInvocationPluginType; |
185 | 191 |
|
186 | 192 | public record UnpublishedTrivialMethods(CompilationGraph unpublishedGraph, boolean newlyTrivial) { |
187 | 193 | } |
@@ -387,6 +393,7 @@ public CompileQueue(DebugContext debug, FeatureHandler featureHandler, HostedUni |
387 | 393 | this.defaultParseHooks = new ParseHooks(this); |
388 | 394 |
|
389 | 395 | callForReplacements(debug, runtimeConfig); |
| 396 | + generatedFoldInvocationPluginType = GraalAccess.getOriginalProviders().getMetaAccess().lookupJavaType(GeneratedFoldInvocationPlugin.class); |
390 | 397 | } |
391 | 398 |
|
392 | 399 | protected AnalysisToHostedGraphTransplanter createGraphTransplanter() { |
@@ -1003,17 +1010,21 @@ protected void ensureParsed(HostedMethod method, HostedMethod callerMethod, Comp |
1003 | 1010 | return; |
1004 | 1011 | } |
1005 | 1012 |
|
1006 | | - if (!(NativeImageOptions.AllowFoldMethods.getValue() || method.getAnnotation(Fold.class) == null || |
1007 | | - (callerMethod != null && metaAccess.lookupJavaType(GeneratedFoldInvocationPlugin.class).isAssignableFrom(callerMethod.getDeclaringClass())))) { |
1008 | | - throw VMError.shouldNotReachHere("Parsing method annotated with @" + Fold.class.getSimpleName() + ": " + |
1009 | | - method.format("%H.%n(%p)") + |
1010 | | - ". Make sure you have used Graal annotation processors on the parent-project of the method's declaring class."); |
| 1013 | + if (!allowFoldMethods && method.getAnnotation(Fold.class) != null && !isFoldInvocationPluginMethod(callerMethod)) { |
| 1014 | + throw VMError.shouldNotReachHere("Parsing method annotated with @%s: %s. " + |
| 1015 | + "This could happen if either: the Graal annotation processor was not executed on the parent-project of the method's declaring class, " + |
| 1016 | + "the arguments passed to the method were not compile-time constants, or the plugin was disabled by the corresponding %s.", |
| 1017 | + Fold.class.getSimpleName(), method.format("%H.%n(%p)"), GraphBuilderContext.class.getSimpleName()); |
1011 | 1018 | } |
1012 | 1019 | if (!method.compilationInfo.inParseQueue.getAndSet(true)) { |
1013 | 1020 | executor.execute(new ParseTask(method, reason)); |
1014 | 1021 | } |
1015 | 1022 | } |
1016 | 1023 |
|
| 1024 | + private boolean isFoldInvocationPluginMethod(HostedMethod method) { |
| 1025 | + return method != null && generatedFoldInvocationPluginType.isAssignableFrom(OriginalClassProvider.getOriginalType(method.getDeclaringClass())); |
| 1026 | + } |
| 1027 | + |
1017 | 1028 | protected final void doParse(DebugContext debug, ParseTask task) { |
1018 | 1029 | HostedMethod method = task.method; |
1019 | 1030 | if (HostedImageLayerBuildingSupport.buildingExtensionLayer()) { |
|
0 commit comments