Search in sources :

Example 1 with BailoutException

use of jdk.vm.ci.code.BailoutException in project graal by oracle.

the class CompilerAssertsTest method neverPartOfCompilationTest.

@Test
public void neverPartOfCompilationTest() {
    NeverPartOfCompilationTestNode result = new NeverPartOfCompilationTestNode();
    RootTestNode rootNode = new RootTestNode(new FrameDescriptor(), "neverPartOfCompilation", result);
    try {
        compileHelper("neverPartOfCompilation", rootNode, new Object[0]);
        Assert.fail("Expected bailout exception due to never part of compilation");
    } catch (BailoutException e) {
    // Bailout exception expected.
    }
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) BailoutException(jdk.vm.ci.code.BailoutException) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode) Test(org.junit.Test)

Example 2 with BailoutException

use of jdk.vm.ci.code.BailoutException in project graal by oracle.

the class TruffleCompilerImpl method notifyCompilableOfFailure.

private static void notifyCompilableOfFailure(CompilableTruffleAST compilable, Throwable e) {
    BailoutException bailout = e instanceof BailoutException ? (BailoutException) e : null;
    boolean permanentBailout = bailout != null ? bailout.isPermanent() : false;
    final Supplier<String> reasonAndStackTrace = new Supplier<String>() {

        @Override
        public String get() {
            StringWriter sw = new StringWriter();
            e.printStackTrace(new PrintWriter(sw));
            return sw.toString();
        }
    };
    compilable.onCompilationFailed(reasonAndStackTrace, bailout != null, permanentBailout);
}
Also used : CancellationBailoutException(org.graalvm.compiler.core.common.CancellationBailoutException) BailoutException(jdk.vm.ci.code.BailoutException) RetryableBailoutException(org.graalvm.compiler.core.common.RetryableBailoutException) StringWriter(java.io.StringWriter) Supplier(java.util.function.Supplier) PrintWriter(java.io.PrintWriter)

Example 3 with BailoutException

use of jdk.vm.ci.code.BailoutException in project graal by oracle.

the class UnbalancedMonitorsTest method checkForBailout.

private void checkForBailout(String name) throws ClassNotFoundException {
    ResolvedJavaMethod method = getResolvedJavaMethod(LOADER.findClass(INNER_CLASS_NAME), name);
    try {
        OptionValues options = getInitialOptions();
        StructuredGraph graph = new StructuredGraph.Builder(options, getDebugContext(options, null, method)).method(method).build();
        Plugins plugins = new Plugins(new InvocationPlugins());
        GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
        OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
        GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), null, null, graphBuilderConfig, optimisticOpts, null);
        graphBuilder.apply(graph);
    } catch (BailoutException e) {
        if (e.getMessage().contains("unbalanced monitors")) {
            return;
        }
        throw e;
    }
    assertTrue("should have bailed out", false);
}
Also used : BailoutException(jdk.vm.ci.code.BailoutException) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) OptimisticOptimizations(org.graalvm.compiler.phases.OptimisticOptimizations) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 4 with BailoutException

use of jdk.vm.ci.code.BailoutException 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)

Example 5 with BailoutException

use of jdk.vm.ci.code.BailoutException in project graal by oracle.

the class InliningData method doInline.

@SuppressWarnings("try")
private void doInline(CallsiteHolderExplorable callerCallsiteHolder, MethodInvocation calleeInvocation) {
    StructuredGraph callerGraph = callerCallsiteHolder.graph();
    InlineInfo calleeInfo = calleeInvocation.callee();
    try {
        try (DebugContext.Scope scope = debug.scope("doInline", callerGraph)) {
            EconomicSet<Node> canonicalizedNodes = EconomicSet.create(Equivalence.IDENTITY);
            canonicalizedNodes.addAll(calleeInfo.invoke().asNode().usages());
            EconomicSet<Node> parameterUsages = calleeInfo.inline(new Providers(context));
            canonicalizedNodes.addAll(parameterUsages);
            counterInliningRuns.increment(debug);
            debug.dump(DebugContext.DETAILED_LEVEL, callerGraph, "after %s", calleeInfo);
            Graph.Mark markBeforeCanonicalization = callerGraph.getMark();
            canonicalizer.applyIncremental(callerGraph, context, canonicalizedNodes);
            // process invokes that are possibly created during canonicalization
            for (Node newNode : callerGraph.getNewNodes(markBeforeCanonicalization)) {
                if (newNode instanceof Invoke) {
                    callerCallsiteHolder.pushInvoke((Invoke) newNode);
                }
            }
            callerCallsiteHolder.computeProbabilities();
            counterInliningPerformed.increment(debug);
        }
    } catch (BailoutException bailout) {
        throw bailout;
    } catch (AssertionError | RuntimeException e) {
        throw new GraalError(e).addContext(calleeInfo.toString());
    } catch (GraalError e) {
        throw e.addContext(calleeInfo.toString());
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : AllocatedObjectNode(org.graalvm.compiler.nodes.virtual.AllocatedObjectNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) AbstractNewObjectNode(org.graalvm.compiler.nodes.java.AbstractNewObjectNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) TypeGuardInlineInfo(org.graalvm.compiler.phases.common.inlining.info.TypeGuardInlineInfo) AssumptionInlineInfo(org.graalvm.compiler.phases.common.inlining.info.AssumptionInlineInfo) InlineInfo(org.graalvm.compiler.phases.common.inlining.info.InlineInfo) ExactInlineInfo(org.graalvm.compiler.phases.common.inlining.info.ExactInlineInfo) MultiTypeGuardInlineInfo(org.graalvm.compiler.phases.common.inlining.info.MultiTypeGuardInlineInfo) DebugContext(org.graalvm.compiler.debug.DebugContext) Providers(org.graalvm.compiler.phases.util.Providers) Invoke(org.graalvm.compiler.nodes.Invoke) BailoutException(jdk.vm.ci.code.BailoutException) InlineableGraph(org.graalvm.compiler.phases.common.inlining.info.elem.InlineableGraph) Graph(org.graalvm.compiler.graph.Graph) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraalError(org.graalvm.compiler.debug.GraalError)

Aggregations

BailoutException (jdk.vm.ci.code.BailoutException)12 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)5 CancellationBailoutException (org.graalvm.compiler.core.common.CancellationBailoutException)3 RetryableBailoutException (org.graalvm.compiler.core.common.RetryableBailoutException)3 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)3 DebugContext (org.graalvm.compiler.debug.DebugContext)3 OptionValues (org.graalvm.compiler.options.OptionValues)3 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 CompilationResult (org.graalvm.compiler.code.CompilationResult)2 CompilationPrinter (org.graalvm.compiler.core.CompilationPrinter)2 PermanentBailoutException (org.graalvm.compiler.core.common.PermanentBailoutException)2 GraalError (org.graalvm.compiler.debug.GraalError)2 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)2 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)2 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)2 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)2 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1