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);
});
}
}
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);
}
}
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);
}
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());
}
}
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();
}
}
Aggregations