Search in sources :

Example 66 with FixedNode

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

the class ConvertDeoptimizeToGuardPhase method moveAsDeoptAfter.

private static void moveAsDeoptAfter(FixedWithNextNode node, StaticDeoptimizingNode deopt) {
    FixedNode next = node.next();
    if (next != deopt.asNode()) {
        node.setNext(node.graph().add(new DeoptimizeNode(deopt.getAction(), deopt.getReason(), deopt.getSpeculation())));
        GraphUtil.killCFG(next);
    }
}
Also used : DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Example 67 with FixedNode

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

the class LoopSafepointEliminationPhase method run.

@Override
protected void run(StructuredGraph graph, MidTierContext context) {
    LoopsData loops = new LoopsData(graph);
    if (context.getOptimisticOptimizations().useLoopLimitChecks(graph.getOptions()) && graph.getGuardsStage().allowsFloatingGuards()) {
        loops.detectedCountedLoops();
        for (LoopEx loop : loops.countedLoops()) {
            if (loop.loop().getChildren().isEmpty() && loop.counted().getStamp().getBits() <= 32) {
                boolean hasSafepoint = false;
                for (LoopEndNode loopEnd : loop.loopBegin().loopEnds()) {
                    hasSafepoint |= loopEnd.canSafepoint();
                }
                if (hasSafepoint) {
                    loop.counted().createOverFlowGuard();
                    loop.loopBegin().disableSafepoint();
                }
            }
        }
    }
    for (LoopEx loop : loops.loops()) {
        for (LoopEndNode loopEnd : loop.loopBegin().loopEnds()) {
            Block b = loops.getCFG().blockFor(loopEnd);
            blocks: while (b != loop.loop().getHeader()) {
                assert b != null;
                for (FixedNode node : b.getNodes()) {
                    if (node instanceof Invoke || (node instanceof ForeignCallNode && ((ForeignCallNode) node).isGuaranteedSafepoint())) {
                        loopEnd.disableSafepoint();
                        break blocks;
                    }
                }
                b = b.getDominator();
            }
        }
    }
    loops.deleteUnusedNodes();
}
Also used : LoopsData(org.graalvm.compiler.loop.LoopsData) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) LoopEx(org.graalvm.compiler.loop.LoopEx) Block(org.graalvm.compiler.nodes.cfg.Block) FixedNode(org.graalvm.compiler.nodes.FixedNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 68 with FixedNode

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

use of org.graalvm.compiler.nodes.FixedNode 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)

Example 70 with FixedNode

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

the class CanonicalStringGraphPrinter method writeCanonicalGraphExpressionString.

protected static void writeCanonicalGraphExpressionString(ValueNode node, boolean checkConstants, boolean removeIdentities, PrintWriter writer) {
    writer.print(node.getClass().getSimpleName());
    writer.print("(");
    Fields properties = node.getNodeClass().getData();
    for (int i = 0; i < properties.getCount(); i++) {
        String dataStr = String.valueOf(properties.get(node, i));
        if (removeIdentities) {
            dataStr = removeIdentities(dataStr);
        }
        writer.print(dataStr);
        if (i + 1 < properties.getCount() || node.inputPositions().iterator().hasNext()) {
            writer.print(", ");
        }
    }
    Iterator<Position> iterator = node.inputPositions().iterator();
    while (iterator.hasNext()) {
        Position position = iterator.next();
        Node input = position.get(node);
        if (checkConstants && input instanceof ConstantNode) {
            ConstantNode constantNode = (ConstantNode) input;
            String valueString = constantNode.getValue().toValueString();
            if (removeIdentities) {
                valueString = removeIdentities(valueString);
            }
            writer.print(valueString);
        } else if (input instanceof ValueNode && !(input instanceof PhiNode) && !(input instanceof FixedNode)) {
            writeCanonicalGraphExpressionString((ValueNode) input, checkConstants, removeIdentities, writer);
        } else if (input == null) {
            writer.print("null");
        } else {
            writer.print(input.getClass().getSimpleName());
        }
        if (iterator.hasNext()) {
            writer.print(", ");
        }
    }
    writer.print(")");
}
Also used : Fields(org.graalvm.compiler.core.common.Fields) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) Position(org.graalvm.compiler.graph.Position) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Aggregations

FixedNode (org.graalvm.compiler.nodes.FixedNode)87 Node (org.graalvm.compiler.graph.Node)41 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)41 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)39 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)39 ValueNode (org.graalvm.compiler.nodes.ValueNode)34 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)33 EndNode (org.graalvm.compiler.nodes.EndNode)27 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)25 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)23 PhiNode (org.graalvm.compiler.nodes.PhiNode)22 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)21 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)21 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)20 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)17 MergeNode (org.graalvm.compiler.nodes.MergeNode)17 StartNode (org.graalvm.compiler.nodes.StartNode)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)16 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)13 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)13