Search in sources :

Example 31 with ParameterNode

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

the class PEGraphDecoder method handleFloatingNodeBeforeAdd.

@Override
protected Node handleFloatingNodeBeforeAdd(MethodScope s, LoopScope loopScope, Node n) {
    PEMethodScope methodScope = (PEMethodScope) s;
    Node node = n;
    if (node instanceof ParameterNode) {
        ParameterNode param = (ParameterNode) node;
        if (methodScope.isInlinedMethod()) {
            throw GraalError.shouldNotReachHere("Parameter nodes are already registered when the inlined scope is created");
        } else if (parameterPlugin != null) {
            assert !methodScope.isInlinedMethod();
            GraphBuilderContext graphBuilderContext = new PENonAppendGraphBuilderContext(methodScope, null);
            Node result = parameterPlugin.interceptParameter(graphBuilderContext, param.index(), StampPair.create(param.stamp(NodeView.DEFAULT), param.uncheckedStamp()));
            if (result != null) {
                return result;
            }
        }
        node = param.copyWithInputs();
    }
    return super.handleFloatingNodeBeforeAdd(methodScope, loopScope, node);
}
Also used : ParameterNode(org.graalvm.compiler.nodes.ParameterNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) StoreIndexedNode(org.graalvm.compiler.nodes.java.StoreIndexedNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) Node(org.graalvm.compiler.graph.Node) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode)

Example 32 with ParameterNode

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

the class BlackholeDirectiveTest method checkLowTierGraph.

@Override
protected boolean checkLowTierGraph(StructuredGraph graph) {
    BlackholeSnippet snippet = graph.method().getAnnotation(BlackholeSnippet.class);
    ParameterNode arg = graph.getParameter(0);
    if (snippet.expectParameterUsage()) {
        Assert.assertNotNull("couldn't find ParameterNode(0)", arg);
        Assert.assertFalse("expected usages of " + arg, arg.hasNoUsages());
    } else {
        Assert.assertTrue("expected no usages of ParameterNode", arg == null || arg.hasNoUsages());
    }
    return true;
}
Also used : ParameterNode(org.graalvm.compiler.nodes.ParameterNode)

Example 33 with ParameterNode

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

the class BytecodeParser method checkPartialIntrinsicExit.

/**
 * A partial intrinsic exits by (effectively) calling the intrinsified method. This call must
 * use exactly the arguments to the call being intrinsified.
 *
 * @param originalArgs arguments of original call to intrinsified method
 * @param recursiveArgs arguments of recursive call to intrinsified method
 */
private static boolean checkPartialIntrinsicExit(ValueNode[] originalArgs, ValueNode[] recursiveArgs) {
    if (originalArgs != null) {
        for (int i = 0; i < originalArgs.length; i++) {
            ValueNode arg = GraphUtil.unproxify(recursiveArgs[i]);
            ValueNode icArg = GraphUtil.unproxify(originalArgs[i]);
            assert arg == icArg : String.format("argument %d of call denoting partial intrinsic exit should be %s, not %s", i, icArg, arg);
        }
    } else {
        for (int i = 0; i < recursiveArgs.length; i++) {
            ValueNode arg = GraphUtil.unproxify(recursiveArgs[i]);
            assert arg instanceof ParameterNode && ((ParameterNode) arg).index() == i : String.format("argument %d of call denoting partial intrinsic exit should be a %s with index %d, not %s", i, ParameterNode.class.getSimpleName(), i, arg);
        }
    }
    return true;
}
Also used : ParameterNode(org.graalvm.compiler.nodes.ParameterNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) RuntimeConstraint(jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint)

Example 34 with ParameterNode

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

the class FrameStateBuilder method initializeForMethodStart.

public void initializeForMethodStart(Assumptions assumptions, boolean eagerResolve, Plugins plugins) {
    int javaIndex = 0;
    int index = 0;
    ResolvedJavaMethod method = getMethod();
    ResolvedJavaType originalType = method.getDeclaringClass();
    if (!method.isStatic()) {
        // add the receiver
        FloatingNode receiver = null;
        StampPair receiverStamp = null;
        if (plugins != null) {
            receiverStamp = plugins.getOverridingStamp(tool, originalType, true);
        }
        if (receiverStamp == null) {
            receiverStamp = StampFactory.forDeclaredType(assumptions, originalType, true);
        }
        if (plugins != null) {
            for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
                receiver = plugin.interceptParameter(tool, index, receiverStamp);
                if (receiver != null) {
                    break;
                }
            }
        }
        if (receiver == null) {
            receiver = new ParameterNode(javaIndex, receiverStamp);
        }
        locals[javaIndex] = graph.addOrUniqueWithInputs(receiver);
        javaIndex = 1;
        index = 1;
    }
    Signature sig = method.getSignature();
    int max = sig.getParameterCount(false);
    ResolvedJavaType accessingClass = originalType;
    for (int i = 0; i < max; i++) {
        JavaType type = sig.getParameterType(i, accessingClass);
        if (eagerResolve) {
            type = type.resolve(accessingClass);
        }
        JavaKind kind = type.getJavaKind();
        StampPair stamp = null;
        if (plugins != null) {
            stamp = plugins.getOverridingStamp(tool, type, false);
        }
        if (stamp == null) {
            stamp = StampFactory.forDeclaredType(assumptions, type, false);
        }
        FloatingNode param = null;
        if (plugins != null) {
            for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
                param = plugin.interceptParameter(tool, index, stamp);
                if (param != null) {
                    break;
                }
            }
        }
        if (param == null) {
            param = new ParameterNode(index, stamp);
        }
        locals[javaIndex] = graph.addOrUniqueWithInputs(param);
        javaIndex++;
        if (kind.needsTwoSlots()) {
            locals[javaIndex] = TWO_SLOT_MARKER;
            javaIndex++;
        }
        index++;
    }
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) ParameterPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) Signature(jdk.vm.ci.meta.Signature) StampPair(org.graalvm.compiler.core.common.type.StampPair) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 35 with ParameterNode

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

the class SpecialInvokeTypeFlow method linkCallee.

protected void linkCallee(BigBang bb, boolean isStatic, MethodFlowsGraph calleeFlows) {
    // iterate over the actual parameters in caller context
    for (int i = 0; i < actualParameters.length; i++) {
        TypeFlow<?> actualParam = actualParameters[i];
        // get the formal parameter from the specific clone
        TypeFlow<?> formalParam = calleeFlows.getParameter(i);
        /*
             * The link between the receiver object and 'this' parameter of instance methods is a
             * non-state-transfer link. The link only exists for a proper iteration of type flow
             * graphs, but the state update of 'this' parameters is achieved through direct state
             * update in VirtualInvokeTypeFlow.update and SpecialInvokeTypeFlow.update by calling
             * FormalReceiverTypeFlow.addReceiverState. This happens because the formal receiver ,
             * i.e., 'this' parameter, state must ONLY reflect those objects of the actual receiver
             * that generated the context for the method clone which it belongs to. A direct link
             * would instead transfer all the objects of compatible type from the actual receiver to
             * the formal receiver.
             */
        if (actualParam != null && formalParam != null) /* && (i != 0 || isStatic) */
        {
            // create the use link:
            // (formalParam, callerContext) -> (actualParam, calleeContext)
            // Note: the callerContext is an implicit property of the current InvokeTypeFlow
            // clone
            actualParam.addUse(bb, formalParam);
        }
    }
    if (actualReturn != null) {
        if (PointstoOptions.DivertParameterReturningMethod.getValue(bb.getOptions())) {
            ParameterNode paramNode = calleeFlows.getMethod().getTypeFlow().getReturnedParameter();
            if (paramNode != null) {
                if (isStatic || paramNode.index() != 0) {
                    TypeFlow<?> actualParam = actualParameters[paramNode.index()];
                    actualParam.addUse(bb, actualReturn);
                }
            // else {
            // receiver object state is transfered in updateReceiver()
            // }
            } else {
                /*
                     * The callee may have a return type, hence the actualReturn is non-null, but it
                     * might throw an exception instead of returning, hence the formal return is
                     * null.
                     */
                if (calleeFlows.getResult() != null) {
                    calleeFlows.getResult().addUse(bb, actualReturn);
                }
            }
        } else {
            /*
                 * The callee may have a return type, hence the actualReturn is non-null, but it
                 * might throw an exception instead of returning, hence the formal return is null.
                 */
            if (calleeFlows.getResult() != null) {
                calleeFlows.getResult().addUse(bb, actualReturn);
            }
        }
    }
    assert this.isClone() && originalInvoke != null;
    calleeFlows.getMethod().registerAsImplementationInvoked(originalInvoke);
}
Also used : ParameterNode(org.graalvm.compiler.nodes.ParameterNode)

Aggregations

ParameterNode (org.graalvm.compiler.nodes.ParameterNode)46 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)19 ValueNode (org.graalvm.compiler.nodes.ValueNode)19 Node (org.graalvm.compiler.graph.Node)13 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)13 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)13 Test (org.junit.Test)10 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)9 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)8 DebugContext (org.graalvm.compiler.debug.DebugContext)7 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)7 FrameState (org.graalvm.compiler.nodes.FrameState)7 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)7 FixedNode (org.graalvm.compiler.nodes.FixedNode)6 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)6 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)5 InvokeNode (org.graalvm.compiler.nodes.InvokeNode)5 PhiNode (org.graalvm.compiler.nodes.PhiNode)5 ArrayList (java.util.ArrayList)4 JavaConstant (jdk.vm.ci.meta.JavaConstant)4