use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class NodePropertiesTest method testGraphCost.
@Test
public void testGraphCost() {
StructuredGraph g1 = parseForCompile(getResolvedJavaMethod("test1Snippet"));
StructuredGraph g2 = parseForCompile(getResolvedJavaMethod("test2Snippet"));
HighTierContext htc = getDefaultHighTierContext();
new CanonicalizerPhase().apply(g1, htc);
new CanonicalizerPhase().apply(g2, htc);
GraphCostPhase gc1 = new GraphCostPhase();
GraphCostPhase gc2 = new GraphCostPhase();
gc1.apply(g1, htc);
gc2.apply(g2, htc);
g1.getDebug().log("Test Graph Cost --> 1.Graph cost:%f vs. 2.Graph cost:%f\n", gc1.finalCycles, gc2.finalCycles);
Assert.assertTrue(gc2.finalCycles > gc1.finalCycles);
Assert.assertTrue(gc2.finalSize == gc1.finalSize);
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class IfCanonicalizerTest method testCombinedIf.
private void testCombinedIf(String snippet, int count) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new FloatingReadPhase().apply(graph);
MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
new GuardLoweringPhase().apply(graph, midContext);
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
new CanonicalizerPhase().apply(graph, context);
assertDeepEquals(count, graph.getNodes().filter(IfNode.class).count());
}
use of org.graalvm.compiler.nodes.StructuredGraph 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);
}
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class InfopointReasonTest method lineInfopoints.
@Test
public void lineInfopoints() {
final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
final StructuredGraph graph = parse(builder(method, AllowAssumptions.ifTrue(OptAssumptions.getValue(getInitialOptions()))), getDebugGraphBuilderSuite());
int graphLineSPs = 0;
for (FullInfopointNode ipn : graph.getNodes().filter(FullInfopointNode.class)) {
if (ipn.getReason() == InfopointReason.BYTECODE_POSITION) {
++graphLineSPs;
}
}
assertTrue(graphLineSPs > 0);
PhaseSuite<HighTierContext> graphBuilderSuite = getCustomGraphBuilderSuite(GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withFullInfopoints(true));
final CompilationResult cr = compileGraph(graph, graph.method(), getProviders(), getBackend(), graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(), createSuites(graph.getOptions()), createLIRSuites(graph.getOptions()), new CompilationResult(graph.compilationId()), CompilationResultBuilderFactory.Default);
int lineSPs = 0;
for (Infopoint sp : cr.getInfopoints()) {
assertNotNull(sp.reason);
if (sp.reason == InfopointReason.BYTECODE_POSITION) {
++lineSPs;
}
}
assertTrue(lineSPs > 0);
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class IntegerEqualsCanonicalizerTest method test.
private void test(String snippet, String referenceSnippet) {
StructuredGraph graph = getCanonicalizedGraph(snippet);
StructuredGraph referenceGraph = getCanonicalizedGraph(referenceSnippet);
assertEquals(referenceGraph, graph);
}
Aggregations