use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class NodePropertiesTest method testDifferentLoopsInnerOuter.
@Test
public void testDifferentLoopsInnerOuter() {
HighTierContext htc = getDefaultHighTierContext();
StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("testLoop04"));
StructuredGraph g2 = parseForCompile(getResolvedJavaMethod("testLoop05"));
prepareGraphForLoopFrequencies(g1, htc);
prepareGraphForLoopFrequencies(g2, htc);
assertFrequency(g1, ITERATIONS_LOOP_1 * ITERATIONS_LOOP_2);
GraphCostPhase gc1 = new GraphCostPhase();
GraphCostPhase gc2 = new GraphCostPhase();
gc1.apply(g1, htc);
gc2.apply(g2, htc);
g1.getDebug().log("Test testDifferentLoopsInnerOuter --> 1.Graph cycles:%f size:%f vs. 2.Graph cycles:%f size:%f\n", gc1.finalCycles, gc1.finalSize, gc2.finalCycles, gc2.finalSize);
Assert.assertTrue(gc2.finalSize > gc1.finalSize);
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class PhiCreationTests method test3.
@Test
public void test3() {
StructuredGraph graph = parseEager("test3Snippet", AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class PhiCreationTests method test2.
@Test
public void test2() {
StructuredGraph graph = parseEager("test2Snippet", AllowAssumptions.YES);
Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class PushThroughIfTest method test.
private void test(String snippet, String reference) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
for (FrameState fs : graph.getNodes(FrameState.TYPE).snapshot()) {
fs.replaceAtUsages(null);
GraphUtil.killWithUnusedFloatingInputs(fs);
}
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
StructuredGraph referenceGraph = parseEager(reference, AllowAssumptions.YES);
for (FrameState fs : referenceGraph.getNodes(FrameState.TYPE).snapshot()) {
fs.replaceAtUsages(null);
GraphUtil.killWithUnusedFloatingInputs(fs);
}
new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
assertEquals(referenceGraph, graph);
}
use of org.graalvm.compiler.nodes.StructuredGraph 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);
}
}
Aggregations