Search in sources :

Example 16 with ProxyNode

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

the class LoopFragmentInside method nodes.

@Override
public NodeBitMap nodes() {
    if (nodes == null) {
        LoopFragmentWhole whole = loop().whole();
        // init nodes bitmap in whole
        whole.nodes();
        nodes = whole.nodes.copy();
        // remove the phis
        LoopBeginNode loopBegin = loop().loopBegin();
        for (PhiNode phi : loopBegin.phis()) {
            nodes.clear(phi);
        }
        clearStateNodes(loopBegin);
        for (LoopExitNode exit : exits()) {
            clearStateNodes(exit);
            for (ProxyNode proxy : exit.proxies()) {
                nodes.clear(proxy);
            }
        }
    }
    return nodes;
}
Also used : ProxyNode(org.graalvm.compiler.nodes.ProxyNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) MemoryPhiNode(org.graalvm.compiler.nodes.memory.MemoryPhiNode) GuardPhiNode(org.graalvm.compiler.nodes.GuardPhiNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode)

Example 17 with ProxyNode

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

the class GraphUtil method checkRedundantProxy.

public static void checkRedundantProxy(ProxyNode vpn) {
    if (vpn.isDeleted()) {
        return;
    }
    AbstractBeginNode proxyPoint = vpn.proxyPoint();
    if (proxyPoint instanceof LoopExitNode) {
        LoopExitNode exit = (LoopExitNode) proxyPoint;
        LoopBeginNode loopBegin = exit.loopBegin();
        Node vpnValue = vpn.value();
        for (ValueNode v : loopBegin.stateAfter().values()) {
            ValueNode v2 = v;
            if (loopBegin.isPhiAtMerge(v2)) {
                v2 = ((PhiNode) v2).valueAt(loopBegin.forwardEnd());
            }
            if (vpnValue == v2) {
                Collection<PhiNode> phiUsages = vpn.usages().filter(PhiNode.class).snapshot();
                Collection<ProxyNode> proxyUsages = vpn.usages().filter(ProxyNode.class).snapshot();
                vpn.replaceAtUsagesAndDelete(vpnValue);
                for (PhiNode phi : phiUsages) {
                    checkRedundantPhi(phi);
                }
                for (ProxyNode proxy : proxyUsages) {
                    checkRedundantProxy(proxy);
                }
                return;
            }
        }
    }
}
Also used : ProxyNode(org.graalvm.compiler.nodes.ProxyNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) PiNode(org.graalvm.compiler.nodes.PiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) VirtualArrayNode(org.graalvm.compiler.nodes.virtual.VirtualArrayNode) GuardNode(org.graalvm.compiler.nodes.GuardNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 18 with ProxyNode

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

the class GraalCompilerTest method getCanonicalGraphString.

protected static String getCanonicalGraphString(StructuredGraph graph, boolean excludeVirtual, boolean checkConstants) {
    SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.EARLIEST);
    schedule.apply(graph);
    ScheduleResult scheduleResult = graph.getLastSchedule();
    NodeMap<Integer> canonicalId = graph.createNodeMap();
    int nextId = 0;
    List<String> constantsLines = new ArrayList<>();
    StringBuilder result = new StringBuilder();
    for (Block block : scheduleResult.getCFG().getBlocks()) {
        result.append("Block ").append(block).append(' ');
        if (block == scheduleResult.getCFG().getStartBlock()) {
            result.append("* ");
        }
        result.append("-> ");
        for (Block succ : block.getSuccessors()) {
            result.append(succ).append(' ');
        }
        result.append('\n');
        for (Node node : scheduleResult.getBlockToNodesMap().get(block)) {
            if (node instanceof ValueNode && node.isAlive()) {
                if (!excludeVirtual || !(node instanceof VirtualObjectNode || node instanceof ProxyNode || node instanceof FullInfopointNode || node instanceof ParameterNode)) {
                    if (node instanceof ConstantNode) {
                        String name = checkConstants ? node.toString(Verbosity.Name) : node.getClass().getSimpleName();
                        if (excludeVirtual) {
                            constantsLines.add(name);
                        } else {
                            constantsLines.add(name + "    (" + filteredUsageCount(node) + ")");
                        }
                    } else {
                        int id;
                        if (canonicalId.get(node) != null) {
                            id = canonicalId.get(node);
                        } else {
                            id = nextId++;
                            canonicalId.set(node, id);
                        }
                        String name = node.getClass().getSimpleName();
                        result.append("  ").append(id).append('|').append(name);
                        if (node instanceof AccessFieldNode) {
                            result.append('#');
                            result.append(((AccessFieldNode) node).field());
                        }
                        if (!excludeVirtual) {
                            result.append("    (");
                            result.append(filteredUsageCount(node));
                            result.append(')');
                        }
                        result.append('\n');
                    }
                }
            }
        }
    }
    StringBuilder constantsLinesResult = new StringBuilder();
    constantsLinesResult.append(constantsLines.size()).append(" constants:\n");
    Collections.sort(constantsLines);
    for (String s : constantsLines) {
        constantsLinesResult.append(s);
        constantsLinesResult.append('\n');
    }
    return constantsLinesResult.toString() + result.toString();
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) BreakpointNode(org.graalvm.compiler.nodes.BreakpointNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) AccessFieldNode(org.graalvm.compiler.nodes.java.AccessFieldNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ArrayList(java.util.ArrayList) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) AccessFieldNode(org.graalvm.compiler.nodes.java.AccessFieldNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Block(org.graalvm.compiler.nodes.cfg.Block)

Aggregations

ProxyNode (org.graalvm.compiler.nodes.ProxyNode)18 ValueNode (org.graalvm.compiler.nodes.ValueNode)15 PhiNode (org.graalvm.compiler.nodes.PhiNode)10 Node (org.graalvm.compiler.graph.Node)9 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)9 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)7 FixedNode (org.graalvm.compiler.nodes.FixedNode)7 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)7 ValueProxyNode (org.graalvm.compiler.nodes.ValueProxyNode)7 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)6 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)6 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)6 ValuePhiNode (org.graalvm.compiler.nodes.ValuePhiNode)6 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)5 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)5 Block (org.graalvm.compiler.nodes.cfg.Block)5 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)4 EndNode (org.graalvm.compiler.nodes.EndNode)4 FrameState (org.graalvm.compiler.nodes.FrameState)4 GuardPhiNode (org.graalvm.compiler.nodes.GuardPhiNode)4