use of org.graalvm.compiler.truffle.common.TruffleCompilerListener in project graal by oracle.
the class IsolateAwareTruffleCompiler method doCompile0.
@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class)
@CEntryPointOptions(publishAs = CEntryPointOptions.Publish.NotPublished)
private static ClientHandle<String> doCompile0(@SuppressWarnings("unused") @CEntryPoint.IsolateThreadContext CompilerIsolateThread context, ClientIsolateThread client, ImageHeapRef<SubstrateTruffleCompiler> delegateRef, ClientHandle<TruffleCompilationIdentifier> compilationIdentifierHandle, ClientHandle<SubstrateCompilableTruffleAST> compilableHandle, ClientHandle<byte[]> encodedOptionsHandle, int encodedOptionsLength, ClientHandle<TruffleCompilationTask> taskHandle, ClientHandle<IsolatedEventContext> eventContextHandle, boolean firstCompilation) {
IsolatedCompileContext.set(new IsolatedCompileContext(client));
try {
SubstrateTruffleCompiler delegate = ImageHeapObjects.deref(delegateRef);
Map<String, Object> options = decodeOptions(client, encodedOptionsHandle, encodedOptionsLength);
IsolatedCompilableTruffleAST compilable = new IsolatedCompilableTruffleAST(compilableHandle);
delegate.initialize(options, compilable, firstCompilation);
TruffleCompilation compilation = new IsolatedCompilationIdentifier(compilationIdentifierHandle, compilable);
TruffleCompilationTask task = null;
if (taskHandle.notEqual(IsolatedHandles.nullHandle())) {
task = new IsolatedTruffleCompilationTask(taskHandle);
}
TruffleCompilerListener listener = null;
if (eventContextHandle.notEqual(IsolatedHandles.nullHandle())) {
listener = new IsolatedTruffleCompilerEventForwarder(eventContextHandle);
}
delegate.doCompile(null, compilation, options, task, listener);
// no exception
return IsolatedHandles.nullHandle();
} catch (Throwable t) {
StringWriter writer = new StringWriter();
t.printStackTrace(new PrintWriter(writer));
return IsolatedCompileContext.get().createStringInClient(writer.toString());
} finally {
/*
* Compilation isolate do not use a dedicated reference handler thread, so we trigger
* the reference handling manually when a compilation finishes.
*/
Heap.getHeap().doReferenceHandling();
IsolatedCompileContext.set(null);
}
}
use of org.graalvm.compiler.truffle.common.TruffleCompilerListener in project graal by oracle.
the class TruffleToLibGraalEntryPoints method doCompile.
@TruffleToLibGraal(DoCompile)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_doCompile")
public static void doCompile(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long compilerHandle, long debugContextHandle, long compilationHandle, JByteArray hsOptions, JObject hsTask, JObject hsListener) {
try (JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, DoCompile, env)) {
TruffleCompilationIdentifier compilation = LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilationIdentifier.class);
try (CompilationContext hotSpotObjectConstantScope = HotSpotGraalServices.openLocalCompilationContext(compilation)) {
HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(compilerHandle, HotSpotTruffleCompilerImpl.class);
TruffleDebugContext debugContext = LibGraalObjectHandles.resolve(debugContextHandle, TruffleDebugContext.class);
Map<String, Object> options = decodeOptions(env, hsOptions);
TruffleCompilationTask task = hsTask.isNull() ? null : new HSTruffleCompilationTask(hsTask);
TruffleCompilerListener listener = hsListener.isNull() ? null : new HSTruffleCompilerListener(scope, hsListener);
compiler.doCompile(debugContext, compilation, options, task, listener);
}
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
}
}
Aggregations