Search in sources :

Example 6 with Scope

use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.

the class JVMCIInfopointErrorTest method testUnknownJavaValue.

@SuppressWarnings("try")
@Test(expected = Error.class)
public void testUnknownJavaValue() {
    DebugContext debug = DebugContext.create(getInitialOptions(), DebugHandlersFactory.LOADER);
    try (Scope s = debug.disable()) {
        /*
             * Expected: either AssertionError or GraalError, depending on whether the unit test run
             * is with assertions enabled or disabled.
             */
        test(debug, (tool, state, safepoint) -> {
            LIRFrameState newState = modifyTopFrame(state, new JavaValue[] { new UnknownJavaValue() }, new JavaKind[] { JavaKind.Int }, 1, 0, 0);
            safepoint.accept(newState);
        });
    }
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) Scope(org.graalvm.compiler.debug.DebugContext.Scope) DebugContext(org.graalvm.compiler.debug.DebugContext) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Example 7 with Scope

use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.

the class GraalTruffleRuntime method maybeDumpTruffleTree.

@SuppressWarnings("try")
private static void maybeDumpTruffleTree(DebugContext inDebug, OptionValues options, OptimizedCallTarget callTarget, TruffleInlining inlining) {
    DebugContext debug = inDebug;
    if (debug == null) {
        Description description = new Description(callTarget, "TruffleTree:" + callTarget.getName());
        debug = DebugContext.create(options, description, NO_GLOBAL_METRIC_VALUES, DEFAULT_LOG_STREAM, singletonList(new TruffleTreeDebugHandlersFactory()));
    }
    GraphOutput<Void, ?> output = null;
    try (Scope c = debug.scope("TruffleTree")) {
        if (debug.isDumpEnabled(DebugContext.BASIC_LEVEL)) {
            output = debug.buildOutput(GraphOutput.newBuilder(VoidGraphStructure.INSTANCE));
            output.beginGroup(null, "Truffle::" + callTarget.toString(), "Truffle::" + callTarget.toString(), null, 0, DebugContext.addVersionProperties(null));
            debug.dump(DebugContext.BASIC_LEVEL, new TruffleTreeDumpHandler.TruffleTreeDump(callTarget, inlining), "TruffleTree");
        }
    } catch (Throwable e) {
        if (output != null) {
            try {
                output.endGroup();
                output.close();
            } catch (IOException ex) {
                throw debug.handle(ex);
            }
        }
        throw debug.handle(e);
    }
}
Also used : Description(org.graalvm.compiler.debug.DebugContext.Description) TruffleOptionsOverrideScope(org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope) Scope(org.graalvm.compiler.debug.DebugContext.Scope) DebugContext(org.graalvm.compiler.debug.DebugContext) IOException(java.io.IOException)

Example 8 with Scope

use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.

the class GraalTruffleRuntime method doCompile.

@SuppressWarnings("try")
protected void doCompile(OptionValues options, OptimizedCallTarget callTarget, Cancellable task) {
    listeners.onCompilationStarted(callTarget);
    TruffleCompiler compiler = getTruffleCompiler();
    TruffleInlining inlining = new TruffleInlining(callTarget, new DefaultInliningPolicy());
    CompilationIdentifier compilationId = compiler.getCompilationIdentifier(callTarget);
    try (DebugContext debug = compilationId != null ? compiler.openDebugContext(options, compilationId, callTarget) : null) {
        try (Scope s = debug != null ? debug.scope("Truffle", new TruffleDebugJavaMethod(callTarget)) : null) {
            maybeDumpTruffleTree(debug, options, callTarget, inlining);
            compiler.doCompile(debug, compilationId, options, callTarget, inlining, task, listeners.isEmpty() ? null : listeners);
        } catch (RuntimeException | Error e) {
            throw e;
        } catch (Throwable e) {
            throw new InternalError(e);
        }
    }
    dequeueInlinedCallSites(inlining, callTarget);
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) TruffleOptionsOverrideScope(org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope) Scope(org.graalvm.compiler.debug.DebugContext.Scope) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) GraalError(org.graalvm.compiler.debug.GraalError) ServiceConfigurationError(java.util.ServiceConfigurationError) TruffleCompiler(org.graalvm.compiler.truffle.common.TruffleCompiler) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 9 with Scope

use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.

the class SPARCBranchBailoutTest method testBailoutOnBranchOverflow.

@SuppressWarnings("try")
@Test
public void testBailoutOnBranchOverflow() throws Throwable {
    Assume.assumeTrue(getBackend().getTarget().arch instanceof SPARC);
    ResolvedJavaMethod m = getResolvedJavaMethod("testBranch");
    DebugContext debug = getDebugContext();
    try {
        try (Scope s = debug.disable()) {
            StructuredGraph graph = parseEager(m, AllowAssumptions.YES, debug);
            compile(m, graph);
        }
    } catch (GraalError e) {
        Assert.assertEquals(PermanentBailoutException.class, e.getCause().getClass());
    }
}
Also used : SPARC(jdk.vm.ci.sparc.SPARC) Scope(org.graalvm.compiler.debug.DebugContext.Scope) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraalError(org.graalvm.compiler.debug.GraalError) DebugContext(org.graalvm.compiler.debug.DebugContext) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) PermanentBailoutException(org.graalvm.compiler.core.common.PermanentBailoutException) Test(org.junit.Test)

Example 10 with Scope

use of org.graalvm.compiler.debug.DebugContext.Scope in project graal by oracle.

the class CompletionExecutor method execute.

@SuppressWarnings("try")
public void execute(DebugContextRunnable command) {
    if (!exceptions.isEmpty()) {
        // Don't add more work if a task already failed with an exception.
        return;
    }
    switch(state.get()) {
        case UNUSED:
            throw JVMCIError.shouldNotReachHere();
        case BEFORE_START:
            assert Thread.currentThread() == mainThread;
            postedBeforeStart.add(command);
            break;
        case STARTED:
            postedOperations.increment();
            if (timing != null) {
                timing.addScheduled(command);
            }
            if (isSequential()) {
                try (DebugContext debug = command.getDebug(bb.getOptions(), bb.getDebugHandlerFactories());
                    Scope s = debug.scope("Operation")) {
                    command.run(debug);
                }
                completedOperations.increment();
            } else {
                executorService.execute(() -> {
                    bb.getHostVM().installInThread(vmConfig);
                    long startTime = 0L;
                    if (timing != null) {
                        startTime = System.nanoTime();
                    }
                    Throwable thrown = null;
                    try (DebugContext debug = command.getDebug(bb.getOptions(), bb.getDebugHandlerFactories());
                        Scope s = debug.scope("Operation")) {
                        command.run(debug);
                    } catch (Throwable x) {
                        thrown = x;
                    } finally {
                        bb.getHostVM().clearInThread();
                        if (timing != null) {
                            long taskTime = System.nanoTime() - startTime;
                            timing.addCompleted(command, taskTime);
                        }
                        if (thrown != null) {
                            exceptions.add(thrown);
                        }
                        completedOperations.increment();
                    }
                });
            }
            break;
        default:
            throw JVMCIError.shouldNotReachHere();
    }
}
Also used : Scope(org.graalvm.compiler.debug.DebugContext.Scope) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

DebugContext (org.graalvm.compiler.debug.DebugContext)14 Scope (org.graalvm.compiler.debug.DebugContext.Scope)14 Test (org.junit.Test)9 OptionValues (org.graalvm.compiler.options.OptionValues)5 IOException (java.io.IOException)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 OptionKey (org.graalvm.compiler.options.OptionKey)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)2 GraalError (org.graalvm.compiler.debug.GraalError)2 TruffleOptionsOverrideScope (org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope)2 List (java.util.List)1 ServiceConfigurationError (java.util.ServiceConfigurationError)1 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 SPARC (jdk.vm.ci.sparc.SPARC)1 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)1 PermanentBailoutException (org.graalvm.compiler.core.common.PermanentBailoutException)1 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)1