Search in sources :

Example 46 with FixedWithNextNode

use of org.graalvm.compiler.nodes.FixedWithNextNode 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 47 with FixedWithNextNode

use of org.graalvm.compiler.nodes.FixedWithNextNode 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 48 with FixedWithNextNode

use of org.graalvm.compiler.nodes.FixedWithNextNode in project graal by oracle.

the class ConvertDeoptimizeToGuardPhase method propagateFixed.

@SuppressWarnings("try")
private void propagateFixed(FixedNode from, StaticDeoptimizingNode deopt, LoweringProvider loweringProvider) {
    Node current = from;
    while (current != null) {
        if (GraalOptions.GuardPriorities.getValue(from.getOptions()) && current instanceof FixedGuardNode) {
            FixedGuardNode otherGuard = (FixedGuardNode) current;
            if (otherGuard.computePriority().isHigherPriorityThan(deopt.computePriority())) {
                moveAsDeoptAfter(otherGuard, deopt);
                return;
            }
        } else if (current instanceof AbstractBeginNode) {
            if (current instanceof AbstractMergeNode) {
                AbstractMergeNode mergeNode = (AbstractMergeNode) current;
                FixedNode next = mergeNode.next();
                while (mergeNode.isAlive()) {
                    AbstractEndNode end = mergeNode.forwardEnds().first();
                    propagateFixed(end, deopt, loweringProvider);
                }
                assert next.isAlive();
                propagateFixed(next, deopt, loweringProvider);
                return;
            } else if (current.predecessor() instanceof IfNode) {
                IfNode ifNode = (IfNode) current.predecessor();
                // Prioritize the source position of the IfNode
                try (DebugCloseable closable = ifNode.withNodeSourcePosition()) {
                    StructuredGraph graph = ifNode.graph();
                    LogicNode conditionNode = ifNode.condition();
                    boolean negateGuardCondition = current == ifNode.trueSuccessor();
                    FixedGuardNode guard = graph.add(new FixedGuardNode(conditionNode, deopt.getReason(), deopt.getAction(), deopt.getSpeculation(), negateGuardCondition));
                    FixedWithNextNode pred = (FixedWithNextNode) ifNode.predecessor();
                    AbstractBeginNode survivingSuccessor;
                    if (negateGuardCondition) {
                        survivingSuccessor = ifNode.falseSuccessor();
                    } else {
                        survivingSuccessor = ifNode.trueSuccessor();
                    }
                    graph.removeSplitPropagate(ifNode, survivingSuccessor);
                    Node newGuard = guard;
                    if (survivingSuccessor instanceof LoopExitNode) {
                        newGuard = ProxyNode.forGuard(guard, (LoopExitNode) survivingSuccessor, graph);
                    }
                    survivingSuccessor.replaceAtUsages(InputType.Guard, newGuard);
                    graph.getDebug().log("Converting deopt on %-5s branch of %s to guard for remaining branch %s.", negateGuardCondition, ifNode, survivingSuccessor);
                    FixedNode next = pred.next();
                    pred.setNext(guard);
                    guard.setNext(next);
                    SimplifierTool simplifierTool = GraphUtil.getDefaultSimplifier(null, null, null, false, graph.getAssumptions(), graph.getOptions(), loweringProvider);
                    survivingSuccessor.simplify(simplifierTool);
                    return;
                }
            } else if (current.predecessor() == null || current.predecessor() instanceof ControlSplitNode) {
                assert current.predecessor() != null || (current instanceof StartNode && current == ((AbstractBeginNode) current).graph().start());
                moveAsDeoptAfter((AbstractBeginNode) current, deopt);
                return;
            }
        }
        current = current.predecessor();
    }
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) StartNode(org.graalvm.compiler.nodes.StartNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) GuardNode(org.graalvm.compiler.nodes.GuardNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) StartNode(org.graalvm.compiler.nodes.StartNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) StaticDeoptimizingNode(org.graalvm.compiler.nodes.StaticDeoptimizingNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IfNode(org.graalvm.compiler.nodes.IfNode) SimplifierTool(org.graalvm.compiler.graph.spi.SimplifierTool) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 49 with FixedWithNextNode

use of org.graalvm.compiler.nodes.FixedWithNextNode in project graal by oracle.

the class CFGPrinter method printNode.

private void printNode(Node node, boolean unscheduled) {
    assert !printedNodes.isMarked(node);
    printedNodes.mark(node);
    if (!(node instanceof ValuePhiNode)) {
        for (Node input : node.inputs()) {
            if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) {
                printNode(input, true);
            }
        }
    }
    if (unscheduled) {
        assert lir == null && schedule == null : "unscheduled nodes can only be present before LIR generation";
        out.print("f ").print(HOVER_START).print("u").print(HOVER_SEP).print("unscheduled").print(HOVER_END).println(COLUMN_END);
    } else if (node instanceof FixedWithNextNode) {
        out.print("f ").print(HOVER_START).print("#").print(HOVER_SEP).print("fixed with next").print(HOVER_END).println(COLUMN_END);
    } else if (node instanceof FixedNode) {
        out.print("f ").print(HOVER_START).print("*").print(HOVER_SEP).print("fixed").print(HOVER_END).println(COLUMN_END);
    } else if (node instanceof FloatingNode) {
        out.print("f ").print(HOVER_START).print("~").print(HOVER_SEP).print("floating").print(HOVER_END).println(COLUMN_END);
    }
    out.print("tid ").print(nodeToString(node)).println(COLUMN_END);
    if (nodeLirGenerator != null) {
        Value operand = nodeLirGenerator.hasOperand(node) ? nodeLirGenerator.operand(node) : null;
        if (operand != null) {
            out.print("result ").print(operand.toString()).println(COLUMN_END);
        }
    }
    if (node instanceof StateSplit) {
        StateSplit stateSplit = (StateSplit) node;
        if (stateSplit.stateAfter() != null) {
            String state = stateToString(stateSplit.stateAfter());
            out.print("st ").print(HOVER_START).print("st").print(HOVER_SEP).print(state).print(HOVER_END).println(COLUMN_END);
        }
    }
    Map<Object, Object> props = new TreeMap<>(node.getDebugProperties());
    out.print("d ").print(HOVER_START).print("d").print(HOVER_SEP);
    out.println("=== Debug Properties ===");
    for (Map.Entry<Object, Object> entry : props.entrySet()) {
        out.print(entry.getKey().toString()).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).println();
    }
    out.println("=== Inputs ===");
    printNamedNodes(node, node.inputPositions().iterator(), "", "\n", null);
    out.println("=== Succesors ===");
    printNamedNodes(node, node.successorPositions().iterator(), "", "\n", null);
    out.println("=== Usages ===");
    if (!node.hasNoUsages()) {
        for (Node usage : node.usages()) {
            out.print(nodeToString(usage)).print(" ");
        }
        out.println();
    }
    out.println("=== Predecessor ===");
    out.print(nodeToString(node.predecessor())).print(" ");
    out.print(HOVER_END).println(COLUMN_END);
    out.print("instruction ");
    out.print(HOVER_START).print(node.getNodeClass().shortName()).print(HOVER_SEP).print(node.getClass().getName()).print(HOVER_END).print(" ");
    printNamedNodes(node, node.inputPositions().iterator(), "", "", "#NDF");
    printNamedNodes(node, node.successorPositions().iterator(), "#", "", "#NDF");
    for (Map.Entry<Object, Object> entry : props.entrySet()) {
        String key = entry.getKey().toString();
        if (key.startsWith("data.") && !key.equals("data.stamp")) {
            out.print(key.substring("data.".length())).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).print(" ");
        }
    }
    out.print(COLUMN_END).print(' ').println(COLUMN_END);
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) TreeMap(java.util.TreeMap) Value(jdk.vm.ci.meta.Value) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) Map(java.util.Map) NodeMap(org.graalvm.compiler.graph.NodeMap) NodeBitMap(org.graalvm.compiler.graph.NodeBitMap) TreeMap(java.util.TreeMap) StateSplit(org.graalvm.compiler.nodes.StateSplit)

Example 50 with FixedWithNextNode

use of org.graalvm.compiler.nodes.FixedWithNextNode in project graal by oracle.

the class CanonicalStringGraphPrinter method writeCanonicalExpressionCFGString.

protected static void writeCanonicalExpressionCFGString(StructuredGraph graph, boolean checkConstants, boolean removeIdentities, PrintWriter writer) {
    ControlFlowGraph controlFlowGraph = getControlFlowGraph(graph);
    if (controlFlowGraph == null) {
        return;
    }
    try {
        for (Block block : controlFlowGraph.getBlocks()) {
            writer.print("Block ");
            writer.print(block);
            writer.print(" ");
            if (block == controlFlowGraph.getStartBlock()) {
                writer.print("* ");
            }
            writer.print("-> ");
            for (Block successor : block.getSuccessors()) {
                writer.print(successor);
                writer.print(" ");
            }
            writer.println();
            FixedNode node = block.getBeginNode();
            while (node != null) {
                writeCanonicalGraphExpressionString(node, checkConstants, removeIdentities, writer);
                writer.println();
                if (node instanceof FixedWithNextNode) {
                    node = ((FixedWithNextNode) node).next();
                } else {
                    node = null;
                }
            }
        }
    } catch (Throwable e) {
        writer.println();
        e.printStackTrace(writer);
    }
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ControlFlowGraph(org.graalvm.compiler.nodes.cfg.ControlFlowGraph) Block(org.graalvm.compiler.nodes.cfg.Block) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Aggregations

FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)57 FixedNode (org.graalvm.compiler.nodes.FixedNode)33 ValueNode (org.graalvm.compiler.nodes.ValueNode)29 Node (org.graalvm.compiler.graph.Node)26 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)22 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)21 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)20 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)13 EndNode (org.graalvm.compiler.nodes.EndNode)12 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)12 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)10 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)9 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)9 Invoke (org.graalvm.compiler.nodes.Invoke)9 LogicNode (org.graalvm.compiler.nodes.LogicNode)9 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)9 PhiNode (org.graalvm.compiler.nodes.PhiNode)9 IfNode (org.graalvm.compiler.nodes.IfNode)8 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)7 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)7