Search in sources :

Example 1 with PEGraphDecoder

use of org.graalvm.compiler.replacements.PEGraphDecoder in project graal by oracle.

the class SubstrateReplacements method getSnippet.

@Override
public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry, Object[] args, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition) {
    Integer startOffset = snippetStartOffsets.get(method);
    if (startOffset == null) {
        throw VMError.shouldNotReachHere("snippet not found: " + method.format("%H.%n(%p)"));
    }
    ParameterPlugin parameterPlugin = null;
    if (args != null) {
        parameterPlugin = new ConstantBindingParameterPlugin(args, providers.getMetaAccess(), snippetReflection);
    }
    EncodedGraph encodedGraph = new EncodedGraph(snippetEncoding, startOffset, snippetObjects, snippetNodeClasses, null, null, null, false, trackNodeSourcePosition);
    try (DebugContext debug = openDebugContext("SVMSnippet_", method)) {
        StructuredGraph result = new StructuredGraph.Builder(options, debug).method(method).trackNodeSourcePosition(trackNodeSourcePosition).build();
        PEGraphDecoder graphDecoder = new PEGraphDecoder(ConfigurationValues.getTarget().arch, result, providers.getMetaAccess(), providers.getConstantReflection(), providers.getConstantFieldProvider(), providers.getStampProvider(), null, snippetInvocationPlugins, new InlineInvokePlugin[0], parameterPlugin, null, null, null) {

            @Override
            protected EncodedGraph lookupEncodedGraph(ResolvedJavaMethod lookupMethod, ResolvedJavaMethod originalMethod, BytecodeProvider intrinsicBytecodeProvider, boolean track) {
                if (lookupMethod.equals(method)) {
                    assert !track || encodedGraph.trackNodeSourcePosition();
                    return encodedGraph;
                } else {
                    throw VMError.shouldNotReachHere(method.format("%H.%n(%p)"));
                }
            }
        };
        graphDecoder.decode(method, trackNodeSourcePosition);
        assert result.verify();
        return result;
    }
}
Also used : ConstantBindingParameterPlugin(org.graalvm.compiler.replacements.ConstantBindingParameterPlugin) ParameterPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) EncodedGraph(org.graalvm.compiler.nodes.EncodedGraph) PEGraphDecoder(org.graalvm.compiler.replacements.PEGraphDecoder) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) DebugContext(org.graalvm.compiler.debug.DebugContext) ConstantBindingParameterPlugin(org.graalvm.compiler.replacements.ConstantBindingParameterPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with PEGraphDecoder

use of org.graalvm.compiler.replacements.PEGraphDecoder in project graal by oracle.

the class PartialEvaluator method doGraphPE.

protected void doGraphPE(CompilableTruffleAST compilable, StructuredGraph graph, HighTierContext tierContext, TruffleInliningPlan inliningDecision) {
    LoopExplosionPlugin loopExplosionPlugin = new PELoopExplosionPlugin();
    ParameterPlugin parameterPlugin = new InterceptReceiverPlugin(compilable);
    ReplacementsImpl replacements = (ReplacementsImpl) providers.getReplacements();
    InlineInvokePlugin[] inlineInvokePlugins;
    InlineInvokePlugin inlineInvokePlugin = new PEInlineInvokePlugin(inliningDecision);
    HistogramInlineInvokePlugin histogramPlugin = null;
    if (TruffleCompilerOptions.getValue(PrintTruffleExpansionHistogram)) {
        histogramPlugin = new HistogramInlineInvokePlugin(graph);
        inlineInvokePlugins = new InlineInvokePlugin[] { replacements, inlineInvokePlugin, histogramPlugin };
    } else {
        inlineInvokePlugins = new InlineInvokePlugin[] { replacements, inlineInvokePlugin };
    }
    SourceLanguagePositionProvider sourceLanguagePosition = new TruffleSourceLanguagePositionProvider(inliningDecision);
    PEGraphDecoder decoder = createGraphDecoder(graph, tierContext, loopExplosionPlugin, decodingInvocationPlugins, inlineInvokePlugins, parameterPlugin, nodePlugins, callInlinedMethod, sourceLanguagePosition);
    decoder.decode(graph.method(), graph.trackNodeSourcePosition());
    if (TruffleCompilerOptions.getValue(PrintTruffleExpansionHistogram)) {
        histogramPlugin.print(compilable);
    }
}
Also used : SourceLanguagePositionProvider(org.graalvm.compiler.graph.SourceLanguagePositionProvider) ParameterPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin) ReplacementsImpl(org.graalvm.compiler.replacements.ReplacementsImpl) LoopExplosionPlugin(org.graalvm.compiler.nodes.graphbuilderconf.LoopExplosionPlugin) CachingPEGraphDecoder(org.graalvm.compiler.replacements.CachingPEGraphDecoder) PEGraphDecoder(org.graalvm.compiler.replacements.PEGraphDecoder) HistogramInlineInvokePlugin(org.graalvm.compiler.truffle.compiler.debug.HistogramInlineInvokePlugin) InlineInvokePlugin(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin) HistogramInlineInvokePlugin(org.graalvm.compiler.truffle.compiler.debug.HistogramInlineInvokePlugin)

Aggregations

ParameterPlugin (org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin)2 PEGraphDecoder (org.graalvm.compiler.replacements.PEGraphDecoder)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 BytecodeProvider (org.graalvm.compiler.bytecode.BytecodeProvider)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 SourceLanguagePositionProvider (org.graalvm.compiler.graph.SourceLanguagePositionProvider)1 EncodedGraph (org.graalvm.compiler.nodes.EncodedGraph)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 InlineInvokePlugin (org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin)1 LoopExplosionPlugin (org.graalvm.compiler.nodes.graphbuilderconf.LoopExplosionPlugin)1 CachingPEGraphDecoder (org.graalvm.compiler.replacements.CachingPEGraphDecoder)1 ConstantBindingParameterPlugin (org.graalvm.compiler.replacements.ConstantBindingParameterPlugin)1 ReplacementsImpl (org.graalvm.compiler.replacements.ReplacementsImpl)1 HistogramInlineInvokePlugin (org.graalvm.compiler.truffle.compiler.debug.HistogramInlineInvokePlugin)1