use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class ConditionalEliminationTest10 method test.
private void test(String snippet, int guardCount) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
CoreProviders context = getProviders();
new LoweringPhase(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new ConditionalEliminationPhase(true).apply(graph, context);
Assert.assertEquals(guardCount, graph.getNodes().filter(GuardNode.class).count());
}
use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class PEGraphDecoderTest method test.
@SuppressWarnings("try")
private StructuredGraph test(String methodName, EconomicMap<ResolvedJavaMethod, EncodedGraph> graphCache) {
ResolvedJavaMethod testMethod = getResolvedJavaMethod(methodName);
StructuredGraph targetGraph = null;
DebugContext debug = getDebugContext();
try (DebugContext.Scope scope = debug.scope("GraphPETest", testMethod)) {
GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withEagerResolving(true).withUnresolvedIsError(true);
graphBuilderConfig = editGraphBuilderConfiguration(graphBuilderConfig);
registerPlugins(graphBuilderConfig.getPlugins().getInvocationPlugins());
targetGraph = new StructuredGraph.Builder(debug.getOptions(), debug, AllowAssumptions.YES).method(testMethod).build();
CachingPEGraphDecoder decoder = new CachingPEGraphDecoder(getTarget().arch, targetGraph, getProviders(), graphBuilderConfig, OptimisticOptimizations.NONE, AllowAssumptions.YES, null, null, new InlineInvokePlugin[] { new InlineAll() }, null, null, null, null, null, graphCache, false);
decoder.decode(testMethod, false, false);
debug.dump(DebugContext.BASIC_LEVEL, targetGraph, "Target Graph");
targetGraph.verify();
CoreProviders context = getProviders();
createCanonicalizerPhase().apply(targetGraph, context);
targetGraph.verify();
return targetGraph;
} catch (Throwable ex) {
if (targetGraph != null) {
debug.dump(DebugContext.BASIC_LEVEL, targetGraph, ex.toString());
}
throw debug.handle(ex);
}
}
use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class UnsafeReadEliminationTest method testEarlyReadElimination.
public void testEarlyReadElimination(StructuredGraph graph, int reads, int writes) {
CoreProviders context = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
canonicalizer.apply(graph, context);
new ReadEliminationPhase(canonicalizer).apply(graph, context);
Assert.assertEquals(3, graph.getNodes().filter(UnsafeAccessNode.class).count());
// after lowering the same applies for reads and writes
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
new ReadEliminationPhase(canonicalizer).apply(graph, context);
Assert.assertEquals(reads, graph.getNodes().filter(ReadNode.class).count());
Assert.assertEquals(writes, graph.getNodes().filter(WriteNode.class).count());
}
use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class SchedulingTest2 method testValueProxyInputs.
@Test
public void testValueProxyInputs() {
StructuredGraph graph = parseEager("testSnippet", AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
ReturnNode returnNode = graph.getNodes(ReturnNode.TYPE).first();
BeginNode beginNode = graph.add(new BeginNode());
returnNode.replaceAtPredecessor(beginNode);
beginNode.setNext(returnNode);
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.EARLIEST_WITH_GUARD_ORDER);
schedulePhase.apply(graph, getDefaultHighTierContext());
ScheduleResult schedule = graph.getLastSchedule();
BlockMap<List<Node>> blockToNodesMap = schedule.getBlockToNodesMap();
NodeMap<Block> nodeToBlock = schedule.getNodeToBlockMap();
assertDeepEquals(2, schedule.getCFG().getBlocks().length);
for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
if (node instanceof AddNode) {
assertTrue(node.toString() + " expected: " + nodeToBlock.get(beginNode) + " but was: " + nodeToBlock.get(node), nodeToBlock.get(node) != nodeToBlock.get(beginNode));
}
}
for (FrameState fs : graph.getNodes(FrameState.TYPE)) {
Block block = nodeToBlock.get(fs);
assertTrue(fs.toString(), block == schedule.getCFG().getStartBlock());
for (Node usage : fs.usages()) {
if (usage instanceof StateSplit && ((StateSplit) usage).stateAfter() == fs) {
assertTrue(usage.toString(), nodeToBlock.get(usage) == block);
if (usage != block.getBeginNode()) {
List<Node> map = blockToNodesMap.get(block);
assertTrue(map.indexOf(fs) + " < " + map.indexOf(usage), map.indexOf(fs) < map.indexOf(usage));
}
}
}
}
CoreProviders context = getProviders();
new LoweringPhase(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new LoweringPhase(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, context);
MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
new GuardLoweringPhase().apply(graph, midContext);
FrameStateAssignmentPhase phase = new FrameStateAssignmentPhase();
phase.apply(graph);
schedulePhase.apply(graph, midContext);
schedule = graph.getLastSchedule();
blockToNodesMap = schedule.getBlockToNodesMap();
nodeToBlock = schedule.getNodeToBlockMap();
for (FrameState fs : graph.getNodes(FrameState.TYPE)) {
Block block = nodeToBlock.get(fs);
assertTrue(fs.toString(), block == schedule.getCFG().getStartBlock());
for (Node usage : fs.usages()) {
if ((usage instanceof StateSplit && ((StateSplit) usage).stateAfter() == fs) || (usage instanceof DeoptDuring && ((DeoptDuring) usage).stateDuring() == fs)) {
assertTrue(usage.toString(), nodeToBlock.get(usage) == block);
if (usage != block.getBeginNode()) {
List<Node> map = blockToNodesMap.get(block);
assertTrue(map.indexOf(fs) + " < " + map.indexOf(usage), map.indexOf(fs) < map.indexOf(usage));
}
}
}
}
}
use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class PushNodesThroughPiTest method compileTestSnippet.
private StructuredGraph compileTestSnippet(final String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
CoreProviders context = getProviders();
CanonicalizerPhase canonicalizer = this.createCanonicalizerPhase();
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
canonicalizer.apply(graph, context);
return graph;
}
Aggregations