Search in sources :

Example 36 with PhiNode

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

the class TypeSystemTest method outputNode.

private static void outputNode(Node node) {
    TTY.print("  " + node + "    (usage count: " + node.getUsageCount() + ") (inputs:");
    for (Node input : node.inputs()) {
        TTY.print(" " + input.toString(Verbosity.Id));
    }
    TTY.println(")");
    if (node instanceof AbstractMergeNode) {
        for (PhiNode phi : ((AbstractMergeNode) node).phis()) {
            outputNode(phi);
        }
    }
}
Also used : PhiNode(org.graalvm.compiler.nodes.PhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) Node(org.graalvm.compiler.graph.Node) PhiNode(org.graalvm.compiler.nodes.PhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode)

Example 37 with PhiNode

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

the class LoopTransformations method processPreLoopPhis.

private static void processPreLoopPhis(LoopEx preLoop, LoopFragmentWhole mainLoop, LoopFragmentWhole postLoop) {
    // process phis for the post loop
    LoopBeginNode preLoopBegin = preLoop.loopBegin();
    for (PhiNode prePhiNode : preLoopBegin.phis()) {
        PhiNode postPhiNode = postLoop.getDuplicatedNode(prePhiNode);
        PhiNode mainPhiNode = mainLoop.getDuplicatedNode(prePhiNode);
        postPhiNode.setValueAt(0, mainPhiNode);
        // Build a work list to update the pre loop phis to the post loops phis
        for (Node usage : prePhiNode.usages().snapshot()) {
            if (usage == mainPhiNode) {
                continue;
            }
            if (preLoop.isOutsideLoop(usage)) {
                usage.replaceFirstInput(prePhiNode, postPhiNode);
            }
        }
    }
    for (Node node : preLoop.inside().nodes()) {
        for (Node externalUsage : node.usages().snapshot()) {
            if (preLoop.isOutsideLoop(externalUsage)) {
                Node postUsage = postLoop.getDuplicatedNode(node);
                assert postUsage != null;
                externalUsage.replaceFirstInput(node, postUsage);
            }
        }
    }
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) SwitchNode(org.graalvm.compiler.nodes.extended.SwitchNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) IntegerLessThanNode(org.graalvm.compiler.nodes.calc.IntegerLessThanNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) SafepointNode(org.graalvm.compiler.nodes.SafepointNode) 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) PhiNode(org.graalvm.compiler.nodes.PhiNode)

Example 38 with PhiNode

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

the class CFGPrinter method scheduleInputs.

private void scheduleInputs(Node node, Block nodeBlock) {
    if (node instanceof ValuePhiNode) {
        PhiNode phi = (PhiNode) node;
        Block phiBlock = latestScheduling.get(phi.merge());
        assert phiBlock != null;
        for (Block pred : phiBlock.getPredecessors()) {
            schedule(phi.valueAt((AbstractEndNode) pred.getEndNode()), pred);
        }
    } else {
        for (Node input : node.inputs()) {
            schedule(input, nodeBlock);
        }
    }
}
Also used : ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) 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) Block(org.graalvm.compiler.nodes.cfg.Block)

Example 39 with PhiNode

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

Example 40 with PhiNode

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

the class MultiTypeGuardInlineInfo method duplicateInvokeForInlining.

private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, AbstractMergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining) {
    Invoke result = (Invoke) invoke.asNode().copyWithInputs();
    Node callTarget = result.callTarget().copyWithInputs();
    result.asNode().replaceFirstInput(result.callTarget(), callTarget);
    result.setUseForInlining(useForInlining);
    JavaKind kind = invoke.asNode().getStackKind();
    if (kind != JavaKind.Void) {
        FrameState stateAfter = invoke.stateAfter();
        stateAfter = stateAfter.duplicate(stateAfter.bci);
        stateAfter.replaceFirstInput(invoke.asNode(), result.asNode());
        result.setStateAfter(stateAfter);
    }
    if (invoke instanceof InvokeWithExceptionNode) {
        assert exceptionMerge != null && exceptionObjectPhi != null;
        InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
        ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithException.exceptionEdge();
        FrameState stateAfterException = exceptionEdge.stateAfter();
        ExceptionObjectNode newExceptionEdge = (ExceptionObjectNode) exceptionEdge.copyWithInputs();
        // set new state (pop old exception object, push new one)
        newExceptionEdge.setStateAfter(stateAfterException.duplicateModified(JavaKind.Object, JavaKind.Object, newExceptionEdge));
        EndNode endNode = graph.add(new EndNode());
        newExceptionEdge.setNext(endNode);
        exceptionMerge.addForwardEnd(endNode);
        exceptionObjectPhi.addInput(newExceptionEdge);
        ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge);
    }
    return result;
}
Also used : EndNode(org.graalvm.compiler.nodes.EndNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) PiNode(org.graalvm.compiler.nodes.PiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) TypeSwitchNode(org.graalvm.compiler.nodes.java.TypeSwitchNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) FrameState(org.graalvm.compiler.nodes.FrameState) Invoke(org.graalvm.compiler.nodes.Invoke) JavaKind(jdk.vm.ci.meta.JavaKind)

Aggregations

PhiNode (org.graalvm.compiler.nodes.PhiNode)41 ValueNode (org.graalvm.compiler.nodes.ValueNode)31 Node (org.graalvm.compiler.graph.Node)22 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)21 FixedNode (org.graalvm.compiler.nodes.FixedNode)21 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)19 ValuePhiNode (org.graalvm.compiler.nodes.ValuePhiNode)18 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)17 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)15 EndNode (org.graalvm.compiler.nodes.EndNode)15 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)15 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)14 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)13 FrameState (org.graalvm.compiler.nodes.FrameState)10 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)10 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)10 MergeNode (org.graalvm.compiler.nodes.MergeNode)9 PiNode (org.graalvm.compiler.nodes.PiNode)9 BeginNode (org.graalvm.compiler.nodes.BeginNode)7