Search in sources :

Example 6 with JNIMethodScope

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

the class TruffleToLibGraalEntryPoints method getVersionProperties.

@TruffleToLibGraal(GetVersionProperties)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getVersionProperties")
@SuppressWarnings({ "unused", "try" })
public static JByteArray getVersionProperties(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetVersionProperties, env);
    try (JNIMethodScope s = scope) {
        Map<String, Object> versionProperties = new HashMap<>();
        for (Map.Entry<Object, Object> e : DebugContext.addVersionProperties(null).entrySet()) {
            Object key = e.getKey();
            Object value = e.getValue();
            assert key instanceof String;
            assert value instanceof String;
            versionProperties.put((String) key, value);
        }
        byte[] serializedProperties = OptionsEncoder.encode(versionProperties);
        JByteArray hsSerializedOptions = NewByteArray(env, serializedProperties.length);
        CCharPointer cdata = GetByteArrayElements(env, hsSerializedOptions, WordFactory.nullPointer());
        CTypeConversion.asByteBuffer(cdata, serializedProperties.length).put(serializedProperties);
        ReleaseByteArrayElements(env, hsSerializedOptions, cdata, JArray.MODE_WRITE_RELEASE);
        scope.setObjectResult(hsSerializedOptions);
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        scope.setObjectResult(WordFactory.nullPointer());
    }
    return scope.getObjectResult();
}
Also used : JByteArray(org.graalvm.jniutils.JNI.JByteArray) HashMap(java.util.HashMap) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) 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) Map(java.util.Map) HashMap(java.util.HashMap) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 7 with JNIMethodScope

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

the class TruffleToLibGraalEntryPoints method closeDebugContext.

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

Example 8 with JNIMethodScope

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

the class TruffleToLibGraalEntryPoints method getDumpChannel.

@TruffleToLibGraal(GetDumpChannel)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getDumpChannel")
@SuppressWarnings({ "unused", "try" })
public static long getDumpChannel(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long debugContextHandle) {
    try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetDumpChannel, env)) {
        TruffleDebugContextImpl debugContext = LibGraalObjectHandles.resolve(debugContextHandle, TruffleDebugContextImpl.class);
        GraphOutput<Void, ?> graphOutput = debugContext.buildOutput(GraphOutput.newBuilder(VoidGraphStructure.INSTANCE));
        return LibGraalObjectHandles.create(graphOutput);
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        return 0;
    }
}
Also used : TruffleDebugContextImpl(org.graalvm.compiler.truffle.compiler.TruffleDebugContextImpl) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 9 with JNIMethodScope

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

the class TruffleToLibGraalEntryPoints method shutdown.

@TruffleToLibGraal(Shutdown)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_shutdown")
public static void shutdown(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
    try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, Shutdown, env)) {
        HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(handle, HotSpotTruffleCompilerImpl.class);
        compiler.shutdown();
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) 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 10 with JNIMethodScope

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

the class TruffleToLibGraalEntryPoints method initializeCompiler.

@TruffleToLibGraal(InitializeCompiler)
@SuppressWarnings("unused")
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_initializeCompiler")
public static void initializeCompiler(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long compilerHandle, JByteArray hsOptions, JObject hsCompilable, boolean firstInitialization) {
    try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, InitializeCompiler, env)) {
        HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(compilerHandle, HotSpotTruffleCompilerImpl.class);
        Map<String, Object> options = decodeOptions(env, hsOptions);
        CompilableTruffleAST compilable = new HSCompilableTruffleAST(s, hsCompilable);
        compiler.initialize(options, compilable, firstInitialization);
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) 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) 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)

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