Search in sources :

Example 21 with TruffleToLibGraal

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

the class TruffleToLibGraalEntryPoints method openCompilation.

@TruffleToLibGraal(OpenCompilation)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_openCompilation")
public static long openCompilation(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle, JObject hsCompilable) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, OpenCompilation, env);
    try (JNIMethodScope s = scope) {
        HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(handle, HotSpotTruffleCompilerImpl.class);
        CompilableTruffleAST compilable = new HSCompilableTruffleAST(env, hsCompilable);
        TruffleCompilation compilation = compiler.openCompilation(compilable);
        assert compilation instanceof TruffleCompilationIdentifier;
        return LibGraalObjectHandles.create(compilation);
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        return 0;
    }
}
Also used : TruffleCompilationIdentifier(org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleCompilation(org.graalvm.compiler.truffle.common.TruffleCompilation) 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 22 with TruffleToLibGraal

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

the class TruffleToLibGraalEntryPoints method closeDebugContextScope.

@TruffleToLibGraal(CloseDebugContextScope)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_closeDebugContextScope")
@SuppressWarnings({ "unused", "try" })
public static void closeDebugContextScope(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
    try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, CloseDebugContextScope, env)) {
        AutoCloseable scope = LibGraalObjectHandles.resolve(handle, DebugContext.Scope.class);
        scope.close();
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) OpenDebugContext(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.OpenDebugContext) CloseDebugContext(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.CloseDebugContext) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) DebugContext(org.graalvm.compiler.debug.DebugContext) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 23 with TruffleToLibGraal

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

the class TruffleToLibGraalEntryPoints method initializeRuntime.

@TruffleToLibGraal(InitializeRuntime)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_initializeRuntime")
public static long initializeRuntime(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, JObject truffleRuntime, long classLoaderDelegateId) {
    try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, InitializeRuntime, env)) {
        ResolvedJavaType classLoaderDelegate = LibGraal.unhand(ResolvedJavaType.class, classLoaderDelegateId);
        HSTruffleCompilerRuntime hsTruffleRuntime = new HSTruffleCompilerRuntime(env, truffleRuntime, classLoaderDelegate, HotSpotGraalOptionValues.defaultOptions());
        TruffleCompilerRuntimeInstance.initialize(hsTruffleRuntime);
        long truffleRuntimeHandle = LibGraalObjectHandles.create(hsTruffleRuntime);
        return truffleRuntimeHandle;
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        return 0L;
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 24 with TruffleToLibGraal

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

the class TruffleToLibGraalEntryPoints method installTruffleCallBoundaryMethod.

@TruffleToLibGraal(InstallTruffleCallBoundaryMethod)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_installTruffleCallBoundaryMethod")
public static void installTruffleCallBoundaryMethod(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle, long methodHandle) {
    try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, InstallTruffleCallBoundaryMethod, env)) {
        HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(handle, HotSpotTruffleCompilerImpl.class);
        compiler.installTruffleCallBoundaryMethod(LibGraal.unhand(ResolvedJavaMethod.class, methodHandle));
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 25 with TruffleToLibGraal

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

the class TruffleToLibGraalEntryPoints method getInfopoints.

@TruffleToLibGraal(GetInfopoints)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getInfopoints")
@SuppressWarnings({ "unused", "try" })
public static JObjectArray getInfopoints(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetInfopoints, env);
    try (JNIMethodScope s = scope) {
        String[] infoPoints = LibGraalObjectHandles.resolve(handle, CompilationResultInfo.class).getInfopoints();
        JClass componentType = FromLibGraalCalls.getJNIClass(env, String.class);
        JObjectArray res = NewObjectArray(env, infoPoints.length, componentType, WordFactory.nullPointer());
        for (int i = 0; i < infoPoints.length; i++) {
            SetObjectArrayElement(env, res, i, createHSString(env, infoPoints[i]));
        }
        scope.setObjectResult(res);
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        scope.setObjectResult(WordFactory.nullPointer());
    }
    return scope.getObjectResult();
}
Also used : CompilationResultInfo(org.graalvm.compiler.truffle.common.TruffleCompilerListener.CompilationResultInfo) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JClass(org.graalvm.jniutils.JNI.JClass) 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) JObjectArray(org.graalvm.jniutils.JNI.JObjectArray) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) 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