Search in sources :

Example 11 with TruffleToLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal in project graal by oracle.

the class TruffleToLibGraalEntryPoints method getCompilerConfigurationName.

@TruffleToLibGraal(GetCompilerConfigurationName)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getCompilerConfigurationName")
public static JString getCompilerConfigurationName(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateId, long handle) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetCompilerConfigurationName, env);
    try (JNIMethodScope s = scope) {
        HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(handle, HotSpotTruffleCompilerImpl.class);
        String name = compiler.getCompilerConfigurationName();
        scope.setObjectResult(createHSString(env, name));
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        scope.setObjectResult(WordFactory.nullPointer());
    }
    return scope.getObjectResult();
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JNIUtil.createString(org.graalvm.jniutils.JNIUtil.createString) JString(org.graalvm.jniutils.JNI.JString) GetSuppliedString(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString) JNIUtil.createHSString(org.graalvm.jniutils.JNIUtil.createHSString) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 12 with TruffleToLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal in project graal by oracle.

the class TruffleToLibGraalEntryPoints method getString.

@TruffleToLibGraal(GetSuppliedString)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getSuppliedString")
@SuppressWarnings({ "unused", "unchecked", "try" })
public static JString getString(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetSuppliedString, env);
    try (JNIMethodScope s = scope) {
        Supplier<String> orig = LibGraalObjectHandles.resolve(handle, Supplier.class);
        if (orig != null) {
            String stackTrace = orig.get();
            scope.setObjectResult(JNIUtil.createHSString(env, stackTrace));
        } else {
            scope.setObjectResult(WordFactory.nullPointer());
        }
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        scope.setObjectResult(WordFactory.nullPointer());
    }
    return scope.getObjectResult();
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JNIUtil.createString(org.graalvm.jniutils.JNIUtil.createString) JString(org.graalvm.jniutils.JNI.JString) GetSuppliedString(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString) JNIUtil.createHSString(org.graalvm.jniutils.JNIUtil.createHSString) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 13 with TruffleToLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal 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);
    }
}
Also used : TruffleCompilationIdentifier(org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) JNIUtil.createString(org.graalvm.jniutils.JNIUtil.createString) JString(org.graalvm.jniutils.JNI.JString) GetSuppliedString(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString) JNIUtil.createHSString(org.graalvm.jniutils.JNIUtil.createHSString) TruffleCompilationTask(org.graalvm.compiler.truffle.common.TruffleCompilationTask) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) CompilationContext(org.graalvm.compiler.hotspot.CompilationContext) HSObject(org.graalvm.jniutils.HSObject) JObject(org.graalvm.jniutils.JNI.JObject) TruffleCompilerListener(org.graalvm.compiler.truffle.common.TruffleCompilerListener) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 14 with TruffleToLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal in project graal by oracle.

the class TruffleToLibGraalEntryPoints method pendingTransferToInterpreterOffset.

@TruffleToLibGraal(PendingTransferToInterpreterOffset)
@SuppressWarnings("unused")
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_pendingTransferToInterpreterOffset")
public static int pendingTransferToInterpreterOffset(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle, JObject hsCompilable) {
    try (JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, PendingTransferToInterpreterOffset, env)) {
        HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(handle, HotSpotTruffleCompilerImpl.class);
        CompilableTruffleAST compilable = new HSCompilableTruffleAST(scope, hsCompilable);
        return compiler.pendingTransferToInterpreterOffset(compilable);
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        return 0;
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) CompilableTruffleAST(org.graalvm.compiler.truffle.common.CompilableTruffleAST) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 15 with TruffleToLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal in project graal by oracle.

the class TruffleToLibGraalEntryPoints method openDebugContext.

@TruffleToLibGraal(OpenDebugContext)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_openDebugContext")
@SuppressWarnings({ "unused", "try" })
public static long openDebugContext(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long compilerHandle, long compilationHandle, JByteArray hsOptions) {
    try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, OpenDebugContext, env)) {
        HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(compilerHandle, HotSpotTruffleCompilerImpl.class);
        TruffleCompilation compilation = LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilation.class);
        Map<String, Object> options = decodeOptions(env, hsOptions);
        TruffleDebugContext debugContext = compiler.openDebugContext(options, compilation);
        long handle = LibGraalObjectHandles.create(debugContext);
        return handle;
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        return 0;
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleCompilation(org.graalvm.compiler.truffle.common.TruffleCompilation) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) HSObject(org.graalvm.jniutils.HSObject) JObject(org.graalvm.jniutils.JNI.JObject) JNIUtil.createString(org.graalvm.jniutils.JNIUtil.createString) JString(org.graalvm.jniutils.JNI.JString) GetSuppliedString(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString) JNIUtil.createHSString(org.graalvm.jniutils.JNIUtil.createHSString) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Aggregations

TruffleToLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)25 JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)25 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)25 GetSuppliedString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString)12 JString (org.graalvm.jniutils.JNI.JString)12 JNIUtil.createHSString (org.graalvm.jniutils.JNIUtil.createHSString)12 JNIUtil.createString (org.graalvm.jniutils.JNIUtil.createString)12 HotSpotTruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl)9 TruffleDebugContext (org.graalvm.compiler.truffle.common.TruffleDebugContext)5 TruffleCompilationIdentifier (org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier)4 HSObject (org.graalvm.jniutils.HSObject)4 JObject (org.graalvm.jniutils.JNI.JObject)4 CompilableTruffleAST (org.graalvm.compiler.truffle.common.CompilableTruffleAST)3 TruffleCompilation (org.graalvm.compiler.truffle.common.TruffleCompilation)3 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 HotSpotGraalOptionValues (org.graalvm.compiler.hotspot.HotSpotGraalOptionValues)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 JClass (org.graalvm.jniutils.JNI.JClass)2 JObjectArray (org.graalvm.jniutils.JNI.JObjectArray)2 IOException (java.io.IOException)1