Search in sources :

Example 1 with LimitedValueProxy

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

the class StrengthenStampsPhase method run.

@Override
protected void run(StructuredGraph graph) {
    for (Node n : graph.getNodes()) {
        if (n instanceof ValueNode && !(n instanceof LimitedValueProxy) && !(n instanceof PhiNode)) {
            /*
                 * The stamp of proxy nodes and phi nodes is inferred automatically, so we do not
                 * need to improve them.
                 */
            ValueNode node = (ValueNode) n;
            /*
                 * First ask the node to improve the stamp itself, to incorporate already improved
                 * input stamps.
                 */
            node.inferStamp();
            Stamp newStamp = strengthen(node.stamp(NodeView.DEFAULT));
            if (newStamp != null) {
                node.setStamp(newStamp);
            }
        }
        if (n instanceof LoadFieldNode) {
            LoadFieldNode node = (LoadFieldNode) n;
            updateStamp(node, toHosted(node.field()).getFieldTypeProfile());
        } else if (n instanceof InstanceOfNode) {
            InstanceOfNode node = (InstanceOfNode) n;
            ObjectStamp newStamp = (ObjectStamp) strengthen(node.getCheckedStamp());
            if (newStamp != null) {
                node.strengthenCheckedStamp(newStamp);
            }
        } else if (n instanceof PiNode) {
            PiNode node = (PiNode) n;
            Stamp newStamp = strengthen(node.piStamp());
            if (newStamp != null) {
                node.strengthenPiStamp(newStamp);
            }
        }
    }
}
Also used : PhiNode(org.graalvm.compiler.nodes.PhiNode) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) AbstractObjectStamp(org.graalvm.compiler.core.common.type.AbstractObjectStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) AbstractObjectStamp(org.graalvm.compiler.core.common.type.AbstractObjectStamp) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) AssertStampNode(com.oracle.svm.hosted.nodes.AssertStampNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) PiNode(org.graalvm.compiler.nodes.PiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) AssertTypeStateNode(com.oracle.svm.hosted.nodes.AssertTypeStateNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) PiNode(org.graalvm.compiler.nodes.PiNode) LimitedValueProxy(org.graalvm.compiler.nodes.spi.LimitedValueProxy) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode)

Example 2 with LimitedValueProxy

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

the class GraphUtil method originalValueSimple.

private static ValueNode originalValueSimple(ValueNode value) {
    /* The very simple case: look through proxies. */
    ValueNode cur = originalValueForProxy(value);
    while (cur instanceof PhiNode) {
        /*
             * We found a phi function. Check if we can analyze it without allocating temporary data
             * structures.
             */
        PhiNode phi = (PhiNode) cur;
        ValueNode phiSingleValue = null;
        int count = phi.valueCount();
        for (int i = 0; i < count; ++i) {
            ValueNode phiCurValue = originalValueForProxy(phi.valueAt(i));
            if (phiCurValue == phi) {
            /* Simple cycle, we can ignore the input value. */
            } else if (phiSingleValue == null) {
                /* The first input. */
                phiSingleValue = phiCurValue;
            } else if (phiSingleValue != phiCurValue) {
                if (phiSingleValue instanceof PhiNode || phiCurValue instanceof PhiNode) {
                    /*
                         * We have two different input values for the phi function, and at least one
                         * of the inputs is another phi function. We need to do a complicated
                         * exhaustive check.
                         */
                    return originalValueForComplicatedPhi(phi, new NodeBitMap(value.graph()));
                } else {
                    /*
                         * We have two different input values for the phi function, but none of them
                         * is another phi function. This phi function cannot be reduce any further,
                         * so the phi function is the original value.
                         */
                    return phi;
                }
            }
        }
        /*
             * Successfully reduced the phi function to a single input value. The single input value
             * can itself be a phi function again, so we might take another loop iteration.
             */
        assert phiSingleValue != null;
        cur = phiSingleValue;
    }
    /* We reached a "normal" node, which is the original value. */
    assert !(cur instanceof LimitedValueProxy) && !(cur instanceof PhiNode);
    return cur;
}
Also used : PhiNode(org.graalvm.compiler.nodes.PhiNode) NodeBitMap(org.graalvm.compiler.graph.NodeBitMap) ValueNode(org.graalvm.compiler.nodes.ValueNode) LimitedValueProxy(org.graalvm.compiler.nodes.spi.LimitedValueProxy)

Aggregations

PhiNode (org.graalvm.compiler.nodes.PhiNode)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 LimitedValueProxy (org.graalvm.compiler.nodes.spi.LimitedValueProxy)2 AssertStampNode (com.oracle.svm.hosted.nodes.AssertStampNode)1 AssertTypeStateNode (com.oracle.svm.hosted.nodes.AssertTypeStateNode)1 AbstractObjectStamp (org.graalvm.compiler.core.common.type.AbstractObjectStamp)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 Stamp (org.graalvm.compiler.core.common.type.Stamp)1 Node (org.graalvm.compiler.graph.Node)1 NodeBitMap (org.graalvm.compiler.graph.NodeBitMap)1 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)1 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)1 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)1 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)1 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)1 PiNode (org.graalvm.compiler.nodes.PiNode)1 InstanceOfNode (org.graalvm.compiler.nodes.java.InstanceOfNode)1 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)1