Search in sources :

Example 11 with JNIMethodScope

use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.

the class TruffleToLibGraalEntryPoints method getGraphDumpDirectory.

@TruffleToLibGraal(GetGraphDumpDirectory)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getGraphDumpDirectory")
public static JString getGraphDumpDirectory(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetGraphDumpDirectory, env);
    try (JNIMethodScope s = scope) {
        String path = DebugOptions.getDumpDirectory(HotSpotGraalOptionValues.defaultOptions());
        scope.setObjectResult(createHSString(env, path));
    } catch (IOException ioe) {
        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) IOException(java.io.IOException) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 12 with JNIMethodScope

use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.

the class TruffleToLibGraalEntryPoints method getNodeTypes.

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

Example 13 with JNIMethodScope

use of org.graalvm.jniutils.JNIMethodScope 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;
    }
}
Also used : TruffleCompilationIdentifier(org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) 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 14 with JNIMethodScope

use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.

the class TruffleToLibGraalEntryPoints method closeCompilation.

@TruffleToLibGraal(CloseCompilation)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_closeCompilation")
public static void closeCompilation(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long compilationHandle) {
    try (JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, CloseCompilation, env)) {
        TruffleCompilation compilation = LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilation.class);
        HSCompilableTruffleAST compilable = (HSCompilableTruffleAST) compilation.getCompilable();
        try {
            compilation.close();
        } finally {
            compilable.release(env);
            HSObject.cleanHandles(env);
            doReferenceHandling();
        }
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleCompilation(org.graalvm.compiler.truffle.common.TruffleCompilation) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 15 with JNIMethodScope

use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.

the class TruffleToLibGraalEntryPoints method getTruffleCompilationTruffleAST.

@TruffleToLibGraal(GetTruffleCompilationTruffleAST)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getTruffleCompilationTruffleAST")
@SuppressWarnings({ "unused", "try" })
public static JObject getTruffleCompilationTruffleAST(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long compilationHandle) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetTruffleCompilationTruffleAST, env);
    try (JNIMethodScope s = scope) {
        HSCompilableTruffleAST compilable = (HSCompilableTruffleAST) LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilation.class).getCompilable();
        scope.setObjectResult(compilable.getHandle());
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        scope.setObjectResult(WordFactory.nullPointer());
    }
    return scope.getObjectResult();
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Aggregations

JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)36 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)32 TruffleToLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)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 JMXToLibGraal (org.graalvm.compiler.hotspot.management.libgraal.annotation.JMXToLibGraal)7 JObject (org.graalvm.jniutils.JNI.JObject)7 TruffleDebugContext (org.graalvm.compiler.truffle.common.TruffleDebugContext)5 TruffleCompilationIdentifier (org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier)4 HSObject (org.graalvm.jniutils.HSObject)4 ObjectHandles (org.graalvm.nativeimage.ObjectHandles)4 AttributeList (javax.management.AttributeList)3 CompilableTruffleAST (org.graalvm.compiler.truffle.common.CompilableTruffleAST)3 TruffleCompilation (org.graalvm.compiler.truffle.common.TruffleCompilation)3 TruffleFromLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)3 JNI (org.graalvm.jniutils.JNI)3 JObjectArray (org.graalvm.jniutils.JNI.JObjectArray)3