Search in sources :

Example 36 with Invoke

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);
        }
    }
}
Also used : ResolveConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) InitializeKlassNode(org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 37 with Invoke

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);
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) VerificationError(org.graalvm.compiler.graph.VerificationError) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 38 with Invoke

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");
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ControlFlowGraph(org.graalvm.compiler.nodes.cfg.ControlFlowGraph) Block(org.graalvm.compiler.nodes.cfg.Block) DebugContext(org.graalvm.compiler.debug.DebugContext) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 39 with Invoke

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);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HashMap(java.util.HashMap) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 40 with Invoke

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);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HashMap(java.util.HashMap) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) Invoke(org.graalvm.compiler.nodes.Invoke)

Aggregations

Invoke (org.graalvm.compiler.nodes.Invoke)49 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)19 Node (org.graalvm.compiler.graph.Node)17 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)17 ValueNode (org.graalvm.compiler.nodes.ValueNode)16 FixedNode (org.graalvm.compiler.nodes.FixedNode)13 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)12 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)10 FrameState (org.graalvm.compiler.nodes.FrameState)10 DebugContext (org.graalvm.compiler.debug.DebugContext)9 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)9 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)9 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)8 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)7 EndNode (org.graalvm.compiler.nodes.EndNode)7 GraalError (org.graalvm.compiler.debug.GraalError)6 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)6 ArrayList (java.util.ArrayList)5 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)5 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)5