Search in sources :

Example 6 with MergeNode

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

the class OptimizeExceptionCallsPhase method setBranchProbability.

/**
 * Sets the branch probability of the guarding IfNode to a small value. The effect is that the
 * exception call block is put at the end of the method. The other block (= the regular path)
 * gets the fall-through block of the IfNode. This should give a better performance - and it
 * looks nicer in the disassembly.
 */
private static void setBranchProbability(Node endNode) {
    Node node = endNode;
    Node predecessor = node.predecessor();
    // Go "up" the graph until we find an IfNode
    while (predecessor != null) {
        if (predecessor instanceof IfNode && node instanceof BeginNode) {
            // We found an IfNode which branches to our runtime exception call
            IfNode ifNode = (IfNode) predecessor;
            ifNode.setTrueSuccessorProbability(node == ifNode.trueSuccessor() ? 0.00001 : 0.99999);
            return;
        }
        if (predecessor instanceof MergeNode || predecessor instanceof ControlSplitNode) {
            // Any other split or merge is suspicious: we abort
            return;
        }
        node = predecessor;
        predecessor = node.predecessor();
    }
}
Also used : MergeNode(org.graalvm.compiler.nodes.MergeNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) IfNode(org.graalvm.compiler.nodes.IfNode) DeadEndNode(com.oracle.svm.core.graal.nodes.DeadEndNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) Node(org.graalvm.compiler.graph.Node) MergeNode(org.graalvm.compiler.nodes.MergeNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) IfNode(org.graalvm.compiler.nodes.IfNode)

Example 7 with MergeNode

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

the class SimpleCFGTest method testImplies.

@Test
public void testImplies() {
    OptionValues options = getInitialOptions();
    DebugContext debug = DebugContext.create(options, new GraalDebugHandlersFactory(getSnippetReflection()));
    StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.YES).build();
    EndNode trueEnd = graph.add(new EndNode());
    EndNode falseEnd = graph.add(new EndNode());
    AbstractBeginNode trueBegin = graph.add(new BeginNode());
    trueBegin.setNext(trueEnd);
    AbstractBeginNode falseBegin = graph.add(new BeginNode());
    falseBegin.setNext(falseEnd);
    IfNode ifNode = graph.add(new IfNode(null, trueBegin, falseBegin, 0.5));
    graph.start().setNext(ifNode);
    AbstractMergeNode merge = graph.add(new MergeNode());
    merge.addForwardEnd(trueEnd);
    merge.addForwardEnd(falseEnd);
    ReturnNode returnNode = graph.add(new ReturnNode(null));
    merge.setNext(returnNode);
    dumpGraph(graph);
    ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
    Block[] blocks = cfg.getBlocks();
    // check number of blocks
    assertDeepEquals(4, blocks.length);
    // check block - node assignment
    assertDeepEquals(blocks[0], cfg.blockFor(graph.start()));
    assertDeepEquals(blocks[0], cfg.blockFor(ifNode));
    assertDeepEquals(blocks[1], cfg.blockFor(trueBegin));
    assertDeepEquals(blocks[1], cfg.blockFor(trueEnd));
    assertDeepEquals(blocks[2], cfg.blockFor(falseBegin));
    assertDeepEquals(blocks[2], cfg.blockFor(falseEnd));
    assertDeepEquals(blocks[3], cfg.blockFor(merge));
    assertDeepEquals(blocks[3], cfg.blockFor(returnNode));
    // check dominators
    assertDominator(blocks[0], null);
    assertDominator(blocks[1], blocks[0]);
    assertDominator(blocks[2], blocks[0]);
    assertDominator(blocks[3], blocks[0]);
    // check dominated
    assertDominatedSize(blocks[0], 3);
    assertDominatedSize(blocks[1], 0);
    assertDominatedSize(blocks[2], 0);
    assertDominatedSize(blocks[3], 0);
    // check postdominators
    assertPostdominator(blocks[0], blocks[3]);
    assertPostdominator(blocks[1], blocks[3]);
    assertPostdominator(blocks[2], blocks[3]);
    assertPostdominator(blocks[3], null);
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) DebugContext(org.graalvm.compiler.debug.DebugContext) IfNode(org.graalvm.compiler.nodes.IfNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) GraalDebugHandlersFactory(org.graalvm.compiler.printer.GraalDebugHandlersFactory) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) EndNode(org.graalvm.compiler.nodes.EndNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) ControlFlowGraph(org.graalvm.compiler.nodes.cfg.ControlFlowGraph) Block(org.graalvm.compiler.nodes.cfg.Block) Test(org.junit.Test)

Example 8 with MergeNode

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

the class BytecodeParser method parseAndInlineCallee.

protected void parseAndInlineCallee(ResolvedJavaMethod targetMethod, ValueNode[] args, IntrinsicContext calleeIntrinsicContext) {
    FixedWithNextNode calleeBeforeUnwindNode = null;
    ValueNode calleeUnwindValue = null;
    try (IntrinsicScope s = calleeIntrinsicContext != null && !parsingIntrinsic() ? new IntrinsicScope(this, targetMethod.getSignature().toParameterKinds(!targetMethod.isStatic()), args) : null) {
        BytecodeParser parser = graphBuilderInstance.createBytecodeParser(graph, this, targetMethod, INVOCATION_ENTRY_BCI, calleeIntrinsicContext);
        FrameStateBuilder startFrameState = new FrameStateBuilder(parser, parser.code, graph);
        if (!targetMethod.isStatic()) {
            args[0] = nullCheckedValue(args[0]);
        }
        startFrameState.initializeFromArgumentsArray(args);
        parser.build(this.lastInstr, startFrameState);
        if (parser.returnDataList == null) {
            /* Callee does not return. */
            lastInstr = null;
        } else {
            ValueNode calleeReturnValue;
            MergeNode returnMergeNode = null;
            if (s != null) {
                s.returnDataList = parser.returnDataList;
            }
            if (parser.returnDataList.size() == 1) {
                /* Callee has a single return, we can continue parsing at that point. */
                ReturnToCallerData singleReturnData = parser.returnDataList.get(0);
                lastInstr = singleReturnData.beforeReturnNode;
                calleeReturnValue = singleReturnData.returnValue;
            } else {
                assert parser.returnDataList.size() > 1;
                /* Callee has multiple returns, we need to insert a control flow merge. */
                returnMergeNode = graph.add(new MergeNode());
                calleeReturnValue = ValueMergeUtil.mergeValueProducers(returnMergeNode, parser.returnDataList, returnData -> returnData.beforeReturnNode, returnData -> returnData.returnValue);
            }
            if (calleeReturnValue != null) {
                frameState.push(targetMethod.getSignature().getReturnKind().getStackKind(), calleeReturnValue);
            }
            if (returnMergeNode != null) {
                returnMergeNode.setStateAfter(createFrameState(stream.nextBCI(), returnMergeNode));
                lastInstr = finishInstruction(returnMergeNode, frameState);
            }
        }
        /*
             * Propagate any side effects into the caller when parsing intrinsics.
             */
        if (parser.frameState.isAfterSideEffect() && parsingIntrinsic()) {
            for (StateSplit sideEffect : parser.frameState.sideEffects()) {
                frameState.addSideEffect(sideEffect);
            }
        }
        calleeBeforeUnwindNode = parser.getBeforeUnwindNode();
        if (calleeBeforeUnwindNode != null) {
            calleeUnwindValue = parser.getUnwindValue();
            assert calleeUnwindValue != null;
        }
    }
    /*
         * Method handleException will call createTarget, which wires this exception edge to the
         * corresponding exception dispatch block in the caller. In the case where it wires to the
         * caller's unwind block, any FrameState created meanwhile, e.g., FrameState for
         * LoopExitNode, would be instantiated with AFTER_EXCEPTION_BCI. Such frame states should
         * not be fixed by IntrinsicScope.close, as they denote the states of the caller. Thus, the
         * following code should be placed outside the IntrinsicScope, so that correctly created
         * FrameStates are not replaced.
         */
    if (calleeBeforeUnwindNode != null) {
        calleeBeforeUnwindNode.setNext(handleException(calleeUnwindValue, bci(), false));
    }
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) LOR(org.graalvm.compiler.bytecode.Bytecodes.LOR) JavaTypeProfile(jdk.vm.ci.meta.JavaTypeProfile) LDC2_W(org.graalvm.compiler.bytecode.Bytecodes.LDC2_W) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) IFEQ(org.graalvm.compiler.bytecode.Bytecodes.IFEQ) FCMPG(org.graalvm.compiler.bytecode.Bytecodes.FCMPG) StampFactory.objectNonNull(org.graalvm.compiler.core.common.type.StampFactory.objectNonNull) ConstantPool(jdk.vm.ci.meta.ConstantPool) DUP_X1(org.graalvm.compiler.bytecode.Bytecodes.DUP_X1) DUP_X2(org.graalvm.compiler.bytecode.Bytecodes.DUP_X2) GETSTATIC(org.graalvm.compiler.bytecode.Bytecodes.GETSTATIC) IFGE(org.graalvm.compiler.bytecode.Bytecodes.IFGE) IMUL(org.graalvm.compiler.bytecode.Bytecodes.IMUL) LOOKUPSWITCH(org.graalvm.compiler.bytecode.Bytecodes.LOOKUPSWITCH) DNEG(org.graalvm.compiler.bytecode.Bytecodes.DNEG) FCMPL(org.graalvm.compiler.bytecode.Bytecodes.FCMPL) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) ExceptionDispatchBlock(org.graalvm.compiler.java.BciBlockMapping.ExceptionDispatchBlock) AnchoringNode(org.graalvm.compiler.nodes.extended.AnchoringNode) LoadMethodNode(org.graalvm.compiler.nodes.extended.LoadMethodNode) ResolveClassBeforeStaticInvoke(org.graalvm.compiler.core.common.GraalOptions.ResolveClassBeforeStaticInvoke) Bytecodes.nameOf(org.graalvm.compiler.bytecode.Bytecodes.nameOf) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) LSUB(org.graalvm.compiler.bytecode.Bytecodes.LSUB) GraalError.shouldNotReachHere(org.graalvm.compiler.debug.GraalError.shouldNotReachHere) NEWARRAY(org.graalvm.compiler.bytecode.Bytecodes.NEWARRAY) FADD(org.graalvm.compiler.bytecode.Bytecodes.FADD) FixedNode(org.graalvm.compiler.nodes.FixedNode) Unresolved(jdk.vm.ci.meta.DeoptimizationReason.Unresolved) ALOAD(org.graalvm.compiler.bytecode.Bytecodes.ALOAD) FloatConvert(org.graalvm.compiler.core.common.calc.FloatConvert) LineNumberTable(jdk.vm.ci.meta.LineNumberTable) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) FDIV(org.graalvm.compiler.bytecode.Bytecodes.FDIV) ICONST_0(org.graalvm.compiler.bytecode.Bytecodes.ICONST_0) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) ICONST_2(org.graalvm.compiler.bytecode.Bytecodes.ICONST_2) ICONST_1(org.graalvm.compiler.bytecode.Bytecodes.ICONST_1) ARRAYLENGTH(org.graalvm.compiler.bytecode.Bytecodes.ARRAYLENGTH) ICONST_4(org.graalvm.compiler.bytecode.Bytecodes.ICONST_4) FREM(org.graalvm.compiler.bytecode.Bytecodes.FREM) ICONST_3(org.graalvm.compiler.bytecode.Bytecodes.ICONST_3) ICONST_5(org.graalvm.compiler.bytecode.Bytecodes.ICONST_5) SignedDivNode(org.graalvm.compiler.nodes.calc.SignedDivNode) BytecodeTableSwitch(org.graalvm.compiler.bytecode.BytecodeTableSwitch) InvocationPluginReceiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.InvocationPluginReceiver) INLINE_DURING_PARSING(org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_DURING_PARSING) ILOAD(org.graalvm.compiler.bytecode.Bytecodes.ILOAD) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) L2D(org.graalvm.compiler.bytecode.Bytecodes.L2D) L2F(org.graalvm.compiler.bytecode.Bytecodes.L2F) InvalidateRecompile(jdk.vm.ci.meta.DeoptimizationAction.InvalidateRecompile) EconomicMap(org.graalvm.collections.EconomicMap) L2I(org.graalvm.compiler.bytecode.Bytecodes.L2I) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) PUTSTATIC(org.graalvm.compiler.bytecode.Bytecodes.PUTSTATIC) FCONST_2(org.graalvm.compiler.bytecode.Bytecodes.FCONST_2) TTY(org.graalvm.compiler.debug.TTY) BREAKPOINT(org.graalvm.compiler.bytecode.Bytecodes.BREAKPOINT) HotSpotPrintInlining(org.graalvm.compiler.core.common.GraalOptions.HotSpotPrintInlining) GraphUtil(org.graalvm.compiler.nodes.util.GraphUtil) FCONST_0(org.graalvm.compiler.bytecode.Bytecodes.FCONST_0) FCONST_1(org.graalvm.compiler.bytecode.Bytecodes.FCONST_1) ResolvedJavaMethodBytecode(org.graalvm.compiler.bytecode.ResolvedJavaMethodBytecode) PrintProfilingInformation(org.graalvm.compiler.core.common.GraalOptions.PrintProfilingInformation) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) LRETURN(org.graalvm.compiler.bytecode.Bytecodes.LRETURN) TraceInlineDuringParsing(org.graalvm.compiler.java.BytecodeParserOptions.TraceInlineDuringParsing) CodeUtil(jdk.vm.ci.code.CodeUtil) Signature(jdk.vm.ci.meta.Signature) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) IOR(org.graalvm.compiler.bytecode.Bytecodes.IOR) UseGuardedIntrinsics(org.graalvm.compiler.java.BytecodeParserOptions.UseGuardedIntrinsics) CASTORE(org.graalvm.compiler.bytecode.Bytecodes.CASTORE) Assertions(org.graalvm.compiler.debug.Assertions) InvokeKind(org.graalvm.compiler.nodes.CallTargetNode.InvokeKind) XorNode(org.graalvm.compiler.nodes.calc.XorNode) LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) INVOKEVIRTUAL(org.graalvm.compiler.bytecode.Bytecodes.INVOKEVIRTUAL) ClassInitializationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin) DebugContext(org.graalvm.compiler.debug.DebugContext) NullCheckException(jdk.vm.ci.meta.DeoptimizationReason.NullCheckException) IINC(org.graalvm.compiler.bytecode.Bytecodes.IINC) StampTool.isPointerNonNull(org.graalvm.compiler.nodes.type.StampTool.isPointerNonNull) SYNCHRONIZED(java.lang.reflect.Modifier.SYNCHRONIZED) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) IFGT(org.graalvm.compiler.bytecode.Bytecodes.IFGT) FSTORE(org.graalvm.compiler.bytecode.Bytecodes.FSTORE) Equivalence(org.graalvm.collections.Equivalence) InvalidateReprofile(jdk.vm.ci.meta.DeoptimizationAction.InvalidateReprofile) SIPUSH(org.graalvm.compiler.bytecode.Bytecodes.SIPUSH) LLOAD_2(org.graalvm.compiler.bytecode.Bytecodes.LLOAD_2) BASTORE(org.graalvm.compiler.bytecode.Bytecodes.BASTORE) LLOAD_1(org.graalvm.compiler.bytecode.Bytecodes.LLOAD_1) LLOAD_0(org.graalvm.compiler.bytecode.Bytecodes.LLOAD_0) StampPair(org.graalvm.compiler.core.common.type.StampPair) LLOAD_3(org.graalvm.compiler.bytecode.Bytecodes.LLOAD_3) CALOAD(org.graalvm.compiler.bytecode.Bytecodes.CALOAD) ProfilingPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ProfilingPlugin) BytecodeExceptionNode(org.graalvm.compiler.nodes.extended.BytecodeExceptionNode) POP(org.graalvm.compiler.bytecode.Bytecodes.POP) LNEG(org.graalvm.compiler.bytecode.Bytecodes.LNEG) BALOAD(org.graalvm.compiler.bytecode.Bytecodes.BALOAD) FMUL(org.graalvm.compiler.bytecode.Bytecodes.FMUL) SWAP(org.graalvm.compiler.bytecode.Bytecodes.SWAP) UnsignedRightShiftNode(org.graalvm.compiler.nodes.calc.UnsignedRightShiftNode) RuntimeConstraint(jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint) IFNONNULL(org.graalvm.compiler.bytecode.Bytecodes.IFNONNULL) BeginNode(org.graalvm.compiler.nodes.BeginNode) IntegerLessThanNode(org.graalvm.compiler.nodes.calc.IntegerLessThanNode) NegateNode(org.graalvm.compiler.nodes.calc.NegateNode) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) INVOKEINTERFACE(org.graalvm.compiler.bytecode.Bytecodes.INVOKEINTERFACE) DADD(org.graalvm.compiler.bytecode.Bytecodes.DADD) DREM(org.graalvm.compiler.bytecode.Bytecodes.DREM) EntryProxyNode(org.graalvm.compiler.nodes.EntryProxyNode) ACONST_NULL(org.graalvm.compiler.bytecode.Bytecodes.ACONST_NULL) Stamp(org.graalvm.compiler.core.common.type.Stamp) DLOAD_0(org.graalvm.compiler.bytecode.Bytecodes.DLOAD_0) BytecodeLookupSwitch(org.graalvm.compiler.bytecode.BytecodeLookupSwitch) DDIV(org.graalvm.compiler.bytecode.Bytecodes.DDIV) DLOAD_2(org.graalvm.compiler.bytecode.Bytecodes.DLOAD_2) DLOAD_1(org.graalvm.compiler.bytecode.Bytecodes.DLOAD_1) BytecodeDisassembler(org.graalvm.compiler.bytecode.BytecodeDisassembler) DLOAD_3(org.graalvm.compiler.bytecode.Bytecodes.DLOAD_3) IRETURN(org.graalvm.compiler.bytecode.Bytecodes.IRETURN) RETURN(org.graalvm.compiler.bytecode.Bytecodes.RETURN) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) IntrinsicContext(org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext) GraalError.guarantee(org.graalvm.compiler.debug.GraalError.guarantee) ASTORE(org.graalvm.compiler.bytecode.Bytecodes.ASTORE) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) GOTO(org.graalvm.compiler.bytecode.Bytecodes.GOTO) OptimisticOptimizations(org.graalvm.compiler.phases.OptimisticOptimizations) LCMP(org.graalvm.compiler.bytecode.Bytecodes.LCMP) ArrayList(java.util.ArrayList) IFNULL(org.graalvm.compiler.bytecode.Bytecodes.IFNULL) TypeReference(org.graalvm.compiler.core.common.type.TypeReference) BIPUSH(org.graalvm.compiler.bytecode.Bytecodes.BIPUSH) MULTIANEWARRAY(org.graalvm.compiler.bytecode.Bytecodes.MULTIANEWARRAY) STATIC(java.lang.reflect.Modifier.STATIC) ASTORE_0(org.graalvm.compiler.bytecode.Bytecodes.ASTORE_0) ProfilingInfo(jdk.vm.ci.meta.ProfilingInfo) ASTORE_2(org.graalvm.compiler.bytecode.Bytecodes.ASTORE_2) ASTORE_1(org.graalvm.compiler.bytecode.Bytecodes.ASTORE_1) ASTORE_3(org.graalvm.compiler.bytecode.Bytecodes.ASTORE_3) DRETURN(org.graalvm.compiler.bytecode.Bytecodes.DRETURN) CanonicalCondition(org.graalvm.compiler.core.common.calc.CanonicalCondition) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ILOAD_0(org.graalvm.compiler.bytecode.Bytecodes.ILOAD_0) ConstantFieldProvider(org.graalvm.compiler.core.common.spi.ConstantFieldProvider) RawConstant(jdk.vm.ci.meta.RawConstant) ILOAD_1(org.graalvm.compiler.bytecode.Bytecodes.ILOAD_1) ILOAD_2(org.graalvm.compiler.bytecode.Bytecodes.ILOAD_2) ILOAD_3(org.graalvm.compiler.bytecode.Bytecodes.ILOAD_3) SLOW_PATH_PROBABILITY(org.graalvm.compiler.nodes.extended.BranchProbabilityNode.SLOW_PATH_PROBABILITY) InlineInfo(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo) StateSplitProxyNode(org.graalvm.compiler.nodes.extended.StateSplitProxyNode) NOP(org.graalvm.compiler.bytecode.Bytecodes.NOP) DeoptimizationReason(jdk.vm.ci.meta.DeoptimizationReason) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) LASTORE(org.graalvm.compiler.bytecode.Bytecodes.LASTORE) Formatter(java.util.Formatter) IF_ACMPNE(org.graalvm.compiler.bytecode.Bytecodes.IF_ACMPNE) StampFactory(org.graalvm.compiler.core.common.type.StampFactory) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) FloatConvertNode(org.graalvm.compiler.nodes.calc.FloatConvertNode) NewMultiArrayNode(org.graalvm.compiler.nodes.java.NewMultiArrayNode) FSTORE_1(org.graalvm.compiler.bytecode.Bytecodes.FSTORE_1) FSTORE_0(org.graalvm.compiler.bytecode.Bytecodes.FSTORE_0) INVOKESTATIC(org.graalvm.compiler.bytecode.Bytecodes.INVOKESTATIC) ANEWARRAY(org.graalvm.compiler.bytecode.Bytecodes.ANEWARRAY) StressInvokeWithExceptionNode(org.graalvm.compiler.core.common.GraalOptions.StressInvokeWithExceptionNode) PiNode(org.graalvm.compiler.nodes.PiNode) FSTORE_3(org.graalvm.compiler.bytecode.Bytecodes.FSTORE_3) FSTORE_2(org.graalvm.compiler.bytecode.Bytecodes.FSTORE_2) ValueNode(org.graalvm.compiler.nodes.ValueNode) List(java.util.List) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) LCONST_1(org.graalvm.compiler.bytecode.Bytecodes.LCONST_1) LCONST_0(org.graalvm.compiler.bytecode.Bytecodes.LCONST_0) GraalError(org.graalvm.compiler.debug.GraalError) DUP2(org.graalvm.compiler.bytecode.Bytecodes.DUP2) SALOAD(org.graalvm.compiler.bytecode.Bytecodes.SALOAD) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) PermanentBailoutException(org.graalvm.compiler.core.common.PermanentBailoutException) GeneratePIC(org.graalvm.compiler.core.common.GraalOptions.GeneratePIC) IUSHR(org.graalvm.compiler.bytecode.Bytecodes.IUSHR) ResolvedJavaMethodBytecodeProvider(org.graalvm.compiler.bytecode.ResolvedJavaMethodBytecodeProvider) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) StampTool(org.graalvm.compiler.nodes.type.StampTool) Condition(org.graalvm.compiler.core.common.calc.Condition) IASTORE(org.graalvm.compiler.bytecode.Bytecodes.IASTORE) TraceBytecodeParserLevel(org.graalvm.compiler.java.BytecodeParserOptions.TraceBytecodeParserLevel) InlinePartialIntrinsicExitDuringParsing(org.graalvm.compiler.java.BytecodeParserOptions.InlinePartialIntrinsicExitDuringParsing) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) LALOAD(org.graalvm.compiler.bytecode.Bytecodes.LALOAD) FLOAD_3(org.graalvm.compiler.bytecode.Bytecodes.FLOAD_3) Bytecodes(org.graalvm.compiler.bytecode.Bytecodes) FLOAD_1(org.graalvm.compiler.bytecode.Bytecodes.FLOAD_1) EndNode(org.graalvm.compiler.nodes.EndNode) FLOAD_2(org.graalvm.compiler.bytecode.Bytecodes.FLOAD_2) LAND(org.graalvm.compiler.bytecode.Bytecodes.LAND) FLOAD_0(org.graalvm.compiler.bytecode.Bytecodes.FLOAD_0) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ALOAD_1(org.graalvm.compiler.bytecode.Bytecodes.ALOAD_1) ALOAD_0(org.graalvm.compiler.bytecode.Bytecodes.ALOAD_0) LDIV(org.graalvm.compiler.bytecode.Bytecodes.LDIV) LocationIdentity(org.graalvm.word.LocationIdentity) DSTORE(org.graalvm.compiler.bytecode.Bytecodes.DSTORE) IF_ICMPGT(org.graalvm.compiler.bytecode.Bytecodes.IF_ICMPGT) INVOKESPECIAL(org.graalvm.compiler.bytecode.Bytecodes.INVOKESPECIAL) NormalizeCompareNode(org.graalvm.compiler.nodes.calc.NormalizeCompareNode) F2L(org.graalvm.compiler.bytecode.Bytecodes.F2L) AndNode(org.graalvm.compiler.nodes.calc.AndNode) F2I(org.graalvm.compiler.bytecode.Bytecodes.F2I) IF_ICMPGE(org.graalvm.compiler.bytecode.Bytecodes.IF_ICMPGE) INEG(org.graalvm.compiler.bytecode.Bytecodes.INEG) JavaSubroutineMismatch(jdk.vm.ci.meta.DeoptimizationReason.JavaSubroutineMismatch) RegisterFinalizerNode(org.graalvm.compiler.nodes.java.RegisterFinalizerNode) MONITOREXIT(org.graalvm.compiler.bytecode.Bytecodes.MONITOREXIT) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition) F2D(org.graalvm.compiler.bytecode.Bytecodes.F2D) OrNode(org.graalvm.compiler.nodes.calc.OrNode) FRETURN(org.graalvm.compiler.bytecode.Bytecodes.FRETURN) INVOCATION_ENTRY_BCI(jdk.vm.ci.runtime.JVMCICompiler.INVOCATION_ENTRY_BCI) LREM(org.graalvm.compiler.bytecode.Bytecodes.LREM) Snippet(org.graalvm.compiler.api.replacements.Snippet) FrameState(org.graalvm.compiler.nodes.FrameState) ObjectEqualsNode(org.graalvm.compiler.nodes.calc.ObjectEqualsNode) LADD(org.graalvm.compiler.bytecode.Bytecodes.LADD) MulNode(org.graalvm.compiler.nodes.calc.MulNode) ALOAD_3(org.graalvm.compiler.bytecode.Bytecodes.ALOAD_3) ALOAD_2(org.graalvm.compiler.bytecode.Bytecodes.ALOAD_2) GraalOptions(org.graalvm.compiler.core.common.GraalOptions) IF_ICMPEQ(org.graalvm.compiler.bytecode.Bytecodes.IF_ICMPEQ) IntegerEqualsNode(org.graalvm.compiler.nodes.calc.IntegerEqualsNode) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) PUTFIELD(org.graalvm.compiler.bytecode.Bytecodes.PUTFIELD) LLOAD(org.graalvm.compiler.bytecode.Bytecodes.LLOAD) MergeNode(org.graalvm.compiler.nodes.MergeNode) AALOAD(org.graalvm.compiler.bytecode.Bytecodes.AALOAD) DeoptALot(org.graalvm.compiler.core.common.GraalOptions.DeoptALot) LXOR(org.graalvm.compiler.bytecode.Bytecodes.LXOR) FASTORE(org.graalvm.compiler.bytecode.Bytecodes.FASTORE) CHECKCAST(org.graalvm.compiler.bytecode.Bytecodes.CHECKCAST) TypeCheckedInliningViolated(jdk.vm.ci.meta.DeoptimizationReason.TypeCheckedInliningViolated) ValueAnchorNode(org.graalvm.compiler.nodes.extended.ValueAnchorNode) ICONST_M1(org.graalvm.compiler.bytecode.Bytecodes.ICONST_M1) D2L(org.graalvm.compiler.bytecode.Bytecodes.D2L) GOTO_W(org.graalvm.compiler.bytecode.Bytecodes.GOTO_W) D2I(org.graalvm.compiler.bytecode.Bytecodes.D2I) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) IfNode(org.graalvm.compiler.nodes.IfNode) DASTORE(org.graalvm.compiler.bytecode.Bytecodes.DASTORE) ISUB(org.graalvm.compiler.bytecode.Bytecodes.ISUB) D2F(org.graalvm.compiler.bytecode.Bytecodes.D2F) DSTORE_1(org.graalvm.compiler.bytecode.Bytecodes.DSTORE_1) LSTORE_2(org.graalvm.compiler.bytecode.Bytecodes.LSTORE_2) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) DSTORE_0(org.graalvm.compiler.bytecode.Bytecodes.DSTORE_0) IF_ACMPEQ(org.graalvm.compiler.bytecode.Bytecodes.IF_ACMPEQ) LSTORE_3(org.graalvm.compiler.bytecode.Bytecodes.LSTORE_3) DSTORE_3(org.graalvm.compiler.bytecode.Bytecodes.DSTORE_3) LSTORE_0(org.graalvm.compiler.bytecode.Bytecodes.LSTORE_0) DSTORE_2(org.graalvm.compiler.bytecode.Bytecodes.DSTORE_2) LSTORE_1(org.graalvm.compiler.bytecode.Bytecodes.LSTORE_1) SignedRemNode(org.graalvm.compiler.nodes.calc.SignedRemNode) NEW(org.graalvm.compiler.bytecode.Bytecodes.NEW) FAST_PATH_PROBABILITY(org.graalvm.compiler.nodes.extended.BranchProbabilityNode.FAST_PATH_PROBABILITY) NodeIterable(org.graalvm.compiler.graph.iterators.NodeIterable) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) LDC_W(org.graalvm.compiler.bytecode.Bytecodes.LDC_W) AASTORE(org.graalvm.compiler.bytecode.Bytecodes.AASTORE) Util(org.graalvm.compiler.core.common.util.Util) DLOAD(org.graalvm.compiler.bytecode.Bytecodes.DLOAD) BranchProbabilityNode(org.graalvm.compiler.nodes.extended.BranchProbabilityNode) Bytes(org.graalvm.compiler.bytecode.Bytes) StartNode(org.graalvm.compiler.nodes.StartNode) BailoutException(jdk.vm.ci.code.BailoutException) LSTORE(org.graalvm.compiler.bytecode.Bytecodes.LSTORE) BeginStateSplitNode(org.graalvm.compiler.nodes.BeginStateSplitNode) RemNode(org.graalvm.compiler.nodes.calc.RemNode) DMUL(org.graalvm.compiler.bytecode.Bytecodes.DMUL) IAND(org.graalvm.compiler.bytecode.Bytecodes.IAND) DUP(org.graalvm.compiler.bytecode.Bytecodes.DUP) LSHR(org.graalvm.compiler.bytecode.Bytecodes.LSHR) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) INSTANCEOF(org.graalvm.compiler.bytecode.Bytecodes.INSTANCEOF) DUP2_X2(org.graalvm.compiler.bytecode.Bytecodes.DUP2_X2) DUP2_X1(org.graalvm.compiler.bytecode.Bytecodes.DUP2_X1) LSHL(org.graalvm.compiler.bytecode.Bytecodes.LSHL) CanonicalizedCondition(org.graalvm.compiler.core.common.calc.Condition.CanonicalizedCondition) StoreIndexedNode(org.graalvm.compiler.nodes.java.StoreIndexedNode) LDC(org.graalvm.compiler.bytecode.Bytecodes.LDC) SubNode(org.graalvm.compiler.nodes.calc.SubNode) ClassCastException(jdk.vm.ci.meta.DeoptimizationReason.ClassCastException) ARETURN(org.graalvm.compiler.bytecode.Bytecodes.ARETURN) StressExplicitExceptionCode(org.graalvm.compiler.core.common.GraalOptions.StressExplicitExceptionCode) Invoke(org.graalvm.compiler.nodes.Invoke) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) Node(org.graalvm.compiler.graph.Node) Comparator(java.util.Comparator) IALOAD(org.graalvm.compiler.bytecode.Bytecodes.IALOAD) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) LogicNegationNode(org.graalvm.compiler.nodes.LogicNegationNode) IADD(org.graalvm.compiler.bytecode.Bytecodes.IADD) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) GETFIELD(org.graalvm.compiler.bytecode.Bytecodes.GETFIELD) IREM(org.graalvm.compiler.bytecode.Bytecodes.IREM) BytecodeStream(org.graalvm.compiler.bytecode.BytecodeStream) IFNE(org.graalvm.compiler.bytecode.Bytecodes.IFNE) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) None(jdk.vm.ci.meta.DeoptimizationAction.None) IDIV(org.graalvm.compiler.bytecode.Bytecodes.IDIV) JSR(org.graalvm.compiler.bytecode.Bytecodes.JSR) LUSHR(org.graalvm.compiler.bytecode.Bytecodes.LUSHR) DALOAD(org.graalvm.compiler.bytecode.Bytecodes.DALOAD) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) JavaMethod(jdk.vm.ci.meta.JavaMethod) InvokeDynamicPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvokeDynamicPlugin) INVOKEDYNAMIC(org.graalvm.compiler.bytecode.Bytecodes.INVOKEDYNAMIC) NodeView(org.graalvm.compiler.nodes.NodeView) ISHL(org.graalvm.compiler.bytecode.Bytecodes.ISHL) JavaType(jdk.vm.ci.meta.JavaType) ISHR(org.graalvm.compiler.bytecode.Bytecodes.ISHR) FLOAD(org.graalvm.compiler.bytecode.Bytecodes.FLOAD) FloatDivNode(org.graalvm.compiler.nodes.calc.FloatDivNode) DSUB(org.graalvm.compiler.bytecode.Bytecodes.DSUB) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) KillingBeginNode(org.graalvm.compiler.nodes.KillingBeginNode) I2S(org.graalvm.compiler.bytecode.Bytecodes.I2S) IFLT(org.graalvm.compiler.bytecode.Bytecodes.IFLT) IF_ICMPNE(org.graalvm.compiler.bytecode.Bytecodes.IF_ICMPNE) StateSplit(org.graalvm.compiler.nodes.StateSplit) IFLE(org.graalvm.compiler.bytecode.Bytecodes.IFLE) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) I2C(org.graalvm.compiler.bytecode.Bytecodes.I2C) IXOR(org.graalvm.compiler.bytecode.Bytecodes.IXOR) TriState(jdk.vm.ci.meta.TriState) I2D(org.graalvm.compiler.bytecode.Bytecodes.I2D) MONITORENTER(org.graalvm.compiler.bytecode.Bytecodes.MONITORENTER) I2F(org.graalvm.compiler.bytecode.Bytecodes.I2F) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) I2L(org.graalvm.compiler.bytecode.Bytecodes.I2L) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) IntegerBelowNode(org.graalvm.compiler.nodes.calc.IntegerBelowNode) ISTORE_0(org.graalvm.compiler.bytecode.Bytecodes.ISTORE_0) ValueMergeUtil(org.graalvm.compiler.phases.util.ValueMergeUtil) JavaField(jdk.vm.ci.meta.JavaField) I2B(org.graalvm.compiler.bytecode.Bytecodes.I2B) ISTORE_3(org.graalvm.compiler.bytecode.Bytecodes.ISTORE_3) ISTORE_1(org.graalvm.compiler.bytecode.Bytecodes.ISTORE_1) ISTORE_2(org.graalvm.compiler.bytecode.Bytecodes.ISTORE_2) SASTORE(org.graalvm.compiler.bytecode.Bytecodes.SASTORE) FNEG(org.graalvm.compiler.bytecode.Bytecodes.FNEG) ATHROW(org.graalvm.compiler.bytecode.Bytecodes.ATHROW) Indent(org.graalvm.compiler.debug.Indent) NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) POP2(org.graalvm.compiler.bytecode.Bytecodes.POP2) FSUB(org.graalvm.compiler.bytecode.Bytecodes.FSUB) IF_ICMPLE(org.graalvm.compiler.bytecode.Bytecodes.IF_ICMPLE) BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) DeoptimizationAction(jdk.vm.ci.meta.DeoptimizationAction) JSR_W(org.graalvm.compiler.bytecode.Bytecodes.JSR_W) NarrowNode(org.graalvm.compiler.nodes.calc.NarrowNode) BciBlock(org.graalvm.compiler.java.BciBlockMapping.BciBlock) JavaKind(jdk.vm.ci.meta.JavaKind) ISTORE(org.graalvm.compiler.bytecode.Bytecodes.ISTORE) DCONST_1(org.graalvm.compiler.bytecode.Bytecodes.DCONST_1) DCONST_0(org.graalvm.compiler.bytecode.Bytecodes.DCONST_0) BytecodeSwitch(org.graalvm.compiler.bytecode.BytecodeSwitch) Mark(org.graalvm.compiler.graph.Graph.Mark) ConstantReflectionProvider(jdk.vm.ci.meta.ConstantReflectionProvider) EntryMarkerNode(org.graalvm.compiler.nodes.EntryMarkerNode) CounterKey(org.graalvm.compiler.debug.CounterKey) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) String.format(java.lang.String.format) FinalFieldBarrierNode(org.graalvm.compiler.nodes.java.FinalFieldBarrierNode) Bytecode(org.graalvm.compiler.bytecode.Bytecode) JavaConstant(jdk.vm.ci.meta.JavaConstant) LogicNode(org.graalvm.compiler.nodes.LogicNode) RET(org.graalvm.compiler.bytecode.Bytecodes.RET) TraceParserPlugins(org.graalvm.compiler.java.BytecodeParserOptions.TraceParserPlugins) IF_ICMPLT(org.graalvm.compiler.bytecode.Bytecodes.IF_ICMPLT) DCMPG(org.graalvm.compiler.bytecode.Bytecodes.DCMPG) LMUL(org.graalvm.compiler.bytecode.Bytecodes.LMUL) InlineInvokePlugin(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) RightShiftNode(org.graalvm.compiler.nodes.calc.RightShiftNode) UnreachedCode(jdk.vm.ci.meta.DeoptimizationReason.UnreachedCode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) DCMPL(org.graalvm.compiler.bytecode.Bytecodes.DCMPL) OptionValues(org.graalvm.compiler.options.OptionValues) BytecodeExceptionMode(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.BytecodeExceptionMode) TABLESWITCH(org.graalvm.compiler.bytecode.Bytecodes.TABLESWITCH) ArrayLengthNode(org.graalvm.compiler.nodes.java.ArrayLengthNode) InfopointReason(jdk.vm.ci.code.site.InfopointReason) ProfiledType(jdk.vm.ci.meta.JavaTypeProfile.ProfiledType) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) MonitorEnterNode(org.graalvm.compiler.nodes.java.MonitorEnterNode) StampProvider(org.graalvm.compiler.nodes.spi.StampProvider) FALOAD(org.graalvm.compiler.bytecode.Bytecodes.FALOAD) Collections(java.util.Collections) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) StateSplit(org.graalvm.compiler.nodes.StateSplit)

Example 9 with MergeNode

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

the class BytecodeParser method afterInvocationPluginExecution.

/**
 * Performs any action required after execution of an invocation plugin. This includes
 * {@linkplain InvocationPluginAssertions#check checking} invocation plugin invariants as well
 * as weaving the {@code else} branch of the code woven by {@link #guardIntrinsic} if
 * {@code guard != null}.
 */
protected void afterInvocationPluginExecution(boolean pluginHandledInvoke, InvocationPluginAssertions assertions, IntrinsicGuard intrinsicGuard, InvokeKind invokeKind, ValueNode[] args, ResolvedJavaMethod targetMethod, JavaKind resultType, JavaType returnType) {
    assert assertions.check(pluginHandledInvoke);
    if (intrinsicGuard != null) {
        if (pluginHandledInvoke) {
            if (intrinsicGuard.nonIntrinsicBranch != null) {
                // Intrinsic emitted: emit a virtual call to the target method and
                // merge it with the intrinsic branch
                EndNode intrinsicEnd = append(new EndNode());
                FrameStateBuilder intrinsicState = null;
                FrameStateBuilder nonIntrinisicState = null;
                if (resultType != JavaKind.Void) {
                    intrinsicState = frameState.copy();
                    frameState.pop(resultType);
                    nonIntrinisicState = frameState;
                }
                lastInstr = intrinsicGuard.nonIntrinsicBranch;
                createNonInlinedInvoke(getActionForInvokeExceptionEdge(null), bci(), args, targetMethod, invokeKind, resultType, returnType, intrinsicGuard.profile);
                EndNode nonIntrinsicEnd = append(new EndNode());
                AbstractMergeNode mergeNode = graph.add(new MergeNode());
                mergeNode.addForwardEnd(intrinsicEnd);
                if (intrinsicState != null) {
                    intrinsicState.merge(mergeNode, nonIntrinisicState);
                    frameState = intrinsicState;
                }
                mergeNode.addForwardEnd(nonIntrinsicEnd);
                mergeNode.setStateAfter(frameState.create(stream.nextBCI(), mergeNode));
                lastInstr = mergeNode;
            }
        } else {
            // Intrinsic was not applied: remove intrinsic guard
            // and restore the original receiver node in the arguments array
            intrinsicGuard.lastInstr.setNext(null);
            GraphUtil.removeNewNodes(graph, intrinsicGuard.mark);
            lastInstr = intrinsicGuard.lastInstr;
            args[0] = intrinsicGuard.receiver;
        }
    }
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) EndNode(org.graalvm.compiler.nodes.EndNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode)

Example 10 with MergeNode

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

the class BytecodeParser method iterateBytecodesForBlock.

@SuppressWarnings("try")
protected void iterateBytecodesForBlock(BciBlock block) {
    if (block.isLoopHeader) {
        // Create the loop header block, which later will merge the backward branches of
        // the loop.
        controlFlowSplit = true;
        LoopBeginNode loopBegin = appendLoopBegin(this.lastInstr, block.startBci);
        lastInstr = loopBegin;
        // Create phi functions for all local variables and operand stack slots.
        frameState.insertLoopPhis(liveness, block.loopId, loopBegin, forceLoopPhis(), stampFromValueForForcedPhis());
        loopBegin.setStateAfter(createFrameState(block.startBci, loopBegin));
        /*
             * We have seen all forward branches. All subsequent backward branches will merge to the
             * loop header. This ensures that the loop header has exactly one non-loop predecessor.
             */
        setFirstInstruction(block, loopBegin);
        /*
             * We need to preserve the frame state builder of the loop header so that we can merge
             * values for phi functions, so make a copy of it.
             */
        setEntryState(block, frameState.copy());
        debug.log("  created loop header %s", loopBegin);
    } else if (lastInstr instanceof MergeNode) {
        /*
             * All inputs of non-loop phi nodes are known by now. We can infer the stamp for the
             * phi, so that parsing continues with more precise type information.
             */
        frameState.inferPhiStamps((AbstractMergeNode) lastInstr);
    }
    assert lastInstr.next() == null : "instructions already appended at block " + block;
    debug.log("  frameState: %s", frameState);
    lastInstr = finishInstruction(lastInstr, frameState);
    int endBCI = stream.endBCI();
    stream.setBCI(block.startBci);
    int bci = block.startBci;
    BytecodesParsed.add(debug, block.endBci - bci);
    /* Reset line number for new block */
    if (graphBuilderConfig.insertFullInfopoints()) {
        previousLineNumber = -1;
    }
    while (bci < endBCI) {
        try (DebugCloseable context = openNodeContext()) {
            if (graphBuilderConfig.insertFullInfopoints() && !parsingIntrinsic()) {
                currentLineNumber = lnt != null ? lnt.getLineNumber(bci) : -1;
                if (currentLineNumber != previousLineNumber) {
                    genInfoPointNode(InfopointReason.BYTECODE_POSITION, null);
                    previousLineNumber = currentLineNumber;
                }
            }
            // read the opcode
            int opcode = stream.currentBC();
            assert traceState();
            assert traceInstruction(bci, opcode, bci == block.startBci);
            if (parent == null && bci == entryBCI) {
                if (block.getJsrScope() != JsrScope.EMPTY_SCOPE) {
                    throw new JsrNotSupportedBailout("OSR into a JSR scope is not supported");
                }
                EntryMarkerNode x = append(new EntryMarkerNode());
                frameState.insertProxies(value -> graph.unique(new EntryProxyNode(value, x)));
                x.setStateAfter(createFrameState(bci, x));
            }
            processBytecode(bci, opcode);
        } catch (BailoutException e) {
            // Don't wrap bailouts as parser errors
            throw e;
        } catch (Throwable e) {
            throw throwParserError(e);
        }
        if (lastInstr == null || lastInstr.next() != null) {
            break;
        }
        stream.next();
        bci = stream.currentBCI();
        assert block == currentBlock;
        assert checkLastInstruction();
        lastInstr = finishInstruction(lastInstr, frameState);
        if (bci < endBCI) {
            if (bci > block.endBci) {
                assert !block.getSuccessor(0).isExceptionEntry;
                assert block.numNormalSuccessors() == 1;
                // we fell through to the next block, add a goto and break
                appendGoto(block.getSuccessor(0));
                break;
            }
        }
    }
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) EntryMarkerNode(org.graalvm.compiler.nodes.EntryMarkerNode) PermanentBailoutException(org.graalvm.compiler.core.common.PermanentBailoutException) BailoutException(jdk.vm.ci.code.BailoutException) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) RuntimeConstraint(jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint) EntryProxyNode(org.graalvm.compiler.nodes.EntryProxyNode)

Aggregations

MergeNode (org.graalvm.compiler.nodes.MergeNode)20 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)16 EndNode (org.graalvm.compiler.nodes.EndNode)14 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)13 FixedNode (org.graalvm.compiler.nodes.FixedNode)13 Node (org.graalvm.compiler.graph.Node)11 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)10 ValueNode (org.graalvm.compiler.nodes.ValueNode)9 BeginNode (org.graalvm.compiler.nodes.BeginNode)8 FrameState (org.graalvm.compiler.nodes.FrameState)7 IfNode (org.graalvm.compiler.nodes.IfNode)7 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)7 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)7 PhiNode (org.graalvm.compiler.nodes.PhiNode)6 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)5 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)5 InvokeNode (org.graalvm.compiler.nodes.InvokeNode)5 PiNode (org.graalvm.compiler.nodes.PiNode)5 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)5 ArrayList (java.util.ArrayList)4