Search in sources :

Example 16 with ValuePhiNode

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

the class TruffleGraphBuilderPlugins method registerCompilerAssertsPlugins.

public static void registerCompilerAssertsPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification) {
    final ResolvedJavaType compilerAssertsType = getRuntime().resolveType(metaAccess, "com.oracle.truffle.api.CompilerAsserts");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(compilerAssertsType));
    r.register1("partialEvaluationConstant", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            ValueNode curValue = value;
            if (curValue instanceof BoxNode) {
                BoxNode boxNode = (BoxNode) curValue;
                curValue = boxNode.getValue();
            }
            if (curValue.isConstant()) {
                return true;
            } else if (canDelayIntrinsification) {
                return false;
            } else {
                StringBuilder sb = new StringBuilder();
                sb.append(curValue);
                if (curValue instanceof ValuePhiNode) {
                    ValuePhiNode valuePhi = (ValuePhiNode) curValue;
                    sb.append(" (");
                    for (Node n : valuePhi.inputs()) {
                        sb.append(n);
                        sb.append("; ");
                    }
                    sb.append(")");
                }
                value.getDebug().dump(DebugContext.VERBOSE_LEVEL, value.graph(), "Graph before bailout at node %s", sb);
                throw b.bailout("Partial evaluation did not reduce value to a constant, is a regular compiler node: " + sb);
            }
        }
    });
    r.register0("neverPartOfCompilation", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.add(new NeverPartOfCompilationNode("CompilerAsserts.neverPartOfCompilation()"));
            return true;
        }
    });
    r.register1("neverPartOfCompilation", String.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) {
            if (message.isConstant()) {
                String messageString = message.asConstant().toValueString();
                b.add(new NeverPartOfCompilationNode(messageString));
                return true;
            } else {
                throw b.bailout("message for never part of compilation is non-constant");
            }
        }
    });
}
Also used : ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) RawLoadNode(org.graalvm.compiler.nodes.extended.RawLoadNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) ForceMaterializeNode(org.graalvm.compiler.truffle.compiler.nodes.frame.ForceMaterializeNode) DynamicPiNode(org.graalvm.compiler.nodes.DynamicPiNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) EnsureVirtualizedNode(org.graalvm.compiler.nodes.virtual.EnsureVirtualizedNode) VirtualFrameIsNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameIsNode) RawStoreNode(org.graalvm.compiler.nodes.extended.RawStoreNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) PiNode(org.graalvm.compiler.nodes.PiNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) NewFrameNode(org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) UnsafeAccessNode(org.graalvm.compiler.nodes.extended.UnsafeAccessNode) AllowMaterializeNode(org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) BranchProbabilityNode(org.graalvm.compiler.nodes.extended.BranchProbabilityNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ConditionAnchorNode(org.graalvm.compiler.nodes.ConditionAnchorNode) InstanceOfDynamicNode(org.graalvm.compiler.nodes.java.InstanceOfDynamicNode) UnsignedMulHighNode(org.graalvm.compiler.replacements.nodes.arithmetic.UnsignedMulHighNode) VirtualFrameGetNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameGetNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) GuardedUnsafeLoadNode(org.graalvm.compiler.nodes.extended.GuardedUnsafeLoadNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) PiArrayNode(org.graalvm.compiler.nodes.PiArrayNode) VirtualFrameSetNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameSetNode) IntegerMulHighNode(org.graalvm.compiler.replacements.nodes.arithmetic.IntegerMulHighNode) Node(org.graalvm.compiler.graph.Node) IsCompilationConstantNode(org.graalvm.compiler.truffle.compiler.nodes.IsCompilationConstantNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 17 with ValuePhiNode

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

the class FrameStateBuilder method createLoopPhi.

private ValueNode createLoopPhi(AbstractMergeNode block, ValueNode value, boolean stampFromValue) {
    if (value == null || value == TWO_SLOT_MARKER) {
        return value;
    }
    assert !block.isPhiAtMerge(value) : "phi function for this block already created";
    ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(stampFromValue ? value.stamp(NodeView.DEFAULT) : value.stamp(NodeView.DEFAULT).unrestricted(), block));
    phi.addInput(value);
    return phi;
}
Also used : ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode)

Example 18 with ValuePhiNode

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

the class LoadFieldNode method asPhi.

private static PhiNode asPhi(ConstantFieldProvider constantFields, ConstantReflectionProvider constantReflection, MetaAccessProvider metaAcccess, OptionValues options, ValueNode forObject, ResolvedJavaField field, Stamp stamp) {
    if (!field.isStatic() && field.isFinal() && forObject instanceof ValuePhiNode && ((ValuePhiNode) forObject).values().filter(isNotA(ConstantNode.class)).isEmpty()) {
        PhiNode phi = (PhiNode) forObject;
        ConstantNode[] constantNodes = new ConstantNode[phi.valueCount()];
        for (int i = 0; i < phi.valueCount(); i++) {
            ConstantNode constant = ConstantFoldUtil.tryConstantFold(constantFields, constantReflection, metaAcccess, field, phi.valueAt(i).asJavaConstant(), options);
            if (constant == null) {
                return null;
            }
            constantNodes[i] = constant;
        }
        return new ValuePhiNode(stamp, phi.merge(), constantNodes);
    }
    return null;
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode)

Example 19 with ValuePhiNode

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

the class ConvertDeoptimizeToGuardPhase method trySplitFixedGuard.

private void trySplitFixedGuard(FixedGuardNode fixedGuard, PhaseContext context) {
    LogicNode condition = fixedGuard.condition();
    if (condition instanceof CompareNode) {
        CompareNode compare = (CompareNode) condition;
        ValueNode x = compare.getX();
        ValuePhiNode xPhi = (x instanceof ValuePhiNode) ? (ValuePhiNode) x : null;
        if (x instanceof ConstantNode || xPhi != null) {
            ValueNode y = compare.getY();
            ValuePhiNode yPhi = (y instanceof ValuePhiNode) ? (ValuePhiNode) y : null;
            if (y instanceof ConstantNode || yPhi != null) {
                processFixedGuardAndPhis(fixedGuard, context, compare, x, xPhi, y, yPhi);
            }
        }
    }
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LogicNode(org.graalvm.compiler.nodes.LogicNode)

Example 20 with ValuePhiNode

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

the class NodeLIRBuilder method createPhiIn.

private Value[] createPhiIn(AbstractMergeNode merge) {
    List<Value> values = new ArrayList<>();
    for (ValuePhiNode phi : merge.valuePhis()) {
        assert getOperand(phi) == null;
        Variable value = gen.newVariable(getExactPhiKind(phi));
        values.add(value);
        setResult(phi, value);
    }
    return values.toArray(new Value[values.size()]);
}
Also used : Variable(org.graalvm.compiler.lir.Variable) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ArrayList(java.util.ArrayList)

Aggregations

ValuePhiNode (org.graalvm.compiler.nodes.ValuePhiNode)24 ValueNode (org.graalvm.compiler.nodes.ValueNode)18 PhiNode (org.graalvm.compiler.nodes.PhiNode)12 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)11 Node (org.graalvm.compiler.graph.Node)9 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)8 FixedNode (org.graalvm.compiler.nodes.FixedNode)8 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)7 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)6 LogicNode (org.graalvm.compiler.nodes.LogicNode)6 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)5 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)5 EndNode (org.graalvm.compiler.nodes.EndNode)5 JavaKind (jdk.vm.ci.meta.JavaKind)4 IfNode (org.graalvm.compiler.nodes.IfNode)4 ArrayList (java.util.ArrayList)3 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)3 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)3 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)3 MergeNode (org.graalvm.compiler.nodes.MergeNode)3