use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.
the class TruffleToLibGraalEntryPoints method getCompilerConfigurationName.
@TruffleToLibGraal(GetCompilerConfigurationName)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getCompilerConfigurationName")
public static JString getCompilerConfigurationName(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateId, long handle) {
JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetCompilerConfigurationName, env);
try (JNIMethodScope s = scope) {
HotSpotTruffleCompilerImpl compiler = LibGraalObjectHandles.resolve(handle, HotSpotTruffleCompilerImpl.class);
String name = compiler.getCompilerConfigurationName();
scope.setObjectResult(createHSString(env, name));
} 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 getString.
@TruffleToLibGraal(GetSuppliedString)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getSuppliedString")
@SuppressWarnings({ "unused", "unchecked", "try" })
public static JString getString(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetSuppliedString, env);
try (JNIMethodScope s = scope) {
Supplier<String> orig = LibGraalObjectHandles.resolve(handle, Supplier.class);
if (orig != null) {
String stackTrace = orig.get();
scope.setObjectResult(JNIUtil.createHSString(env, stackTrace));
} else {
scope.setObjectResult(WordFactory.nullPointer());
}
} 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 HSCompilableTruffleAST method getCallNodes.
@TruffleFromLibGraal(GetCallNodes)
@Override
public TruffleCallNode[] getCallNodes() {
JNIMethodScope scope = scope();
JNIEnv env = scope.getEnv();
JObjectArray peerArr = callGetCallNodes(env, getHandle());
int len = JNIUtil.GetArrayLength(env, peerArr);
TruffleCallNode[] res = new TruffleCallNode[len];
for (int i = 0; i < len; i++) {
JObject peerTruffleCallNode = JNIUtil.GetObjectArrayElement(env, peerArr, i);
res[i] = new HSTruffleCallNode(scope, peerTruffleCallNode);
}
return res;
}
use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.
the class HSTruffleCompilerRuntime method asCompilableTruffleAST.
@TruffleFromLibGraal(AsCompilableTruffleAST)
@Override
public CompilableTruffleAST asCompilableTruffleAST(JavaConstant constant) {
JNIMethodScope scope = JNIMethodScope.scopeOrNull();
if (scope == null) {
return null;
}
long constantHandle = LibGraal.translate(constant);
JObject hsCompilable = callAsCompilableTruffleAST(scope.getEnv(), getHandle(), constantHandle);
if (hsCompilable.isNull()) {
return null;
} else {
return new HSCompilableTruffleAST(scope, hsCompilable);
}
}
use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.
the class JMXToLibGraalEntryPoints method pollRegistrations.
/**
* Returns the pending {@link DynamicMBean} registrations.
*/
@JMXToLibGraal(PollRegistrations)
@CEntryPoint(name = "Java_org_graalvm_compiler_hotspot_management_JMXToLibGraalCalls_pollRegistrations")
@SuppressWarnings({ "try", "unused" })
static JNI.JLongArray pollRegistrations(JNI.JNIEnv env, JNI.JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId) {
JNIMethodScope scope = LibGraalUtil.openScope(JMXToLibGraalEntryPoints.class, PollRegistrations, env);
try (JNIMethodScope s = scope) {
List<MBeanProxy<?>> registrations = MBeanProxy.drainRegistrations();
JNI.JLongArray res = JNIUtil.NewLongArray(env, registrations.size());
CLongPointer elems = JNIUtil.GetLongArrayElements(env, res, WordFactory.nullPointer());
try {
ObjectHandles globalHandles = ObjectHandles.getGlobal();
for (int i = 0; i < registrations.size(); i++) {
long handle = globalHandles.create(registrations.get(i)).rawValue();
elems.write(i, handle);
}
} finally {
JNIUtil.ReleaseLongArrayElements(env, res, elems, JNI.JArray.MODE_WRITE_RELEASE);
}
scope.setObjectResult(res);
}
return scope.getObjectResult();
}
Aggregations