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();
}
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);
}
}
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;
}
}
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);
}
}
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);
}
}
Aggregations