diff --git a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderContext.java b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderContext.java index 26cae9fa23f5..7ffd29083efd 100644 --- a/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderContext.java +++ b/compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderContext.java @@ -27,10 +27,6 @@ import static jdk.vm.ci.meta.DeoptimizationAction.InvalidateReprofile; import static org.graalvm.compiler.core.common.type.StampFactory.objectNonNull; -import java.util.ArrayList; -import java.util.List; - -import org.graalvm.collections.Pair; import org.graalvm.compiler.bytecode.Bytecode; import org.graalvm.compiler.bytecode.BytecodeProvider; import org.graalvm.compiler.core.common.type.AbstractPointerStamp; @@ -263,19 +259,6 @@ default int getDepth() { return result; } - default List> getCallingContext() { - List> callingContext = new ArrayList<>(); - /* - * We always add a method which bytecode is parsed, so size of this list is minimum one. - */ - GraphBuilderContext cur = this; - while (cur != null) { - callingContext.add(Pair.create(cur.getMethod(), cur.bci())); - cur = cur.getParent(); - } - return callingContext; - } - /** * Determines if this parsing context is within the bytecode of an intrinsic or a method inlined * by an intrinsic. diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/api/HostVM.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/api/HostVM.java index 05cafe47292d..224d2b665261 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/api/HostVM.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/api/HostVM.java @@ -37,7 +37,6 @@ import org.graalvm.compiler.phases.OptimisticOptimizations; import com.oracle.graal.pointsto.BigBang; -import com.oracle.graal.pointsto.flow.AnalysisParsedGraph; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.graal.pointsto.meta.AnalysisUniverse; @@ -108,10 +107,6 @@ default String getImageName() { void methodBeforeTypeFlowCreationHook(BigBang bb, AnalysisMethod method, StructuredGraph graph); - default AnalysisParsedGraph parseBytecode(BigBang bb, AnalysisMethod analysisMethod) { - return AnalysisParsedGraph.parseBytecode(bb, analysisMethod); - } - default boolean hasNeverInlineDirective(@SuppressWarnings("unused") ResolvedJavaMethod method) { /* No inlining by the static analysis unless explicitly overwritten by the VM. */ return true; diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java index 2b3b68039363..805478ac2566 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/meta/AnalysisMethod.java @@ -612,7 +612,7 @@ public AnalysisParsedGraph ensureGraphParsed(BigBang bb) { continue; } - AnalysisParsedGraph graph = bb.getHostVM().parseBytecode(bb, this); + AnalysisParsedGraph graph = AnalysisParsedGraph.parseBytecode(bb, this); /* * Since we still hold the parsing lock, the transition form "parsing" to diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java index 046496e9bc78..7cefcdd66fd6 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java @@ -263,8 +263,6 @@ import com.oracle.svm.hosted.phases.CInterfaceInvocationPlugin; import com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin; import com.oracle.svm.hosted.phases.EarlyConstantFoldLoadFieldPlugin; -import com.oracle.svm.hosted.phases.ExperimentalNativeImageInlineDuringParsingPlugin; -import com.oracle.svm.hosted.phases.ExperimentalNativeImageInlineDuringParsingSupport; import com.oracle.svm.hosted.phases.InjectedAccessorsPlugin; import com.oracle.svm.hosted.phases.IntrinsifyMethodHandlesInvocationPlugin; import com.oracle.svm.hosted.phases.SubstrateClassInitializationPlugin; @@ -844,9 +842,6 @@ private void setupNativeImage(String imageName, OptionValues options, Map feature.afterRegistration(access)); @@ -1141,10 +1136,6 @@ public static void registerGraphBuilderPlugins(FeatureHandler featureHandler, Ru SubstrateReplacements replacements = (SubstrateReplacements) providers.getReplacements(); plugins.appendInlineInvokePlugin(replacements); - if (nativeImageInlineDuringParsingEnabled()) { - plugins.appendInlineInvokePlugin(new ExperimentalNativeImageInlineDuringParsingPlugin(reason, providers)); - } - plugins.appendNodePlugin(new IntrinsifyMethodHandlesInvocationPlugin(reason, providers, aUniverse, hUniverse)); plugins.appendNodePlugin(new DeletedFieldsPlugin()); plugins.appendNodePlugin(new InjectedAccessorsPlugin()); @@ -1240,12 +1231,6 @@ public T getInjectedArgument(Class type) { } } - public static boolean nativeImageInlineDuringParsingEnabled() { - return ExperimentalNativeImageInlineDuringParsingPlugin.Options.OldInlineBeforeAnalysis.getValue() && - !ImageSingletons.lookup(ExperimentalNativeImageInlineDuringParsingSupport.class).isNativeImageInlineDuringParsingDisabled() && - !DeoptTester.Options.DeoptimizeAll.getValue(); - } - @SuppressWarnings("try") public static void registerReplacements(DebugContext debug, FeatureHandler featureHandler, RuntimeConfiguration runtimeConfig, Providers providers, SnippetReflectionProvider snippetReflection, boolean hosted, boolean initForeignCalls) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java index 122edfbf7000..b3b25d09da09 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java @@ -69,7 +69,6 @@ import com.oracle.graal.pointsto.api.HostVM; import com.oracle.graal.pointsto.api.PointstoOptions; import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException; -import com.oracle.graal.pointsto.flow.AnalysisParsedGraph; import com.oracle.graal.pointsto.infrastructure.OriginalClassProvider; import com.oracle.graal.pointsto.meta.AnalysisField; import com.oracle.graal.pointsto.meta.AnalysisMethod; @@ -107,8 +106,6 @@ import com.oracle.svm.hosted.phases.AnalysisGraphBuilderPhase; import com.oracle.svm.hosted.phases.ImplicitAssertionsPhase; import com.oracle.svm.hosted.phases.InlineBeforeAnalysisPolicyImpl; -import com.oracle.svm.hosted.phases.IntrinsifyMethodHandlesInvocationPlugin.IntrinsificationRegistry; -import com.oracle.svm.hosted.snippets.ReflectionPlugins.ReflectionPluginRegistry; import com.oracle.svm.hosted.substitute.UnsafeAutomaticSubstitutionProcessor; import com.oracle.svm.util.ReflectionUtil; @@ -697,21 +694,6 @@ public boolean isAnalysisTrivialMethod(AnalysisMethod method) { return analysisTrivialMethods.containsKey(method); } - @Override - @SuppressWarnings("try") - public AnalysisParsedGraph parseBytecode(BigBang bb, AnalysisMethod analysisMethod) { - /* - * Temporarily pause the thread local registries. The results of parsing need to be - * persistent. - */ - try (AutoCloseable ignored1 = ReflectionPluginRegistry.pauseThreadLocalRegistry(); - AutoCloseable ignored2 = IntrinsificationRegistry.pauseThreadLocalRegistry()) { - return AnalysisParsedGraph.parseBytecode(bb, analysisMethod); - } catch (Throwable e) { - throw bb.getDebug().handle(e); - } - } - @Override public boolean hasNeverInlineDirective(ResolvedJavaMethod method) { if (GuardedAnnotationAccess.isAnnotationPresent(method, NeverInline.class)) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java index b4e99e6b99e0..a5e19e3231e3 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java @@ -110,14 +110,14 @@ public boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, Va Method switchTableMethod = ReflectionUtil.lookupMethod(aMethod.getDeclaringClass().getJavaClass(), method.getName()); Object switchTable = switchTableMethod.invoke(null); if (switchTable instanceof int[]) { - ImageSingletons.lookup(ReflectionPlugins.ReflectionPluginRegistry.class).add(b.getCallingContext(), switchTable); + ImageSingletons.lookup(ReflectionPlugins.ReflectionPluginRegistry.class).add(b.getMethod(), b.bci(), switchTable); } } catch (ReflectiveOperationException ex) { throw GraalError.shouldNotReachHere(ex); } } - Object switchTable = ImageSingletons.lookup(ReflectionPlugins.ReflectionPluginRegistry.class).get(b.getCallingContext()); + Object switchTable = ImageSingletons.lookup(ReflectionPlugins.ReflectionPluginRegistry.class).get(b.getMethod(), b.bci()); if (switchTable != null) { b.addPush(JavaKind.Object, ConstantNode.forConstant(snippetReflection.forObject(switchTable), 1, true, b.getMetaAccess())); return true; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ExperimentalNativeImageInlineDuringParsingPlugin.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ExperimentalNativeImageInlineDuringParsingPlugin.java deleted file mode 100644 index fc4663c156d8..000000000000 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ExperimentalNativeImageInlineDuringParsingPlugin.java +++ /dev/null @@ -1,570 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * 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.hosted.phases; - -import static com.oracle.svm.hosted.snippets.IntrinsificationPluginRegistry.CallSiteDescriptor; - -import java.util.List; -import java.util.Objects; - -import org.graalvm.collections.Pair; -import org.graalvm.compiler.core.common.PermanentBailoutException; -import org.graalvm.compiler.core.common.type.Stamp; -import org.graalvm.compiler.core.common.type.StampPair; -import org.graalvm.compiler.debug.Assertions; -import org.graalvm.compiler.debug.DebugContext; -import org.graalvm.compiler.graph.Graph.NodeEventListener; -import org.graalvm.compiler.graph.Graph.NodeEventScope; -import org.graalvm.compiler.graph.Node; -import org.graalvm.compiler.java.BytecodeParser; -import org.graalvm.compiler.java.GraphBuilderPhase; -import org.graalvm.compiler.nodes.ConstantNode; -import org.graalvm.compiler.nodes.FrameState; -import org.graalvm.compiler.nodes.NodeView; -import org.graalvm.compiler.nodes.ParameterNode; -import org.graalvm.compiler.nodes.ReturnNode; -import org.graalvm.compiler.nodes.StructuredGraph; -import org.graalvm.compiler.nodes.ValueNode; -import org.graalvm.compiler.nodes.calc.FloatingNode; -import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration; -import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; -import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderTool; -import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin; -import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext; -import org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin; -import org.graalvm.compiler.nodes.java.LoadFieldNode; -import org.graalvm.compiler.nodes.java.NewArrayNode; -import org.graalvm.compiler.nodes.java.NewInstanceNode; -import org.graalvm.compiler.nodes.spi.UncheckedInterfaceProvider; -import org.graalvm.compiler.nodes.type.StampTool; -import org.graalvm.compiler.options.Option; -import org.graalvm.compiler.options.OptionValues; -import org.graalvm.compiler.phases.OptimisticOptimizations; -import org.graalvm.compiler.phases.util.Providers; -import org.graalvm.compiler.word.WordTypes; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.util.GuardedAnnotationAccess; - -import com.oracle.graal.pointsto.meta.AnalysisMethod; -import com.oracle.graal.pointsto.meta.AnalysisType; -import com.oracle.graal.pointsto.meta.HostedProviders; -import com.oracle.svm.core.ParsingReason; -import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.DeoptTest; -import com.oracle.svm.core.annotate.NeverInline; -import com.oracle.svm.core.annotate.NeverInlineTrivial; -import com.oracle.svm.core.annotate.RestrictHeapAccess; -import com.oracle.svm.core.annotate.Uninterruptible; -import com.oracle.svm.core.option.HostedOptionKey; -import com.oracle.svm.core.util.VMError; -import com.oracle.svm.hosted.meta.HostedMethod; -import com.oracle.svm.hosted.phases.AnalysisGraphBuilderPhase.AnalysisBytecodeParser; -import com.oracle.svm.hosted.phases.ExperimentalNativeImageInlineDuringParsingPlugin.CallSite; -import com.oracle.svm.hosted.phases.ExperimentalNativeImageInlineDuringParsingPlugin.InvocationResult; -import com.oracle.svm.hosted.phases.ExperimentalNativeImageInlineDuringParsingPlugin.InvocationResultInline; -import com.oracle.svm.hosted.phases.IntrinsifyMethodHandlesInvocationPlugin.IntrinsificationRegistry; -import com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.SharedBytecodeParser; -import com.oracle.svm.hosted.snippets.ReflectionPlugins.ReflectionPluginRegistry; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * This plugin analyses the graph for the resolved Java method and specifies what should to be - * inlined during graph parsing before the static analysis. Plugin is searching for the methods that - * folds to a constant. - *

- * Usage: To use this plugin, add option -H:+InlineBeforeAnalysis to the native-image. - * - *

Structure of the ExperimentalNativeImageInlineDuringParsingPlugin

- * - *
    - * - *
  • InvocationResultInline -- stores inline data for the currently parsed invoke (resolved Java - * method).
  • - * - *
  • CallSite -- class that stores information about caller method. This information are used in - * InvocationResultInline and saved in the dataInline map from where we read information after - * analysis.
  • - * - *
  • TrivialMethodDetector -- class that analyses the callee graph and detects if it should be - * inlined or not.
  • - * - *
  • MethodNodeTrackingAndInline -- innerclass of the TrivialMethodDetector that collects - * information during graph construction to filter non-trivial methods and inline trivial invokes - * (callees children). It is searching for the method that folds to constant, so an unlimited amount - * of constants, parameter nodes and load filed nodes is allowed in the callees graph. On the other - * hand, we don't want to inline if the instance node, array node, store filed node is detected, and - * also we don't allow call target nodes and invokes that don't fold to constant. During graph - * analysis, this class also inlines trivial invokes (callees children).
  • - * - *
- *

- * The results of an inlining decision are placed in the - * {@link ExperimentalNativeImageInlineDuringParsingSupport#inlineData}. - *

- * Example: Assume that we have a graph with methods R, A, B, C, where R is the root method, A calls - * B, B calls C, and C returns the constant 1.* - * - *

- *       R
- *      /
- *     A
- *    /
- *   B
- *  /
- * C   <-- only returns 1
- * 
- *

- * We first analyze A and decide whether to enter the method for further analysis or not. In first - * case, we proceed and analyze the nodes deeper in the graph with MethodNodeTrackingAndInline. We - * repeat the procedure with B and C, and when the analysis of method C is complete, we decide to - * inline it because it only returns a constant value. After that, B folds to constant, so we inline - * this method too. Finally, for the same reason, we decide to inline A into R. - * - * This code is for testing purposes only and it will be replaced with a more elegant version. - */ -@SuppressWarnings("ThrowableNotThrown") -public class ExperimentalNativeImageInlineDuringParsingPlugin implements InlineInvokePlugin { - - public static class Options { - @Option(help = "Experimental: Inline methods which folds to constant during parsing before the static analysis.")// - public static final HostedOptionKey OldInlineBeforeAnalysis = new HostedOptionKey<>(false); - - @Option(help = "Maximum depth when inlining.")// - public static final HostedOptionKey InlineBeforeAnalysisMaxDepth = new HostedOptionKey<>(9); - - } - - private final ParsingReason reason; - private final HostedProviders providers; - - public ExperimentalNativeImageInlineDuringParsingPlugin(ParsingReason reason, HostedProviders providers) { - this.reason = reason; - this.providers = providers; - } - - @Override - @SuppressWarnings("try") - public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod callee, ValueNode[] args) { - ResolvedJavaMethod caller = b.getMethod(); - if (inliningBeforeAnalysisNotAllowed(b, callee, caller)) { - return null; - } - - InvocationResult inline = null; - CallSite callSite = new CallSite(b.getCallingContext(), toAnalysisMethod(callee)); - if (reason == ParsingReason.PointsToAnalysis) { - DebugContext debug = b.getDebug(); - try (DebugContext.Scope ignored = debug.scope("TrivialMethodDetectorAnalysis", this); - AutoCloseable ignored1 = ReflectionPluginRegistry.startThreadLocalRegistry(); - AutoCloseable ignored2 = IntrinsificationRegistry.startThreadLocalnRegistry()) { - TrivialMethodDetector detector = new TrivialMethodDetector(providers, ((SharedBytecodeParser) b).getGraphBuilderConfig(), b.getOptions(), b.getDebug()); - InvocationResult newResult = detector.analyzeMethod(callSite, (AnalysisMethod) callee, args); - ExperimentalNativeImageInlineDuringParsingPlugin.support().add(callSite, newResult); - inline = newResult; - } catch (Throwable ex) { - debug.handle(ex); - } - } else { - /* - * When parsing for compilation, we inline method that was inlined during analysis. - */ - inline = ExperimentalNativeImageInlineDuringParsingPlugin.support().inlineData.get(callSite); - } - - if (inline instanceof InvocationResultInline) { - InvocationResultInline inlineData = (InvocationResultInline) inline; - VMError.guarantee(inlineData.callee.equals(toAnalysisMethod(callee))); - - if (reason == ParsingReason.PointsToAnalysis) { - AnalysisMethod aMethod = (AnalysisMethod) callee; - - if (!SubstrateOptions.parseOnce()) { - aMethod.registerAsImplementationInvoked(null); - } - - if (!aMethod.isStatic() && args[0].isConstant()) { - AnalysisType receiverType = (AnalysisType) StampTool.typeOrNull(args[0]); - if (receiverType != null) { - receiverType.registerAsInHeap(); - } - } - } - return InlineInfo.createStandardInlineInfo(callee); - } else { - return null; - } - } - - static boolean inliningBeforeAnalysisNotAllowed(GraphBuilderContext b, ResolvedJavaMethod callee, ResolvedJavaMethod caller) { - return b.parsingIntrinsic() || - GuardedAnnotationAccess.isAnnotationPresent(callee, NeverInline.class) || GuardedAnnotationAccess.isAnnotationPresent(callee, NeverInlineTrivial.class) || - GuardedAnnotationAccess.isAnnotationPresent(callee, Uninterruptible.class) || GuardedAnnotationAccess.isAnnotationPresent(caller, Uninterruptible.class) || - GuardedAnnotationAccess.isAnnotationPresent(callee, RestrictHeapAccess.class) || GuardedAnnotationAccess.isAnnotationPresent(caller, RestrictHeapAccess.class) || - /* - * Inlining during parsing into a class initializer can lead to recursive - * parsing of that class initializer. - */ - caller.isClassInitializer() || - /* - * Canonicalization during inlining folds to a constant in analysis, but not - * for - * com.oracle.svm.hosted.image.NativeImageCodeCache.buildRuntimeMetadata. - * Either we need to re-use the analysis graphs or we have to apply the same - * canonicalizations for buildRuntimeMetadata. - */ - GuardedAnnotationAccess.isAnnotationPresent(caller, DeoptTest.class) || - b.getDepth() > ExperimentalNativeImageInlineDuringParsingPlugin.Options.InlineBeforeAnalysisMaxDepth.getValue(b.getOptions()) || - isRecursiveCall(b.getCallingContext(), callee) || - /* - * We don't want to process invokes if bci is not unique. - */ - b.bciCanBeDuplicated(); - } - - public static boolean isRecursiveCall(List> callingContext, ResolvedJavaMethod callee) { - return callingContext.stream().map(Pair::getLeft).anyMatch(caller -> caller.equals(callee)); - } - - public static ExperimentalNativeImageInlineDuringParsingSupport support() { - return ImageSingletons.lookup(ExperimentalNativeImageInlineDuringParsingSupport.class); - } - - static AnalysisMethod toAnalysisMethod(ResolvedJavaMethod method) { - if (method instanceof AnalysisMethod) { - return (AnalysisMethod) method; - } else { - return ((HostedMethod) method).getWrapped(); - } - } - - /** - * Stores information about caller method. This information are used in - * {@link InvocationResultInline}. - */ - static final class CallSite extends CallSiteDescriptor { - final AnalysisMethod callee; - - CallSite(List> callingContext, AnalysisMethod callee) { - super(callingContext); - this.callee = callee; - } - - @Override - public int hashCode() { - return super.hashCode() ^ callee.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return super.equals(obj) && callee.equals(((CallSite) obj).callee); - } - - @Override - public String toString() { - return super.toString() + callee.format("%h.%n(%p)"); - } - } - - static class InvocationResult { - static final InvocationResult ANALYSIS_TOO_COMPLICATED = new InvocationResult() { - @Override - public String toString() { - return "Analysis to complicated."; - } - }; - } - - public static class InvocationResultInline extends InvocationResult { - final CallSite callSite; - final AnalysisMethod callee; - - InvocationResultInline(CallSite callSite, AnalysisMethod callee) { - this.callSite = callSite; - this.callee = callee; - } - - @Override - public String toString() { - return callSite + " -> " + callee.format("%h.%n(%p)"); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InvocationResultInline that = (InvocationResultInline) o; - return callSite.equals(that.callSite) && - Objects.equals(callee, that.callee); - } - - @Override - public int hashCode() { - return Objects.hash(callSite, callee); - } - } -} - -/** - * This class detects what can be inlined. - */ -class TrivialMethodDetector { - - private final HostedProviders providers; - private final GraphBuilderConfiguration prototypeGraphBuilderConfig; - private final OptionValues options; - private final DebugContext debug; - - TrivialMethodDetector(HostedProviders providers, GraphBuilderConfiguration originalGraphBuilderConfig, OptionValues options, DebugContext debug) { - this.debug = debug; - this.prototypeGraphBuilderConfig = makePrototypeGraphBuilderConfig(originalGraphBuilderConfig); - this.options = options; - this.providers = providers; - } - - private static GraphBuilderConfiguration makePrototypeGraphBuilderConfig(GraphBuilderConfiguration originalGraphBuilderConfig) { - GraphBuilderConfiguration result = originalGraphBuilderConfig.copy(); - result.getPlugins().clearInlineInvokePlugins(); - for (InlineInvokePlugin inlineInvokePlugin : originalGraphBuilderConfig.getPlugins().getInlineInvokePlugins()) { - if (!(inlineInvokePlugin instanceof ExperimentalNativeImageInlineDuringParsingPlugin)) { - result.getPlugins().appendInlineInvokePlugin(inlineInvokePlugin); - } - } - return result; - } - - @SuppressWarnings("try") - InvocationResult analyzeMethod(CallSite callSite, AnalysisMethod method, ValueNode[] args) { - if (!method.hasBytecodes()) { - /* Native method. */ - return InvocationResult.ANALYSIS_TOO_COMPLICATED; - } else if (providers.getGraphBuilderPlugins().getInvocationPlugins().lookupInvocation(method) != null) { - /* Method has an invocation plugin that we must not miss. */ - return InvocationResult.ANALYSIS_TOO_COMPLICATED; - } else if (method.isSynchronized()) { - /* - * Synchronization operations will always bring us above the node limit, so no point in - * starting an analysis. - */ - return InvocationResult.ANALYSIS_TOO_COMPLICATED; - } - - GraphBuilderConfiguration graphBuilderConfig = prototypeGraphBuilderConfig.copy(); - graphBuilderConfig.getPlugins().appendInlineInvokePlugin(new TrivialChildrenInline(callSite)); - graphBuilderConfig.getPlugins().appendParameterPlugin(new TrivialMethodDetectorParameterPlugin(args)); - MethodNodeTracking methodNodeTracking = new MethodNodeTracking(); - - StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build(); - - try (DebugContext.Scope ignored = debug.scope("InlineDuringParsingAnalysis", graph, method, this)) { - - TrivialMethodDetectorGraphBuilderPhase builderPhase = new TrivialMethodDetectorGraphBuilderPhase(providers, graphBuilderConfig, OptimisticOptimizations.NONE, null, - providers.getWordTypes()); - - try (NodeEventScope ignored1 = graph.trackNodeEvents(methodNodeTracking)) { - builderPhase.apply(graph); - } - - debug.dump(DebugContext.VERBOSE_LEVEL, graph, "InlineDuringParsingAnalysis successful"); - return new InvocationResultInline(callSite, method); - } catch (TrivialMethodDetectorBailoutException ex) { - debug.dump(DebugContext.VERBOSE_LEVEL, graph, "InlineDuringParsingAnalysis failed with %s", ex); - /* - * We saw not allowed node and decide to not inline that invocation. - */ - return InvocationResult.ANALYSIS_TOO_COMPLICATED; - } catch (Throwable ex) { - if (Assertions.assertionsEnabled()) { - throw debug.handle(ex); - } - /* - * Whatever else happens during the analysis is non-fatal because we can just not inline - * that invocation. - */ - return InvocationResult.ANALYSIS_TOO_COMPLICATED; - } - } - - /** - * We collect information during graph construction to filter non-trivial methods. - */ - static class MethodNodeTracking extends NodeEventListener { - - @Override - public void nodeAdded(Node node) { - if (node instanceof ConstantNode) { - /* An unlimited amount of constants is allowed. */ - /* Nothing to do, an unlimited amount of constants is allowed. We like constants. */ - } else if (node instanceof ParameterNode) { - /* Nothing to do, an unlimited amount of parameters is allowed. */ - /* Nothing to do. */ - } else if (node instanceof ReturnNode) { - /* - * Nothing to do, returning a value is fine. We don't allow control flow so there - * can never be more than one return. - */ - } else if (node instanceof LoadFieldNode) { - /* Nothing to do, it's ok to read a static or instance field. */ - } else if (node instanceof FrameState) { - if (((FrameState) node).bci == 0) { - /* Nothing to do, it's ok to have frame state for the start node. */ - } else { - throw new TrivialMethodDetectorBailoutException("Only frame state for the start node is allowed: " + node); - } - } else if (node instanceof NewArrayNode || node instanceof NewInstanceNode) { - /* - * We go further in the analysis to check if any callees can be inline into this - * method. If there was non-constant array or object, method won't be inlined - * because of elimination for existing store field nodes. - */ - } else { - throw new TrivialMethodDetectorBailoutException("Node not allowed: " + node); - - } - } - } - - /** - * Inline trivial invokes (children). - */ - class TrivialChildrenInline implements InlineInvokePlugin { - private final CallSite callSite; - - TrivialChildrenInline(CallSite callSite) { - this.callSite = callSite; - } - - @Override - public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod callee, ValueNode[] args) { - if (ExperimentalNativeImageInlineDuringParsingPlugin.inliningBeforeAnalysisNotAllowed(b, callee, b.getMethod())) { - return null; - } - - /* - * In order to detect recursion it is necessary to preserve all information about - * callers from the beginning of the analysis to the current caller. We can find this - * information in the call site because it's callee is the current caller. - */ - List> callingContext = concatCallingContexts(b.getCallingContext()); - - if (ExperimentalNativeImageInlineDuringParsingPlugin.isRecursiveCall(callingContext, callee)) { - return null; - } - - CallSite newCallSite = new CallSite(callingContext, ExperimentalNativeImageInlineDuringParsingPlugin.toAnalysisMethod(callee)); - InvocationResult inline = analyzeMethod(newCallSite, (AnalysisMethod) callee, args); - - if (inline instanceof InvocationResultInline) { - return InlineInfo.createStandardInlineInfo(callee); - } else { - return null; - } - } - - private List> concatCallingContexts(List> baseContext) { - for (int i = 0; i < callSite.getLength(); i++) { - baseContext.add(Pair.create(callSite.getCaller()[i], callSite.getBci()[i])); - } - return baseContext; - } - } -} - -class TrivialMethodDetectorBailoutException extends PermanentBailoutException { - - private static final long serialVersionUID = -1063600090362390263L; - - TrivialMethodDetectorBailoutException(String message) { - super(message); - } - - /** - * For performance reasons, this exception does not record any stack trace information. - */ - @SuppressWarnings("sync-override") - @Override - public final Throwable fillInStackTrace() { - return this; - } -} - -class TrivialMethodDetectorGraphBuilderPhase extends AnalysisGraphBuilderPhase { - - TrivialMethodDetectorGraphBuilderPhase(Providers providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, - IntrinsicContext initialIntrinsicContext, WordTypes wordTypes) { - super(providers, graphBuilderConfig, optimisticOpts, initialIntrinsicContext, wordTypes); - } - - @Override - protected BytecodeParser createBytecodeParser(StructuredGraph graph, BytecodeParser parent, ResolvedJavaMethod method, int entryBCI, IntrinsicContext intrinsicContext) { - return new TrivialMethodDetectorBytecodeParser(this, graph, parent, method, entryBCI, intrinsicContext); - } -} - -class TrivialMethodDetectorBytecodeParser extends AnalysisBytecodeParser { - TrivialMethodDetectorBytecodeParser(GraphBuilderPhase.Instance graphBuilderInstance, StructuredGraph graph, BytecodeParser parent, ResolvedJavaMethod method, - int entryBCI, - IntrinsicContext intrinsicContext) { - super(graphBuilderInstance, graph, parent, method, entryBCI, intrinsicContext); - } - - @Override - protected boolean needsExplicitNullCheckException(ValueNode object) { - if (currentBlock.exceptionDispatchBlock() != null) { - throw new TrivialMethodDetectorBailoutException("Null check inside exception handler"); - } - return false; - } -} - -class TrivialMethodDetectorParameterPlugin implements ParameterPlugin { - - private final ValueNode[] args; - - TrivialMethodDetectorParameterPlugin(ValueNode[] args) { - this.args = args; - } - - @Override - public FloatingNode interceptParameter(GraphBuilderTool b, int index, StampPair stamp) { - ValueNode arg = args[index]; - Stamp argStamp = arg.stamp(NodeView.DEFAULT); - if (arg.isConstant()) { - return new ConstantNode(arg.asConstant(), argStamp); - } else { - StampPair stampPair; - if (arg instanceof UncheckedInterfaceProvider) { - stampPair = StampPair.create(argStamp, ((UncheckedInterfaceProvider) arg).uncheckedStamp()); - } else { - stampPair = StampPair.createSingle(argStamp); - } - return new ParameterNode(index, stampPair); - } - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ExperimentalNativeImageInlineDuringParsingSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ExperimentalNativeImageInlineDuringParsingSupport.java deleted file mode 100644 index 31d64404d6cc..000000000000 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/ExperimentalNativeImageInlineDuringParsingSupport.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * 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.hosted.phases; - -import java.util.concurrent.ConcurrentHashMap; - -import com.oracle.svm.core.util.VMError; -import com.oracle.svm.hosted.phases.ExperimentalNativeImageInlineDuringParsingPlugin.InvocationResult; - -public class ExperimentalNativeImageInlineDuringParsingSupport { - private boolean nativeImageInlineDuringParsingDisabled; - - /** - * The map that contains all inlining decisions. During analysis we store information about - * inlining decision so we can reuse it during compilation. - */ - final ConcurrentHashMap inlineData = new ConcurrentHashMap<>(); - - public void disableNativeImageInlineDuringParsing() { - this.nativeImageInlineDuringParsingDisabled = true; - } - - public boolean isNativeImageInlineDuringParsingDisabled() { - return nativeImageInlineDuringParsingDisabled; - } - - void add(ExperimentalNativeImageInlineDuringParsingPlugin.CallSite callSite, ExperimentalNativeImageInlineDuringParsingPlugin.InvocationResult value) { - InvocationResult existingResult = inlineData.putIfAbsent(callSite, value); - VMError.guarantee(existingResult == null, "Duplicate bci found during inlining in analysis. This is not supported. Please find the cause of the bci duplication and filtered it out."); - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/IntrinsifyMethodHandlesInvocationPlugin.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/IntrinsifyMethodHandlesInvocationPlugin.java index f2c5b00c63f0..f5655c04dc01 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/IntrinsifyMethodHandlesInvocationPlugin.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/IntrinsifyMethodHandlesInvocationPlugin.java @@ -166,18 +166,6 @@ public class IntrinsifyMethodHandlesInvocationPlugin implements NodePlugin { public static class IntrinsificationRegistry extends IntrinsificationPluginRegistry { - - private static IntrinsificationRegistry singleton() { - return ImageSingletons.lookup(IntrinsificationRegistry.class); - } - - public static AutoCloseable startThreadLocalnRegistry() { - return IntrinsificationPluginRegistry.startThreadLocalRegistry(singleton()); - } - - public static AutoCloseable pauseThreadLocalRegistry() { - return IntrinsificationPluginRegistry.pauseThreadLocalRegistry(singleton()); - } } private final ParsingReason reason; @@ -521,7 +509,7 @@ private boolean processInvokeWithMethodHandle(GraphBuilderContext b, Replacement * intrinsified during analysis. Otherwise new code that was not seen as reachable by the * static analysis would be compiled. */ - if (reason != ParsingReason.PointsToAnalysis && intrinsificationRegistry.get(b.getCallingContext()) != Boolean.TRUE) { + if (reason != ParsingReason.PointsToAnalysis && intrinsificationRegistry.get(b.getMethod(), b.bci()) != Boolean.TRUE) { return reportUnsupportedFeature(b, methodHandleMethod); } Plugins graphBuilderPlugins = new Plugins(parsingProviders.getReplacements().getGraphBuilderPlugins()); @@ -571,7 +559,7 @@ private boolean processInvokeWithMethodHandle(GraphBuilderContext b, Replacement * Successfully intrinsified during analysis, remember that we can intrinsify * when parsing for compilation. */ - intrinsificationRegistry.add(b.getCallingContext(), Boolean.TRUE); + intrinsificationRegistry.add(b.getMethod(), b.bci(), Boolean.TRUE); } return true; } catch (AbortTransplantException ex) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java index fa49970f8705..46641609e457 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java @@ -99,10 +99,6 @@ protected SharedBytecodeParser(GraphBuilderPhase.Instance graphBuilderInstance, this.allowIncompleteClassPath = allowIncompleteClasspath; } - public GraphBuilderConfiguration getGraphBuilderConfig() { - return graphBuilderConfig; - } - @Override protected RuntimeException throwParserError(Throwable e) { if (e instanceof UserException) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/IntrinsificationPluginRegistry.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/IntrinsificationPluginRegistry.java index c7459fa15056..21816faa1317 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/IntrinsificationPluginRegistry.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/IntrinsificationPluginRegistry.java @@ -24,13 +24,8 @@ */ package com.oracle.svm.hosted.snippets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import org.graalvm.collections.Pair; - import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.meta.HostedMethod; @@ -39,56 +34,32 @@ public class IntrinsificationPluginRegistry { - public static class CallSiteDescriptor { - private final AnalysisMethod[] caller; - private final int[] bci; - private final int length; - - public CallSiteDescriptor(List> callingContext) { - this.length = callingContext.size(); - this.caller = new AnalysisMethod[length]; - this.bci = new int[length]; - int i = 0; - for (Pair pair : callingContext) { - this.caller[i] = toAnalysisMethod(pair.getLeft()); - this.bci[i] = pair.getRight(); - i++; - } - } - - public AnalysisMethod[] getCaller() { - return caller; - } - - public int[] getBci() { - return bci; - } + static final class CallSiteDescriptor { + private final AnalysisMethod method; + private final int bci; - public int getLength() { - return length; + private CallSiteDescriptor(ResolvedJavaMethod method, int bci) { + this.method = toAnalysisMethod(method); + this.bci = bci; } @Override public boolean equals(Object obj) { if (obj instanceof CallSiteDescriptor) { CallSiteDescriptor other = (CallSiteDescriptor) obj; - return Arrays.equals(this.bci, other.bci) && Arrays.equals(this.caller, other.caller); + return other.bci == this.bci && other.method.equals(this.method); } return false; } @Override public int hashCode() { - return java.util.Arrays.hashCode(caller) ^ java.util.Arrays.hashCode(bci); + return method.hashCode() ^ bci; } @Override public String toString() { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < caller.length; i++) { - sb.append(caller[i].format("%h.%n(%p)")).append("@").append(bci[i]).append(System.lineSeparator()); - } - return sb.toString(); + return method.format("%h.%n(%p)") + "@" + bci; } private static AnalysisMethod toAnalysisMethod(ResolvedJavaMethod method) { @@ -102,67 +73,29 @@ private static AnalysisMethod toAnalysisMethod(ResolvedJavaMethod method) { } private static final Object NULL_MARKER = new Object(); + /** * Contains all the elements intrinsified during analysis. Only these elements will be * intrinsified during compilation. We cannot intrinsify an element during compilation if it was * not intrinsified during analysis since it can lead to compiling code that was not seen during * analysis. */ - private final ConcurrentHashMap globalAnalysisElements = new ConcurrentHashMap<>(); - public final Set methodsWithIntrinsification = ConcurrentHashMap.newKeySet(); - public final ThreadLocal> threadLocalRegistry = new ThreadLocal<>(); - - public static AutoCloseable startThreadLocalRegistry(IntrinsificationPluginRegistry registry) { - return new AutoCloseable() { - { - assert registry.threadLocalRegistry.get() == null; - registry.threadLocalRegistry.set(new ConcurrentHashMap<>()); - } + private final ConcurrentHashMap analysisElements = new ConcurrentHashMap<>(); - @Override - public void close() { - registry.threadLocalRegistry.set(null); - } - }; - } - - public static AutoCloseable pauseThreadLocalRegistry(IntrinsificationPluginRegistry registry) { - return new AutoCloseable() { - final ConcurrentHashMap threadLocalRegistryBackup; - { - /* Cache and remove the threadLocalRegistry temporarily. */ - threadLocalRegistryBackup = registry.threadLocalRegistry.get(); - registry.threadLocalRegistry.set(null); - } - - @Override - public void close() { - /* Restore threadLocalRegistry. */ - registry.threadLocalRegistry.set(threadLocalRegistryBackup); - } - }; - } - - private ConcurrentHashMap getAnalysisElements() { - return threadLocalRegistry.get() == null ? globalAnalysisElements : threadLocalRegistry.get(); - } - - public void add(List> callingContext, Object element) { + public void add(ResolvedJavaMethod method, int bci, Object element) { Object nonNullElement = element != null ? element : NULL_MARKER; - Object previous = getAnalysisElements().putIfAbsent(new CallSiteDescriptor(callingContext), nonNullElement); - VMError.guarantee(previous == null || previous == nonNullElement, "Newly intrinsified element is different than the previous"); + Object previous = analysisElements.put(new CallSiteDescriptor(method, bci), nonNullElement); - /* save information that method has intrinsification */ - methodsWithIntrinsification.add((AnalysisMethod) callingContext.get(0).getLeft()); + /* + * New elements can only be added when the intrinsification is executed during the analysis. + * If an intrinsified element was already registered that's an error. + */ + VMError.guarantee(previous == null, "Detected previously intrinsified element"); } @SuppressWarnings("unchecked") - public T get(List> callingContext) { - Object nonNullElement = getAnalysisElements().get(new CallSiteDescriptor(callingContext)); + public T get(ResolvedJavaMethod method, int bci) { + Object nonNullElement = analysisElements.get(new CallSiteDescriptor(method, bci)); return nonNullElement != NULL_MARKER ? (T) nonNullElement : null; } - - public boolean hasIntrinsifications(AnalysisMethod method) { - return methodsWithIntrinsification.contains(method); - } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ReflectionPlugins.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ReflectionPlugins.java index 5201c46896b0..6ce756016e14 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ReflectionPlugins.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ReflectionPlugins.java @@ -94,18 +94,6 @@ */ public final class ReflectionPlugins { public static class ReflectionPluginRegistry extends IntrinsificationPluginRegistry { - - private static ReflectionPluginRegistry singleton() { - return ImageSingletons.lookup(ReflectionPluginRegistry.class); - } - - public static AutoCloseable startThreadLocalRegistry() { - return IntrinsificationPluginRegistry.startThreadLocalRegistry(singleton()); - } - - public static AutoCloseable pauseThreadLocalRegistry() { - return IntrinsificationPluginRegistry.pauseThreadLocalRegistry(singleton()); - } } static class Options { @@ -491,10 +479,10 @@ private T getIntrinsic(GraphBuilderContext context, T element) { } /* During parsing for analysis we intrinsify and cache the result for compilation. */ - ImageSingletons.lookup(ReflectionPluginRegistry.class).add(context.getCallingContext(), replaced); + ImageSingletons.lookup(ReflectionPluginRegistry.class).add(context.getMethod(), context.bci(), replaced); } /* During parsing for compilation we only intrinsify if intrinsified during analysis. */ - return ImageSingletons.lookup(ReflectionPluginRegistry.class).get(context.getCallingContext()); + return ImageSingletons.lookup(ReflectionPluginRegistry.class).get(context.getMethod(), context.bci()); } private static boolean isDeleted(T element, MetaAccessProvider metaAccess) { 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 d899459ea1f4..dba1c552e7cb 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 @@ -158,9 +158,6 @@ import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.SVMHost; import com.oracle.svm.hosted.meta.HostedType; -import com.oracle.svm.hosted.phases.ExperimentalNativeImageInlineDuringParsingSupport; -import com.oracle.svm.hosted.phases.IntrinsifyMethodHandlesInvocationPlugin; -import com.oracle.svm.hosted.snippets.ReflectionPlugins; import com.oracle.svm.hosted.snippets.SubstrateGraphBuilderPlugins; import com.oracle.svm.truffle.api.SubstrateThreadLocalHandshake; import com.oracle.svm.truffle.api.SubstrateThreadLocalHandshakeSnippets; @@ -310,9 +307,6 @@ private static T invokeStaticMethod(String className, String methodName, Col public void afterRegistration(AfterRegistrationAccess a) { imageClassLoader = a.getApplicationClassLoader(); - /* Inline during parsing does not work well with deopt targets ATM. */ - ImageSingletons.lookup(ExperimentalNativeImageInlineDuringParsingSupport.class).disableNativeImageInlineDuringParsing(); - TruffleRuntime runtime = Truffle.getRuntime(); UserError.guarantee(runtime != null, "TruffleRuntime not available via Truffle.getRuntime()"); UserError.guarantee(runtime instanceof SubstrateTruffleRuntime || runtime instanceof DefaultTruffleRuntime, @@ -590,16 +584,6 @@ public InlineInfo shouldInlineInvoke(GraphBuilderContext builder, ResolvedJavaMe return InlineInfo.DO_NOT_INLINE_WITH_EXCEPTION; } - /* - * We can't inline methods that use intrnsifications. By inlining them we are opening a - * door for inconsistencies between parsing in analysis and parsing for runtime methods. - */ - if (ImageSingletons.lookup(IntrinsifyMethodHandlesInvocationPlugin.IntrinsificationRegistry.class).hasIntrinsifications((AnalysisMethod) original)) { - return InlineInfo.DO_NOT_INLINE_WITH_EXCEPTION; - } else if (ImageSingletons.lookup(ReflectionPlugins.ReflectionPluginRegistry.class).hasIntrinsifications((AnalysisMethod) original)) { - return InlineInfo.DO_NOT_INLINE_WITH_EXCEPTION; - } - for (ResolvedJavaMethod m : partialEvaluator.getNeverInlineMethods()) { if (original.equals(m)) { return InlineInfo.DO_NOT_INLINE_WITH_EXCEPTION;