Search in sources :

Example 1 with DebugDumpScope

use of org.graalvm.compiler.debug.DebugDumpScope in project graal by oracle.

the class InliningTest method getGraph.

@SuppressWarnings("try")
private StructuredGraph getGraph(final String snippet, final boolean eagerInfopointMode) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("InliningTest", new DebugDumpScope(snippet, true))) {
        ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
        Builder builder = builder(method, AllowAssumptions.YES, debug);
        StructuredGraph graph = eagerInfopointMode ? parse(builder, getDebugGraphBuilderSuite()) : parse(builder, getEagerGraphBuilderSuite());
        try (DebugContext.Scope s2 = debug.scope("Inlining", graph)) {
            PhaseSuite<HighTierContext> graphBuilderSuite = eagerInfopointMode ? getCustomGraphBuilderSuite(GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withFullInfopoints(true)) : getDefaultGraphBuilderSuite();
            HighTierContext context = new HighTierContext(getProviders(), graphBuilderSuite, OptimisticOptimizations.ALL);
            debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
            new CanonicalizerPhase().apply(graph, context);
            new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
            debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
            new CanonicalizerPhase().apply(graph, context);
            new DeadCodeEliminationPhase().apply(graph);
            return graph;
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) Builder(org.graalvm.compiler.nodes.StructuredGraph.Builder) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with DebugDumpScope

use of org.graalvm.compiler.debug.DebugDumpScope in project graal by oracle.

the class LoopFullUnrollTest method test.

@SuppressWarnings("try")
private void test(String snippet, int loopCount) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope(getClass().getSimpleName(), new DebugDumpScope(snippet))) {
        final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO, debug);
        PhaseContext context = new PhaseContext(getProviders());
        new LoopFullUnrollPhase(new CanonicalizerPhase(), new DefaultLoopPolicies()).apply(graph, context);
        assertTrue(graph.getNodes().filter(LoopBeginNode.class).count() == loopCount);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) LoopFullUnrollPhase(org.graalvm.compiler.loop.phases.LoopFullUnrollPhase) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) DefaultLoopPolicies(org.graalvm.compiler.loop.DefaultLoopPolicies) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 3 with DebugDumpScope

use of org.graalvm.compiler.debug.DebugDumpScope in project graal by oracle.

the class ImplicitNullCheckTest method test.

@SuppressWarnings("try")
private void test(final String snippet) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("FloatingReadTest", new DebugDumpScope(snippet))) {
        StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES, debug);
        PhaseContext context = new PhaseContext(getProviders());
        new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        new FloatingReadPhase().apply(graph);
        MidTierContext midTierContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
        new GuardLoweringPhase().apply(graph, midTierContext);
        Assert.assertEquals(0, graph.getNodes(DeoptimizeNode.TYPE).count());
        Assert.assertTrue(graph.getNodes().filter(ReadNode.class).first().canNullCheck());
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) DebugContext(org.graalvm.compiler.debug.DebugContext) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase)

Example 4 with DebugDumpScope

use of org.graalvm.compiler.debug.DebugDumpScope in project graal by oracle.

the class ReadAfterCheckCastTest method test.

@SuppressWarnings("try")
private void test(final String snippet) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("ReadAfterCheckCastTest", new DebugDumpScope(snippet))) {
        // check shape of graph, with lots of assumptions. will probably fail if graph
        // structure changes significantly
        StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
        PhaseContext context = new PhaseContext(getProviders());
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        new FloatingReadPhase().apply(graph);
        canonicalizer.apply(graph, context);
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After lowering");
        for (FloatingReadNode node : graph.getNodes(ParameterNode.TYPE).first().usages().filter(FloatingReadNode.class)) {
            // Checking that the parameter a is not directly used for the access to field
            // x10 (because x10 must be guarded by the checkcast).
            Assert.assertTrue(node.getLocationIdentity().isImmutable());
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase)

Example 5 with DebugDumpScope

use of org.graalvm.compiler.debug.DebugDumpScope in project graal by oracle.

the class NativeImageGenerator method registerReplacements.

@SuppressWarnings("try")
public static void registerReplacements(DebugContext debug, FeatureHandler featureHandler, RuntimeConfiguration runtimeConfig, Providers providers, SnippetReflectionProvider snippetReflection, boolean hosted) {
    OptionValues options = hosted ? HostedOptionValues.singleton() : RuntimeOptionValues.singleton();
    Providers runtimeCallProviders = runtimeConfig != null ? runtimeConfig.getBackendForNormalMethod().getProviders() : providers;
    SubstrateForeignCallsProvider foreignCallsProvider = (SubstrateForeignCallsProvider) providers.getForeignCalls();
    for (SubstrateForeignCallDescriptor descriptor : SnippetRuntime.getRuntimeCalls()) {
        foreignCallsProvider.getForeignCalls().put(descriptor, new SubstrateForeignCallLinkage(runtimeCallProviders, descriptor));
    }
    featureHandler.forEachGraalFeature(feature -> feature.registerForeignCalls(runtimeConfig, runtimeCallProviders, snippetReflection, foreignCallsProvider.getForeignCalls(), hosted));
    try (DebugContext.Scope s = debug.scope("RegisterLowerings", new DebugDumpScope("RegisterLowerings"))) {
        SubstrateLoweringProvider lowerer = (SubstrateLoweringProvider) providers.getLowerer();
        Map<Class<? extends Node>, NodeLoweringProvider<?>> lowerings = lowerer.getLowerings();
        Iterable<DebugHandlersFactory> factories = runtimeConfig != null ? runtimeConfig.getDebugHandlersFactories() : Collections.singletonList(new GraalDebugHandlersFactory(snippetReflection));
        lowerer.setConfiguration(runtimeConfig, options, factories, providers, snippetReflection);
        NonSnippetLowerings.registerLowerings(runtimeConfig, options, factories, providers, snippetReflection, lowerings);
        ArithmeticSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        MonitorSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        TypeSnippets.registerLowerings(runtimeConfig, options, factories, providers, snippetReflection, lowerings);
        ExceptionSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        if (hosted) {
            AssertSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
            DeoptHostedSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        } else {
            DeoptRuntimeSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        }
        if (NativeImageOptions.DeoptimizeAll.getValue()) {
            DeoptTestSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        }
        featureHandler.forEachGraalFeature(feature -> feature.registerLowerings(runtimeConfig, options, factories, providers, snippetReflection, lowerings, hosted));
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    SubstrateReplacements replacements = (SubstrateReplacements) providers.getReplacements();
    assert checkInvocationPluginMethods(replacements);
    replacements.encodeSnippets();
}
Also used : SubstrateForeignCallDescriptor(com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor) HostedOptionValues(com.oracle.svm.core.option.HostedOptionValues) RuntimeOptionValues(com.oracle.svm.core.option.RuntimeOptionValues) OptionValues(org.graalvm.compiler.options.OptionValues) SubstrateLoweringProvider(com.oracle.svm.core.graal.meta.SubstrateLoweringProvider) DebugHandlersFactory(org.graalvm.compiler.debug.DebugHandlersFactory) GraalDebugHandlersFactory(org.graalvm.compiler.printer.GraalDebugHandlersFactory) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) Node(org.graalvm.compiler.graph.Node) SubstrateForeignCallsProvider(com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider) SubstrateForeignCallLinkage(com.oracle.svm.core.graal.meta.SubstrateForeignCallLinkage) DebugContext(org.graalvm.compiler.debug.DebugContext) Providers(org.graalvm.compiler.phases.util.Providers) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) GraalDebugHandlersFactory(org.graalvm.compiler.printer.GraalDebugHandlersFactory) SubstrateReplacements(com.oracle.svm.core.graal.meta.SubstrateReplacements) NodeLoweringProvider(com.oracle.svm.core.graal.snippets.NodeLoweringProvider)

Aggregations

DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)18 DebugContext (org.graalvm.compiler.debug.DebugContext)17 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)16 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)10 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)6 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)6 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)5 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)4 CompilationResult (org.graalvm.compiler.code.CompilationResult)3 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)3 Node (org.graalvm.compiler.graph.Node)3 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)3 JavaMethod (jdk.vm.ci.meta.JavaMethod)2 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)2 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)2 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 GuardLoweringPhase (org.graalvm.compiler.phases.common.GuardLoweringPhase)2 MidTierContext (org.graalvm.compiler.phases.tiers.MidTierContext)2