Search in sources :

Example 1 with NodeView

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

the class GetClassNode method canonical.

@Override
public ValueNode canonical(CanonicalizerTool tool) {
    NodeView view = NodeView.from(tool);
    ValueNode folded = tryFold(tool.getMetaAccess(), tool.getConstantReflection(), view, getObject());
    return folded == null ? this : folded;
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 2 with NodeView

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

the class InstanceOfNode method canonical.

@Override
public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) {
    NodeView view = NodeView.from(tool);
    LogicNode synonym = findSynonym(checkedStamp, forValue, view);
    if (synonym != null) {
        return synonym;
    } else {
        return this;
    }
}
Also used : UnaryOpLogicNode(org.graalvm.compiler.nodes.UnaryOpLogicNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 3 with NodeView

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

the class IntegerSwitchNode method simplify.

@Override
public void simplify(SimplifierTool tool) {
    NodeView view = NodeView.from(tool);
    if (blockSuccessorCount() == 1) {
        tool.addToWorkList(defaultSuccessor());
        graph().removeSplitPropagate(this, defaultSuccessor());
    } else if (value() instanceof ConstantNode) {
        killOtherSuccessors(tool, successorIndexAtKey(value().asJavaConstant().asInt()));
    } else if (tryOptimizeEnumSwitch(tool)) {
        return;
    } else if (tryRemoveUnreachableKeys(tool, value().stamp(view))) {
        return;
    }
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 4 with NodeView

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

the class NewArrayNode method simplify.

@Override
public void simplify(SimplifierTool tool) {
    if (hasNoUsages()) {
        NodeView view = NodeView.from(tool);
        Stamp lengthStamp = length().stamp(view);
        if (lengthStamp instanceof IntegerStamp) {
            IntegerStamp lengthIntegerStamp = (IntegerStamp) lengthStamp;
            if (lengthIntegerStamp.isPositive()) {
                GraphUtil.removeFixedWithUnusedInputs(this);
                return;
            }
        }
        // RuntimeConstraint
        if (graph().getGuardsStage().allowsFloatingGuards()) {
            LogicNode lengthNegativeCondition = CompareNode.createCompareNode(graph(), CanonicalCondition.LT, length(), ConstantNode.forInt(0, graph()), tool.getConstantReflection(), view);
            // we do not have a non-deopting path for that at the moment so action=None.
            FixedGuardNode guard = graph().add(new FixedGuardNode(lengthNegativeCondition, DeoptimizationReason.RuntimeConstraint, DeoptimizationAction.None, true));
            graph().replaceFixedWithFixed(this, guard);
        }
    }
}
Also used : FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) LogicNode(org.graalvm.compiler.nodes.LogicNode) NodeView(org.graalvm.compiler.nodes.NodeView)

Example 5 with NodeView

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

the class RawLoadNode method canonical.

@Override
public Node canonical(CanonicalizerTool tool) {
    if (!isAnyLocationForced() && getLocationIdentity().isAny()) {
        ValueNode targetObject = object();
        if (offset().isConstant() && targetObject.isConstant() && !targetObject.isNullConstant()) {
            ConstantNode objectConstant = (ConstantNode) targetObject;
            ResolvedJavaType type = StampTool.typeOrNull(objectConstant);
            if (type != null && type.isArray()) {
                JavaConstant arrayConstant = objectConstant.asJavaConstant();
                if (arrayConstant != null) {
                    int stableDimension = objectConstant.getStableDimension();
                    if (stableDimension > 0) {
                        NodeView view = NodeView.from(tool);
                        long constantOffset = offset().asJavaConstant().asLong();
                        Constant constant = stamp(view).readConstant(tool.getConstantReflection().getMemoryAccessProvider(), arrayConstant, constantOffset);
                        boolean isDefaultStable = objectConstant.isDefaultStable();
                        if (constant != null && (isDefaultStable || !constant.isDefaultForKind())) {
                            return ConstantNode.forConstant(stamp(view), constant, stableDimension - 1, isDefaultStable, tool.getMetaAccess());
                        }
                    }
                }
            }
        }
    }
    return super.canonical(tool);
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) Constant(jdk.vm.ci.meta.Constant) JavaConstant(jdk.vm.ci.meta.JavaConstant) ValueNode(org.graalvm.compiler.nodes.ValueNode) JavaConstant(jdk.vm.ci.meta.JavaConstant) NodeView(org.graalvm.compiler.nodes.NodeView) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Aggregations

NodeView (org.graalvm.compiler.nodes.NodeView)37 ValueNode (org.graalvm.compiler.nodes.ValueNode)28 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)6 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)4 Constant (jdk.vm.ci.meta.Constant)3 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)2 LogicNode (org.graalvm.compiler.nodes.LogicNode)2 AddNode (org.graalvm.compiler.nodes.calc.AddNode)2 MulNode (org.graalvm.compiler.nodes.calc.MulNode)2 ArrayList (java.util.ArrayList)1 Assumptions (jdk.vm.ci.meta.Assumptions)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 Add (org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Add)1 Mul (org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Mul)1 Sub (org.graalvm.compiler.core.common.type.ArithmeticOpTable.BinaryOp.Sub)1 FloatStamp (org.graalvm.compiler.core.common.type.FloatStamp)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 Stamp (org.graalvm.compiler.core.common.type.Stamp)1