use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.
the class JMXToLibGraalEntryPoints method getMBeanInfo.
/**
* Returns the {@link MBeanInfo} encoded as a byte array using {@link OptionsEncoder}.
*/
@JMXToLibGraal(GetMBeanInfo)
@CEntryPoint(name = "Java_org_graalvm_compiler_hotspot_management_JMXToLibGraalCalls_getMBeanInfo")
@SuppressWarnings({ "try", "unused" })
static JNI.JByteArray getMBeanInfo(JNI.JNIEnv env, JNI.JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
JNIMethodScope scope = LibGraalUtil.openScope(JMXToLibGraalEntryPoints.class, GetMBeanInfo, env);
try (JNIMethodScope s = scope) {
ObjectHandles globalHandles = ObjectHandles.getGlobal();
MBeanProxy<?> registration = globalHandles.get(WordFactory.pointer(handle));
MBeanInfo info = registration.getBean().getMBeanInfo();
Map<String, Object> map = new LinkedHashMap<>();
map.put("bean.class", info.getClassName());
map.put("bean.description", info.getDescription());
for (MBeanAttributeInfo attr : info.getAttributes()) {
putAttributeInfo(map, attr);
}
int opCounter = 0;
for (MBeanOperationInfo op : info.getOperations()) {
putOperationInfo(map, op, ++opCounter);
}
scope.setObjectResult(mapToRaw(env, map));
}
return scope.getObjectResult();
}
use of org.graalvm.jniutils.JNIMethodScope 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);
}
}
use of org.graalvm.jniutils.JNIMethodScope 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;
}
}
use of org.graalvm.jniutils.JNIMethodScope 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;
}
}
use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.
the class TruffleToLibGraalEntryPoints method isPrintGraphEnabled.
@TruffleToLibGraal(IsPrintGraphEnabled)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_isPrintGraphEnabled")
public static boolean isPrintGraphEnabled(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long truffleRuntimeHandle) {
try (JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, IsPrintGraphEnabled, env)) {
HSTruffleCompilerRuntime hsTruffleRuntime = LibGraalObjectHandles.resolve(truffleRuntimeHandle, HSTruffleCompilerRuntime.class);
assert TruffleCompilerRuntime.getRuntime() == hsTruffleRuntime;
OptionValues graalOptions = hsTruffleRuntime.getGraalOptions(OptionValues.class);
return DebugOptions.PrintGraph.getValue(graalOptions) != DebugOptions.PrintGraphTarget.Disable;
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
return false;
}
}
Aggregations