Search in sources :

Example 1 with IsolatedCompileContext

use of com.oracle.svm.graal.isolated.IsolatedCompileContext 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);
    }
}
Also used : TruffleCompilation(org.graalvm.compiler.truffle.common.TruffleCompilation) IsolatedCompileContext(com.oracle.svm.graal.isolated.IsolatedCompileContext) TruffleCompilationTask(org.graalvm.compiler.truffle.common.TruffleCompilationTask) SubstrateTruffleCompiler(com.oracle.svm.truffle.api.SubstrateTruffleCompiler) StringWriter(java.io.StringWriter) PinnedObject(org.graalvm.nativeimage.PinnedObject) TruffleCompilerListener(org.graalvm.compiler.truffle.common.TruffleCompilerListener) PrintWriter(java.io.PrintWriter) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions)

Example 2 with IsolatedCompileContext

use of com.oracle.svm.graal.isolated.IsolatedCompileContext in project graal by oracle.

the class IsolatedCompilableTruffleAST method dequeueInlined.

@Override
public void dequeueInlined() {
    final IsolatedCompileContext context = IsolatedCompileContext.get();
    dequeueInlined0(context.getClient(), handle);
}
Also used : IsolatedCompileContext(com.oracle.svm.graal.isolated.IsolatedCompileContext)

Aggregations

IsolatedCompileContext (com.oracle.svm.graal.isolated.IsolatedCompileContext)2 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)1 SubstrateTruffleCompiler (com.oracle.svm.truffle.api.SubstrateTruffleCompiler)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 TruffleCompilation (org.graalvm.compiler.truffle.common.TruffleCompilation)1 TruffleCompilationTask (org.graalvm.compiler.truffle.common.TruffleCompilationTask)1 TruffleCompilerListener (org.graalvm.compiler.truffle.common.TruffleCompilerListener)1 PinnedObject (org.graalvm.nativeimage.PinnedObject)1 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)1