use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class FloatingReadTest 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);
CoreProviders context = getProviders();
new LoweringPhase(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new FloatingReadPhase().apply(graph);
ReturnNode returnNode = null;
MonitorExit monitorexit = null;
for (Node n : graph.getNodes()) {
if (n instanceof ReturnNode) {
assert returnNode == null;
returnNode = (ReturnNode) n;
} else if (n instanceof MonitorExit) {
monitorexit = (MonitorExit) n;
}
}
debug.dump(DebugContext.BASIC_LEVEL, graph, "After lowering");
Assert.assertNotNull(returnNode);
Assert.assertNotNull(monitorexit);
Assert.assertTrue(returnNode.result() instanceof FloatingReadNode);
FloatingReadNode read = (FloatingReadNode) returnNode.result();
assertOrderedAfterSchedule(graph, read, (Node) monitorexit);
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class IfCanonicalizerTest method testCombinedIf.
private void testCombinedIf(String snippet, int count) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
CoreProviders context = getProviders();
new LoweringPhase(createCanonicalizerPhase(), 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(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
createCanonicalizerPhase().apply(graph, context);
assertDeepEquals(count, graph.getNodes().filter(IfNode.class).count());
}
use of org.graalvm.compiler.nodes.spi.CoreProviders 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);
CoreProviders context = getProviders();
new LoweringPhase(createCanonicalizerPhase(), 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.spi.CoreProviders in project graal by oracle.
the class ScalarTypeSystemTest method test.
private void test(final String snippet, final String referenceSnippet) {
// No debug scope to reduce console noise for @Test(expected = ...) tests
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
graph.getDebug().dump(DebugContext.BASIC_LEVEL, graph, "Graph");
CoreProviders context = getProviders();
createCanonicalizerPhase().apply(graph, context);
StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
assertEquals(referenceGraph, graph);
}
use of org.graalvm.compiler.nodes.spi.CoreProviders 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);
CoreProviders context = getProviders();
CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
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