use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class EliminateRedundantInitializationPhase method removeInitsAtStaticCalls.
/**
* Find each {@link Invoke} that has a corresponding {@link InitializeKlassNode}. These
* {@link InitializeKlassNode} are redundant and are removed.
*/
private static void removeInitsAtStaticCalls(StructuredGraph graph) {
for (Invoke invoke : graph.getInvokes()) {
if (invoke.classInit() != null) {
Node classInit = invoke.classInit();
classInit.replaceAtUsages(null);
graph.removeFixed((FixedWithNextNode) classInit);
}
}
}
use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class EnsureVirtualizedNode method ensureVirtualFailure.
public static void ensureVirtualFailure(Node location, Stamp stamp) {
String additionalReason = "";
if (location instanceof FixedWithNextNode && !(location instanceof EnsureVirtualizedNode)) {
FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) location;
FixedNode next = fixedWithNextNode.next();
if (next instanceof StoreFieldNode) {
additionalReason = " (must not store virtual object into a field)";
} else if (next instanceof Invoke) {
additionalReason = " (must not pass virtual object into an invoke that cannot be inlined)";
} else {
additionalReason = " (must not let virtual object escape at node " + next + ")";
}
}
Throwable exception = new VerificationError("Object of type %s should not be materialized%s:", StampTool.typeOrNull(stamp).getName(), additionalReason);
Node pos;
if (location instanceof FixedWithNextNode) {
pos = ((FixedWithNextNode) location).next();
} else if (location instanceof AbstractEndNode) {
pos = ((AbstractEndNode) location).merge();
} else {
pos = location;
}
throw GraphUtil.approxSourceException(pos, exception);
}
use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class NestedLoopTest method test.
private void test(String snippet, int rootExits, int nestedExits, int innerExits) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
Assert.assertEquals(3, cfg.getLoops().size());
Loop<Block> rootLoop = cfg.getLoops().get(0);
Loop<Block> nestedLoop = cfg.getLoops().get(1);
Loop<Block> innerMostLoop = cfg.getLoops().get(2);
Invoke a = getInvoke("a", graph);
Invoke b = getInvoke("b", graph);
Invoke c = getInvoke("c", graph);
Invoke d = getInvoke("d", graph);
Assert.assertTrue(containsDirect(rootLoop, a, cfg));
Assert.assertTrue(containsDirect(nestedLoop, b, cfg));
Assert.assertTrue(containsDirect(innerMostLoop, c, cfg));
Assert.assertTrue(containsDirect(innerMostLoop, d, cfg));
Assert.assertTrue(contains(rootLoop, d, cfg));
Assert.assertTrue(contains(nestedLoop, d, cfg));
Assert.assertEquals(rootExits, rootLoop.getExits().size());
Assert.assertEquals(nestedExits, nestedLoop.getExits().size());
Assert.assertEquals(innerExits, innerMostLoop.getExits().size());
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
}
use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class InvokeExceptionTest method test.
private void test(String snippet) {
StructuredGraph graph = parseProfiled(snippet, AllowAssumptions.NO);
Map<Invoke, Double> hints = new HashMap<>();
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
}
use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class InvokeHintsTest method test.
private void test(String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
Map<Invoke, Double> hints = new HashMap<>();
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.NO);
assertEquals(referenceGraph, graph);
}
Aggregations