use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class TruffleToLibGraalEntryPoints method closeDebugContext.
@TruffleToLibGraal(CloseDebugContext)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_closeDebugContext")
@SuppressWarnings({ "unused", "try" })
public static void closeDebugContext(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, CloseDebugContext, env)) {
TruffleDebugContext debugContext = LibGraalObjectHandles.resolve(handle, TruffleDebugContext.class);
debugContext.close();
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
}
}
use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class TransferToInterpreterTest method test.
@Test
public void test() {
RootNode rootNode = new TestRootNode();
GraalTruffleRuntime runtime = GraalTruffleRuntime.getRuntime();
OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget();
target.call(0);
Assert.assertFalse(target.isValid());
final OptimizedCallTarget compilable = target;
TruffleCompiler compiler = runtime.getTruffleCompiler(compilable);
Map<String, Object> options = GraalTruffleRuntime.getOptionsForCompiler(target);
try (TruffleCompilation compilation = compiler.openCompilation(compilable)) {
TruffleDebugContext debug = compiler.openDebugContext(options, compilation);
compiler.doCompile(debug, compilation, options, new TestTruffleCompilationTask(), null);
}
Assert.assertTrue(target.isValid());
target.call(0);
Assert.assertTrue(target.isValid());
target.call(1);
Assert.assertFalse(target.isValid());
}
use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class TruffleToLibGraalEntryPoints method openDebugContextScope.
@TruffleToLibGraal(OpenDebugContextScope)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_openDebugContextScope")
@SuppressWarnings({ "unused", "try" })
public static long openDebugContextScope(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle, JString hsName, long compilationHandle) {
try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, OpenDebugContextScope, env)) {
TruffleDebugContext debugContext = LibGraalObjectHandles.resolve(handle, TruffleDebugContext.class);
String name = createString(env, hsName);
AutoCloseable scope;
if (compilationHandle == 0) {
scope = debugContext.scope(name);
} else {
TruffleCompilationIdentifier compilation = LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilationIdentifier.class);
scope = debugContext.scope(name, new TruffleDebugJavaMethod(compilation.getCompilable()));
}
if (scope == null) {
return 0;
}
long scopeHandle = LibGraalObjectHandles.create(scope);
return scopeHandle;
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
return 0;
}
}
use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class JNIExceptionWrapperTest method testMergedStackTraceImpl.
private void testMergedStackTraceImpl() throws Exception {
setupContext("engine.CompilationExceptionsAreThrown", Boolean.TRUE.toString(), "engine.CompilationExceptionsAreFatal", Boolean.FALSE.toString());
GraalTruffleRuntime runtime = GraalTruffleRuntime.getRuntime();
OptimizedCallTarget compilable = (OptimizedCallTarget) RootNode.createConstantNode(42).getCallTarget();
TruffleCompiler compiler = runtime.getTruffleCompiler(compilable);
try (TruffleCompilation compilation = compiler.openCompilation(compilable)) {
try (TruffleDebugContext debug = compiler.openDebugContext(GraalTruffleRuntime.getOptionsForCompiler(compilable), compilation)) {
TestListener listener = new TestListener();
compiler.doCompile(debug, compilation, GraalTruffleRuntime.getOptionsForCompiler(compilable), new TestTruffleCompilationTask(), listener);
}
} catch (Throwable t) {
String message = t.getMessage();
int runtimeIndex = findFrame(message, JNIExceptionWrapperTest.class, "testMergedStackTrace");
assertNotEquals(message, -1, runtimeIndex);
int listenerIndex = findFrame(message, TestListener.class, "onTruffleTierFinished");
assertNotEquals(message, -1, listenerIndex);
int compilerIndex = findFrame(message, TruffleCompilerImpl.class, "compileAST");
assertNotEquals(message, -1, compilerIndex);
assertTrue(listenerIndex < compilerIndex);
assertTrue(compilerIndex < runtimeIndex);
}
}
use of org.graalvm.compiler.truffle.common.TruffleDebugContext in project graal by oracle.
the class GraalTruffleRuntime method compileImpl.
@SuppressWarnings("try")
private void compileImpl(TruffleDebugContext initialDebug, OptimizedCallTarget callTarget, TruffleCompilationTask task) {
boolean compilationStarted = false;
try {
TruffleCompiler compiler = getTruffleCompiler(callTarget);
try (TruffleCompilation compilation = compiler.openCompilation(callTarget)) {
final Map<String, Object> optionsMap = getOptionsForCompiler(callTarget);
TruffleDebugContext debug = initialDebug;
if (debug == null) {
debug = compiler.openDebugContext(optionsMap, compilation);
}
listeners.onCompilationStarted(callTarget, task);
compilationStarted = true;
try {
compiler.doCompile(debug, compilation, optionsMap, task, listeners.isEmpty() ? null : listeners);
} finally {
if (initialDebug == null) {
debug.close();
}
}
TruffleInlining inlining = (TruffleInlining) task.inliningData();
truffleDump(callTarget, compiler, compilation, optionsMap, inlining);
inlining.dequeueTargets();
}
} catch (OptimizationFailedException e) {
// Listeners already notified
throw e;
} catch (RuntimeException | Error e) {
notifyCompilationFailure(callTarget, e, compilationStarted, task.tier());
throw e;
} catch (Throwable e) {
notifyCompilationFailure(callTarget, e, compilationStarted, task.tier());
throw new InternalError(e);
}
}
Aggregations