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);
}
}
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);
}
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);
}
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());
}
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);
}
}
Aggregations