Search in sources :

Example 1 with CachingPEGraphDecoder

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

the class PartialEvaluator method createGraphDecoder.

@SuppressWarnings("unused")
protected PEGraphDecoder createGraphDecoder(StructuredGraph graph, final HighTierContext tierContext, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins, ParameterPlugin parameterPlugin, NodePlugin[] nodePluginList, ResolvedJavaMethod callInlined, SourceLanguagePositionProvider sourceLanguagePositionProvider) {
    final GraphBuilderConfiguration newConfig = configForParsing.copy();
    if (newConfig.trackNodeSourcePosition()) {
        graph.setTrackNodeSourcePosition();
    }
    InvocationPlugins parsingInvocationPlugins = newConfig.getPlugins().getInvocationPlugins();
    Plugins plugins = newConfig.getPlugins();
    ReplacementsImpl replacements = (ReplacementsImpl) providers.getReplacements();
    plugins.clearInlineInvokePlugins();
    plugins.appendInlineInvokePlugin(replacements);
    plugins.appendInlineInvokePlugin(new ParsingInlineInvokePlugin(replacements, parsingInvocationPlugins, loopExplosionPlugin));
    if (!TruffleCompilerOptions.getValue(PrintTruffleExpansionHistogram)) {
        plugins.appendInlineInvokePlugin(new InlineDuringParsingPlugin());
    }
    Providers compilationUnitProviders = providers.copyWith(new TruffleConstantFieldProvider(providers.getConstantFieldProvider(), providers.getMetaAccess()));
    return new CachingPEGraphDecoder(architecture, graph, compilationUnitProviders, newConfig, TruffleCompilerImpl.Optimizations, AllowAssumptions.ifNonNull(graph.getAssumptions()), loopExplosionPlugin, decodingInvocationPlugins, inlineInvokePlugins, parameterPlugin, nodePluginList, callInlined, sourceLanguagePositionProvider);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) InlineDuringParsingPlugin(org.graalvm.compiler.replacements.InlineDuringParsingPlugin) ReplacementsImpl(org.graalvm.compiler.replacements.ReplacementsImpl) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) Providers(org.graalvm.compiler.phases.util.Providers) CachingPEGraphDecoder(org.graalvm.compiler.replacements.CachingPEGraphDecoder) TruffleGraphBuilderPlugins(org.graalvm.compiler.truffle.compiler.substitutions.TruffleGraphBuilderPlugins) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 2 with CachingPEGraphDecoder

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

the class PEGraphDecoderTest method test.

@Test
@SuppressWarnings("try")
public void test() {
    ResolvedJavaMethod testMethod = getResolvedJavaMethod(PEGraphDecoderTest.class, "doTest", Object.class);
    StructuredGraph targetGraph = null;
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope scope = debug.scope("GraphPETest", testMethod)) {
        GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withEagerResolving(true).withUnresolvedIsError(true);
        registerPlugins(graphBuilderConfig.getPlugins().getInvocationPlugins());
        targetGraph = new StructuredGraph.Builder(getInitialOptions(), debug, AllowAssumptions.YES).method(testMethod).build();
        CachingPEGraphDecoder decoder = new CachingPEGraphDecoder(getTarget().arch, targetGraph, getProviders(), graphBuilderConfig, OptimisticOptimizations.NONE, AllowAssumptions.YES, null, null, new InlineInvokePlugin[] { new InlineAll() }, null, null, null, null);
        decoder.decode(testMethod, false);
        debug.dump(DebugContext.BASIC_LEVEL, targetGraph, "Target Graph");
        targetGraph.verify();
        PhaseContext context = new PhaseContext(getProviders());
        new CanonicalizerPhase().apply(targetGraph, context);
        targetGraph.verify();
    } catch (Throwable ex) {
        if (targetGraph != null) {
            debug.dump(DebugContext.BASIC_LEVEL, targetGraph, ex.toString());
        }
        debug.handle(ex);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) CachingPEGraphDecoder(org.graalvm.compiler.replacements.CachingPEGraphDecoder) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Aggregations

GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)2 CachingPEGraphDecoder (org.graalvm.compiler.replacements.CachingPEGraphDecoder)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)1 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)1 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)1 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)1 Providers (org.graalvm.compiler.phases.util.Providers)1 InlineDuringParsingPlugin (org.graalvm.compiler.replacements.InlineDuringParsingPlugin)1 ReplacementsImpl (org.graalvm.compiler.replacements.ReplacementsImpl)1 TruffleGraphBuilderPlugins (org.graalvm.compiler.truffle.compiler.substitutions.TruffleGraphBuilderPlugins)1 Test (org.junit.Test)1