Search in sources :

Example 31 with FixedWithNextNode

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

the class GraphKit method endInvokeWithException.

/**
 * Finishes a control flow started with {@link #startInvokeWithException}. If necessary, creates
 * a merge of the non-exception and exception edges. The merge node is returned and the
 * non-exception edge is the first forward end of the merge, the exception edge is the second
 * forward end (relevant for phi nodes).
 */
public AbstractMergeNode endInvokeWithException() {
    InvokeWithExceptionStructure s = saveLastInvokeWithExceptionNode();
    FixedWithNextNode noExceptionEdge = s.noExceptionEdge instanceof FixedWithNextNode ? (FixedWithNextNode) s.noExceptionEdge : null;
    FixedWithNextNode exceptionEdge = s.exceptionEdge instanceof FixedWithNextNode ? (FixedWithNextNode) s.exceptionEdge : null;
    AbstractMergeNode merge = null;
    if (noExceptionEdge != null && exceptionEdge != null) {
        EndNode noExceptionEnd = graph.add(new EndNode());
        graph.addAfterFixed(noExceptionEdge, noExceptionEnd);
        EndNode exceptionEnd = graph.add(new EndNode());
        graph.addAfterFixed(exceptionEdge, exceptionEnd);
        merge = graph.add(new MergeNode());
        merge.addForwardEnd(noExceptionEnd);
        merge.addForwardEnd(exceptionEnd);
        lastFixedNode = merge;
    } else if (noExceptionEdge != null) {
        lastFixedNode = noExceptionEdge;
    } else if (exceptionEdge != null) {
        lastFixedNode = exceptionEdge;
    } else {
        assert lastFixedNode == null;
    }
    s.state = InvokeWithExceptionStructure.State.FINISHED;
    popStructure();
    return merge;
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) EndNode(org.graalvm.compiler.nodes.EndNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode)

Example 32 with FixedWithNextNode

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

the class IntrinsicGraphBuilder method updateLastInstruction.

private <T extends ValueNode> void updateLastInstruction(T v) {
    if (v instanceof FixedNode) {
        FixedNode fixedNode = (FixedNode) v;
        lastInstr.setNext(fixedNode);
        if (fixedNode instanceof FixedWithNextNode) {
            FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) fixedNode;
            assert fixedWithNextNode.next() == null : "cannot append instruction to instruction which isn't end";
            lastInstr = fixedWithNextNode;
        } else {
            lastInstr = null;
        }
    }
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Example 33 with FixedWithNextNode

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

the class PEGraphDecoder method doInline.

protected LoopScope doInline(PEMethodScope methodScope, LoopScope loopScope, InvokeData invokeData, InlineInfo inlineInfo, ValueNode[] arguments) {
    ResolvedJavaMethod inlineMethod = inlineInfo.getMethodToInline();
    EncodedGraph graphToInline = lookupEncodedGraph(inlineMethod, inlineInfo.getOriginalMethod(), inlineInfo.getIntrinsicBytecodeProvider(), graph.trackNodeSourcePosition());
    if (graphToInline == null) {
        return null;
    }
    assert !graph.trackNodeSourcePosition() || graphToInline.trackNodeSourcePosition() : graph + " " + graphToInline;
    if (methodScope.inliningDepth > Options.InliningDepthError.getValue(options)) {
        throw tooDeepInlining(methodScope);
    }
    for (InlineInvokePlugin plugin : inlineInvokePlugins) {
        plugin.notifyBeforeInline(inlineMethod);
    }
    Invoke invoke = invokeData.invoke;
    FixedNode invokeNode = invoke.asNode();
    FixedWithNextNode predecessor = (FixedWithNextNode) invokeNode.predecessor();
    invokeNode.replaceAtPredecessor(null);
    PEMethodScope inlineScope = new PEMethodScope(graph, methodScope, loopScope, graphToInline, inlineMethod, invokeData, methodScope.inliningDepth + 1, loopExplosionPlugin, arguments);
    if (!inlineMethod.isStatic()) {
        if (StampTool.isPointerAlwaysNull(arguments[0])) {
            /*
                 * The receiver is null, so we can unconditionally throw a NullPointerException
                 * instead of performing any inlining.
                 */
            DeoptimizeNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.NullCheckException));
            predecessor.setNext(deoptimizeNode);
            finishInlining(inlineScope);
            /* Continue decoding in the caller. */
            return loopScope;
        } else if (!StampTool.isPointerNonNull(arguments[0])) {
            /* The receiver might be null, so we need to insert a null check. */
            PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(inlineScope, predecessor);
            arguments[0] = graphBuilderContext.nullCheckedValue(arguments[0]);
            predecessor = graphBuilderContext.lastInstr;
        }
    }
    LoopScope inlineLoopScope = createInitialLoopScope(inlineScope, predecessor);
    /*
         * The GraphEncoder assigns parameters a nodeId immediately after the fixed nodes.
         * Initializing createdNodes here avoid decoding and immediately replacing the
         * ParameterNodes.
         */
    int firstArgumentNodeId = inlineScope.maxFixedNodeOrderId + 1;
    for (int i = 0; i < arguments.length; i++) {
        inlineLoopScope.createdNodes[firstArgumentNodeId + i] = arguments[i];
    }
    // Copy assumptions from inlinee to caller
    Assumptions assumptions = graph.getAssumptions();
    Assumptions inlinedAssumptions = graphToInline.getAssumptions();
    if (assumptions != null) {
        if (inlinedAssumptions != null) {
            assumptions.record(inlinedAssumptions);
        }
    } else {
        assert inlinedAssumptions == null : String.format("cannot inline graph (%s) which makes assumptions into a graph (%s) that doesn't", inlineMethod, graph);
    }
    // Copy inlined methods from inlinee to caller
    List<ResolvedJavaMethod> inlinedMethods = graphToInline.getInlinedMethods();
    if (inlinedMethods != null) {
        graph.getMethods().addAll(inlinedMethods);
    }
    if (graphToInline.getFields() != null) {
        for (ResolvedJavaField field : graphToInline.getFields()) {
            graph.recordField(field);
        }
    }
    if (graphToInline.hasUnsafeAccess()) {
        graph.markUnsafeAccess();
    }
    /*
         * Do the actual inlining by returning the initial loop scope for the inlined method scope.
         */
    return inlineLoopScope;
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) EncodedGraph(org.graalvm.compiler.nodes.EncodedGraph) InlineInvokePlugin(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin) FixedNode(org.graalvm.compiler.nodes.FixedNode) Invoke(org.graalvm.compiler.nodes.Invoke) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) Assumptions(jdk.vm.ci.meta.Assumptions) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 34 with FixedWithNextNode

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

the class IntegerExactArithmeticSplitNode method lower.

static void lower(LoweringTool tool, IntegerExactArithmeticNode node) {
    if (node.asNode().graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
        FloatingNode floatingNode = (FloatingNode) node;
        FixedWithNextNode previous = tool.lastFixedNode();
        FixedNode next = previous.next();
        previous.setNext(null);
        DeoptimizeNode deopt = floatingNode.graph().add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.ArithmeticException));
        AbstractBeginNode normalBegin = floatingNode.graph().add(new BeginNode());
        normalBegin.setNext(next);
        IntegerExactArithmeticSplitNode split = node.createSplit(normalBegin, BeginNode.begin(deopt));
        previous.setNext(split);
        floatingNode.replaceAndDelete(split);
    }
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 35 with FixedWithNextNode

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

the class MethodHandleNode method simplify.

@Override
public void simplify(SimplifierTool tool) {
    MethodHandleAccessProvider methodHandleAccess = tool.getConstantReflection().getMethodHandleAccess();
    ValueNode[] argumentsArray = arguments.toArray(new ValueNode[arguments.size()]);
    final FixedNode before = this;
    GraphAdder adder = new GraphAdder(graph()) {

        @Override
        public <T extends ValueNode> T add(T node) {
            T added = graph().addOrUnique(node);
            if (added instanceof FixedWithNextNode) {
                graph().addBeforeFixed(before, (FixedWithNextNode) added);
            }
            return added;
        }
    };
    InvokeNode invoke = tryResolveTargetInvoke(adder, methodHandleAccess, intrinsicMethod, targetMethod, bci, returnStamp, argumentsArray);
    if (invoke != null) {
        assert invoke.graph() == null;
        invoke = graph().addOrUniqueWithInputs(invoke);
        invoke.setStateAfter(stateAfter());
        FixedNode currentNext = next();
        replaceAtUsages(invoke);
        GraphUtil.removeFixedWithUnusedInputs(this);
        graph().addBeforeFixed(currentNext, invoke);
    }
}
Also used : MethodHandleAccessProvider(jdk.vm.ci.meta.MethodHandleAccessProvider) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Aggregations

FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)57 FixedNode (org.graalvm.compiler.nodes.FixedNode)33 ValueNode (org.graalvm.compiler.nodes.ValueNode)29 Node (org.graalvm.compiler.graph.Node)26 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)22 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)21 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)20 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)13 EndNode (org.graalvm.compiler.nodes.EndNode)12 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)12 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)10 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)9 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)9 Invoke (org.graalvm.compiler.nodes.Invoke)9 LogicNode (org.graalvm.compiler.nodes.LogicNode)9 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)9 PhiNode (org.graalvm.compiler.nodes.PhiNode)9 IfNode (org.graalvm.compiler.nodes.IfNode)8 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)7 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)7