Search in sources :

Example 61 with Node

use of org.graalvm.compiler.graph.Node in project graal by oracle.

the class CFGPrinter method printNodes.

private void printNodes(Block block) {
    printedNodes = new NodeBitMap(cfg.graph);
    begin("IR");
    out.println("HIR");
    out.disableIndentation();
    if (block.getBeginNode() instanceof AbstractMergeNode) {
        // Currently phi functions are not in the schedule, so print them separately here.
        for (ValueNode phi : ((AbstractMergeNode) block.getBeginNode()).phis()) {
            printNode(phi, false);
        }
    }
    Node cur = block.getBeginNode();
    while (true) {
        printNode(cur, false);
        if (cur == block.getEndNode()) {
            UnmodifiableMapCursor<Node, Block> cursor = latestScheduling.getEntries();
            while (cursor.advance()) {
                if (cursor.getValue() == block && !inFixedSchedule(cursor.getKey()) && !printedNodes.isMarked(cursor.getKey())) {
                    printNode(cursor.getKey(), true);
                }
            }
            break;
        }
        assert cur.successors().count() == 1;
        cur = cur.successors().first();
    }
    out.enableIndentation();
    end("IR");
    printedNodes = null;
}
Also used : NodeBitMap(org.graalvm.compiler.graph.NodeBitMap) 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) ValueNode(org.graalvm.compiler.nodes.ValueNode) Block(org.graalvm.compiler.nodes.cfg.Block) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode)

Example 62 with Node

use of org.graalvm.compiler.graph.Node in project graal by oracle.

the class CFGPrinter method printScheduledBlock.

private void printScheduledBlock(Block block, List<Node> nodesFor) {
    printBlockProlog(block);
    begin("IR");
    out.println("HIR");
    out.disableIndentation();
    if (block.getBeginNode() instanceof AbstractMergeNode) {
        // Currently phi functions are not in the schedule, so print them separately here.
        for (ValueNode phi : ((AbstractMergeNode) block.getBeginNode()).phis()) {
            printNode(phi, false);
        }
    }
    for (Node n : nodesFor) {
        printNode(n, false);
    }
    out.enableIndentation();
    end("IR");
    printBlockEpilog(block);
}
Also used : 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) ValueNode(org.graalvm.compiler.nodes.ValueNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode)

Example 63 with Node

use of org.graalvm.compiler.graph.Node in project graal by oracle.

the class CanonicalStringGraphPrinter method writeCanonicalGraphString.

protected static void writeCanonicalGraphString(StructuredGraph graph, boolean excludeVirtual, boolean checkConstants, PrintWriter writer) {
    StructuredGraph.ScheduleResult scheduleResult = GraphPrinter.getScheduleOrNull(graph);
    if (scheduleResult == null) {
        return;
    }
    try {
        NodeMap<Integer> canonicalId = graph.createNodeMap();
        int nextId = 0;
        List<String> constantsLines = null;
        if (checkConstants) {
            constantsLines = new ArrayList<>();
        }
        for (Block block : scheduleResult.getCFG().getBlocks()) {
            writer.print("Block ");
            writer.print(block);
            writer.print(" ");
            if (block == scheduleResult.getCFG().getStartBlock()) {
                writer.print("* ");
            }
            writer.print("-> ");
            for (Block successor : block.getSuccessors()) {
                writer.print(successor);
                writer.print(" ");
            }
            writer.println();
            for (Node node : scheduleResult.getBlockToNodesMap().get(block)) {
                if (node instanceof ValueNode && node.isAlive()) {
                    if (!excludeVirtual || !(node instanceof VirtualObjectNode || node instanceof ProxyNode || node instanceof FullInfopointNode)) {
                        if (node instanceof ConstantNode) {
                            if (constantsLines != null) {
                                String name = node.toString(Verbosity.Name);
                                String str = name + (excludeVirtual ? "" : "    (" + filteredUsageCount(node) + ")");
                                constantsLines.add(str);
                            }
                        } else {
                            int id;
                            if (canonicalId.get(node) != null) {
                                id = canonicalId.get(node);
                            } else {
                                id = nextId++;
                                canonicalId.set(node, id);
                            }
                            String name = node.getClass().getSimpleName();
                            writer.print("  ");
                            writer.print(id);
                            writer.print("|");
                            writer.print(name);
                            if (!excludeVirtual) {
                                writer.print("    (");
                                writer.print(filteredUsageCount(node));
                                writer.print(")");
                            }
                            writer.println();
                        }
                    }
                }
            }
        }
        if (constantsLines != null) {
            writer.print(constantsLines.size());
            writer.println(" constants:");
            Collections.sort(constantsLines);
            for (String s : constantsLines) {
                writer.println(s);
            }
        }
    } catch (Throwable t) {
        writer.println();
        t.printStackTrace(writer);
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) 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) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) Block(org.graalvm.compiler.nodes.cfg.Block)

Example 64 with Node

use of org.graalvm.compiler.graph.Node in project graal by oracle.

the class GraphOrder method visitForward.

private static void visitForward(ArrayList<Node> nodes, NodeBitMap visited, Node node, boolean floatingOnly) {
    try {
        assert node == null || node.isAlive() : node + " not alive";
        if (node != null && !visited.isMarked(node)) {
            if (floatingOnly && node instanceof FixedNode) {
                throw new GraalError("unexpected reference to fixed node: %s (this indicates an unexpected cycle)", node);
            }
            visited.mark(node);
            FrameState stateAfter = null;
            if (node instanceof StateSplit) {
                stateAfter = ((StateSplit) node).stateAfter();
            }
            for (Node input : node.inputs()) {
                if (input != stateAfter) {
                    visitForward(nodes, visited, input, true);
                }
            }
            if (node instanceof EndNode) {
                EndNode end = (EndNode) node;
                for (PhiNode phi : end.merge().phis()) {
                    visitForward(nodes, visited, phi.valueAt(end), true);
                }
            }
            nodes.add(node);
            if (node instanceof AbstractMergeNode) {
                for (PhiNode phi : ((AbstractMergeNode) node).phis()) {
                    visited.mark(phi);
                    nodes.add(phi);
                }
            }
            if (stateAfter != null) {
                visitForward(nodes, visited, stateAfter, true);
            }
        }
    } catch (GraalError e) {
        throw GraalGraphError.transformAndAddContext(e, node);
    }
}
Also used : GraalError(org.graalvm.compiler.debug.GraalError) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) EndNode(org.graalvm.compiler.nodes.EndNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) FrameState(org.graalvm.compiler.nodes.FrameState) StateSplit(org.graalvm.compiler.nodes.StateSplit)

Example 65 with Node

use of org.graalvm.compiler.graph.Node in project graal by oracle.

the class GraphOrder method createOrder.

private static List<Node> createOrder(StructuredGraph graph) {
    final ArrayList<Node> nodes = new ArrayList<>();
    final NodeBitMap visited = graph.createNodeBitMap();
    new StatelessPostOrderNodeIterator(graph.start()) {

        @Override
        protected void node(FixedNode node) {
            visitForward(nodes, visited, node, false);
        }
    }.apply();
    return nodes;
}
Also used : NodeBitMap(org.graalvm.compiler.graph.NodeBitMap) StatelessPostOrderNodeIterator(org.graalvm.compiler.phases.graph.StatelessPostOrderNodeIterator) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) ArrayList(java.util.ArrayList) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Aggregations

Node (org.graalvm.compiler.graph.Node)189 ValueNode (org.graalvm.compiler.nodes.ValueNode)105 FixedNode (org.graalvm.compiler.nodes.FixedNode)91 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)75 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)74 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)73 PhiNode (org.graalvm.compiler.nodes.PhiNode)64 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)61 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)53 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)47 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)43 FloatingNode (org.graalvm.compiler.nodes.calc.FloatingNode)41 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)38 EndNode (org.graalvm.compiler.nodes.EndNode)37 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)37 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)37 MergeNode (org.graalvm.compiler.nodes.MergeNode)35 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)35 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)32 LogicNode (org.graalvm.compiler.nodes.LogicNode)31