Search in sources :

Example 26 with DebugContext

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

the class AllocatorTest method testAllocation.

@SuppressWarnings("try")
protected void testAllocation(String snippet, final int expectedRegisters, final int expectedRegRegMoves, final int expectedSpillMoves) {
    final StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope s = debug.scope("AllocatorTest", graph, graph.method(), getCodeCache())) {
        final RegisterStats stats = new RegisterStats(getLIRGenerationResult(graph).getLIR());
        try (DebugContext.Scope s2 = debug.scope("Assertions", stats.lir)) {
            Assert.assertEquals("register count", expectedRegisters, stats.registers.size());
            Assert.assertEquals("reg-reg moves", expectedRegRegMoves, stats.regRegMoves);
            Assert.assertEquals("spill moves", expectedSpillMoves, stats.spillMoves);
        } catch (Throwable e) {
            throw debug.handle(e);
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 27 with DebugContext

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

the class StraighteningTest method test.

private void test(final String snippet) {
    // No debug scope to reduce console noise for @Test(expected = ...) tests
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
    assertEquals(referenceGraph, graph);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 28 with DebugContext

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

the class TypeSystemTest method test.

private void test(String snippet, String referenceSnippet) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    /*
         * When using FlowSensitiveReductionPhase instead of ConditionalEliminationPhase,
         * tail-duplication gets activated thus resulting in a graph with more nodes than the
         * reference graph.
         */
    new ConditionalEliminationPhase(false).apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    // a second canonicalizer is needed to process nested MaterializeNodes
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
    new ConditionalEliminationPhase(false).apply(referenceGraph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
    assertEquals(referenceGraph, graph);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 29 with DebugContext

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

the class TypeSystemTest method testHelper.

private <T extends Node> void testHelper(String snippet, Class<T> clazz) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph " + snippet);
    Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes().filter(clazz).iterator().hasNext());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 30 with DebugContext

use of org.graalvm.compiler.debug.DebugContext 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)

Aggregations

DebugContext (org.graalvm.compiler.debug.DebugContext)234 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)87 OptionValues (org.graalvm.compiler.options.OptionValues)50 Indent (org.graalvm.compiler.debug.Indent)37 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)31 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)29 Test (org.junit.Test)27 Node (org.graalvm.compiler.graph.Node)24 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)24 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)22 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)20 Scope (org.graalvm.compiler.debug.DebugContext.Scope)18 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)18 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)17 ValueNode (org.graalvm.compiler.nodes.ValueNode)16 FixedNode (org.graalvm.compiler.nodes.FixedNode)14 CompilationResult (org.graalvm.compiler.code.CompilationResult)13 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)13 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)12 LIR (org.graalvm.compiler.lir.LIR)11