Search in sources :

Example 11 with AbstractBeginNode

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

the class BytecodeParser method createInvokeWithException.

protected InvokeWithExceptionNode createInvokeWithException(int invokeBci, CallTargetNode callTarget, JavaKind resultType, ExceptionEdgeAction exceptionEdgeAction) {
    if (currentBlock != null && stream.nextBCI() > currentBlock.endBci) {
        /*
             * Clear non-live locals early so that the exception handler entry gets the cleared
             * state.
             */
        frameState.clearNonLiveLocals(currentBlock, liveness, false);
    }
    AbstractBeginNode exceptionEdge = handleException(null, bci(), exceptionEdgeAction == ExceptionEdgeAction.INCLUDE_AND_DEOPTIMIZE);
    InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionEdge, invokeBci));
    frameState.pushReturn(resultType, invoke);
    invoke.setStateAfter(createFrameState(stream.nextBCI(), invoke));
    return invoke;
}
Also used : StressInvokeWithExceptionNode(org.graalvm.compiler.core.common.GraalOptions.StressInvokeWithExceptionNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 12 with AbstractBeginNode

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

the class BytecodeParser method handleException.

private AbstractBeginNode handleException(ValueNode exceptionObject, int bci, boolean deoptimizeOnly) {
    assert bci == BytecodeFrame.BEFORE_BCI || bci == bci() : "invalid bci";
    debug.log("Creating exception dispatch edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, (profilingInfo == null ? "" : profilingInfo.getExceptionSeen(bci)));
    FrameStateBuilder dispatchState = frameState.copy();
    dispatchState.clearStack();
    AbstractBeginNode dispatchBegin;
    if (exceptionObject == null) {
        ExceptionObjectNode newExceptionObject = graph.add(new ExceptionObjectNode(metaAccess));
        dispatchBegin = newExceptionObject;
        dispatchState.push(JavaKind.Object, dispatchBegin);
        dispatchState.setRethrowException(true);
        newExceptionObject.setStateAfter(dispatchState.create(bci, newExceptionObject));
    } else {
        dispatchBegin = graph.add(new BeginNode());
        dispatchState.push(JavaKind.Object, exceptionObject);
        dispatchState.setRethrowException(true);
    }
    this.controlFlowSplit = true;
    FixedWithNextNode finishedDispatch = finishInstruction(dispatchBegin, dispatchState);
    if (deoptimizeOnly) {
        DeoptimizeNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.TransferToInterpreter));
        dispatchBegin.setNext(BeginNode.begin(deoptimizeNode));
    } else {
        createHandleExceptionTarget(finishedDispatch, bci, dispatchState);
    }
    return dispatchBegin;
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) KillingBeginNode(org.graalvm.compiler.nodes.KillingBeginNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 13 with AbstractBeginNode

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

the class BytecodeParser method handleUnresolvedInstanceOf.

/**
 * @param type the unresolved type of the type check
 * @param object the object value whose type is being checked against {@code type}
 */
protected void handleUnresolvedInstanceOf(JavaType type, ValueNode object) {
    assert !graphBuilderConfig.unresolvedIsError();
    AbstractBeginNode successor = graph.add(new BeginNode());
    DeoptimizeNode deopt = graph.add(new DeoptimizeNode(InvalidateRecompile, Unresolved));
    deopt.updateNodeSourcePosition(() -> createBytecodePosition());
    append(new IfNode(graph.addOrUniqueWithInputs(IsNullNode.create(object)), successor, deopt, 1));
    lastInstr = successor;
    frameState.push(JavaKind.Int, appendConstant(JavaConstant.INT_0));
}
Also used : BeginNode(org.graalvm.compiler.nodes.BeginNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) KillingBeginNode(org.graalvm.compiler.nodes.KillingBeginNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 14 with AbstractBeginNode

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

the class BytecodeParser method emitExplicitNullCheck.

protected ValueNode emitExplicitNullCheck(ValueNode receiver) {
    if (StampTool.isPointerNonNull(receiver.stamp(NodeView.DEFAULT))) {
        return receiver;
    }
    BytecodeExceptionNode exception = graph.add(new BytecodeExceptionNode(metaAccess, NullPointerException.class));
    AbstractBeginNode falseSucc = graph.add(new BeginNode());
    ValueNode nonNullReceiver = graph.addOrUniqueWithInputs(PiNode.create(receiver, objectNonNull(), falseSucc));
    append(new IfNode(graph.addOrUniqueWithInputs(IsNullNode.create(receiver)), exception, falseSucc, SLOW_PATH_PROBABILITY));
    lastInstr = falseSucc;
    exception.setStateAfter(createFrameState(bci(), exception));
    exception.setNext(handleException(exception, bci(), false));
    EXPLICIT_EXCEPTIONS.increment(debug);
    return nonNullReceiver;
}
Also used : BeginNode(org.graalvm.compiler.nodes.BeginNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) KillingBeginNode(org.graalvm.compiler.nodes.KillingBeginNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) BytecodeExceptionNode(org.graalvm.compiler.nodes.extended.BytecodeExceptionNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 15 with AbstractBeginNode

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

the class NodeLIRBuilder method doBlock.

@Override
@SuppressWarnings("try")
public void doBlock(Block block, StructuredGraph graph, BlockMap<List<Node>> blockMap) {
    OptionValues options = graph.getOptions();
    try (BlockScope blockScope = gen.getBlockScope(block)) {
        setSourcePosition(null);
        if (block == gen.getResult().getLIR().getControlFlowGraph().getStartBlock()) {
            assert block.getPredecessorCount() == 0;
            emitPrologue(graph);
        } else {
            assert block.getPredecessorCount() > 0;
            // create phi-in value array
            AbstractBeginNode begin = block.getBeginNode();
            if (begin instanceof AbstractMergeNode) {
                AbstractMergeNode merge = (AbstractMergeNode) begin;
                LabelOp label = (LabelOp) gen.getResult().getLIR().getLIRforBlock(block).get(0);
                label.setPhiValues(createPhiIn(merge));
                if (Options.PrintIRWithLIR.getValue(options) && !TTY.isSuppressed()) {
                    TTY.println("Created PhiIn: " + label);
                }
            }
        }
        doBlockPrologue(block, options);
        List<Node> nodes = blockMap.get(block);
        // Allow NodeLIRBuilder subclass to specialize code generation of any interesting groups
        // of instructions
        matchComplexExpressions(nodes);
        boolean trace = traceLIRGeneratorLevel >= 3;
        for (int i = 0; i < nodes.size(); i++) {
            Node node = nodes.get(i);
            if (node instanceof ValueNode) {
                DebugContext debug = node.getDebug();
                ValueNode valueNode = (ValueNode) node;
                if (trace) {
                    TTY.println("LIRGen for " + valueNode);
                }
                Value operand = getOperand(valueNode);
                if (operand == null) {
                    if (!peephole(valueNode)) {
                        try {
                            doRoot(valueNode);
                        } catch (GraalError e) {
                            throw GraalGraphError.transformAndAddContext(e, valueNode);
                        } catch (Throwable e) {
                            throw new GraalGraphError(e).addContext(valueNode);
                        }
                    }
                } else if (ComplexMatchValue.INTERIOR_MATCH.equals(operand)) {
                    // Doesn't need to be evaluated
                    debug.log("interior match for %s", valueNode);
                } else if (operand instanceof ComplexMatchValue) {
                    debug.log("complex match for %s", valueNode);
                    ComplexMatchValue match = (ComplexMatchValue) operand;
                    operand = match.evaluate(this);
                    if (operand != null) {
                        setResult(valueNode, operand);
                    }
                } else {
                // There can be cases in which the result of an instruction is already set
                // before by other instructions.
                }
            }
        }
        if (!gen.hasBlockEnd(block)) {
            NodeIterable<Node> successors = block.getEndNode().successors();
            assert successors.count() == block.getSuccessorCount();
            if (block.getSuccessorCount() != 1) {
                /*
                     * If we have more than one successor, we cannot just use the first one. Since
                     * successors are unordered, this would be a random choice.
                     */
                throw new GraalError("Block without BlockEndOp: " + block.getEndNode());
            }
            gen.emitJump(getLIRBlock((FixedNode) successors.first()));
        }
        assert verifyBlock(gen.getResult().getLIR(), block);
    }
}
Also used : LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) OptionValues(org.graalvm.compiler.options.OptionValues) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) IfNode(org.graalvm.compiler.nodes.IfNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) DeoptimizingNode(org.graalvm.compiler.nodes.DeoptimizingNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) DirectCallTargetNode(org.graalvm.compiler.nodes.DirectCallTargetNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) IntegerTestNode(org.graalvm.compiler.nodes.calc.IntegerTestNode) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) SwitchNode(org.graalvm.compiler.nodes.extended.SwitchNode) LoweredCallTargetNode(org.graalvm.compiler.nodes.LoweredCallTargetNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IndirectCallTargetNode(org.graalvm.compiler.nodes.IndirectCallTargetNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) Node(org.graalvm.compiler.graph.Node) PhiNode(org.graalvm.compiler.nodes.PhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LIRGenerationDebugContext(org.graalvm.compiler.lir.debug.LIRGenerationDebugContext) DebugContext(org.graalvm.compiler.debug.DebugContext) FixedNode(org.graalvm.compiler.nodes.FixedNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) GraalError(org.graalvm.compiler.debug.GraalError) BlockScope(org.graalvm.compiler.lir.gen.LIRGeneratorTool.BlockScope) GraalGraphError(org.graalvm.compiler.graph.GraalGraphError) ValueNode(org.graalvm.compiler.nodes.ValueNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Aggregations

AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)63 FixedNode (org.graalvm.compiler.nodes.FixedNode)32 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)31 Node (org.graalvm.compiler.graph.Node)24 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)23 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)23 EndNode (org.graalvm.compiler.nodes.EndNode)22 BeginNode (org.graalvm.compiler.nodes.BeginNode)21 ValueNode (org.graalvm.compiler.nodes.ValueNode)20 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)16 IfNode (org.graalvm.compiler.nodes.IfNode)16 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)15 MergeNode (org.graalvm.compiler.nodes.MergeNode)15 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)15 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)14 PhiNode (org.graalvm.compiler.nodes.PhiNode)14 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)13 LogicNode (org.graalvm.compiler.nodes.LogicNode)12 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)11 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)11