use of org.graalvm.jniutils.JNI.JObject 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.JNI.JObject in project graal by oracle.
the class HotSpotCalls method callStaticJObject.
/**
* Performs a JNI call of a static method returning {@link Object}.
*/
@SuppressWarnings("unchecked")
@HotSpotCall
public <R extends JObject> R callStaticJObject(JNIEnv env, JClass clazz, JNIMethod method, JNI.JValue args) {
traceCall(env, clazz, method);
JNI.JObject res = env.getFunctions().getCallStaticObjectMethodA().call(env, clazz, method.getJMethodID(), args);
wrapAndThrowPendingJNIException(env, exceptionHandler);
return (R) res;
}
use of org.graalvm.jniutils.JNI.JObject 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.JNI.JObject in project graal by oracle.
the class HSTruffleCompilerRuntime method registerOptimizedAssumptionDependency.
@TruffleFromLibGraal(RegisterOptimizedAssumptionDependency)
@Override
public Consumer<OptimizedAssumptionDependency> registerOptimizedAssumptionDependency(JavaConstant optimizedAssumption) {
long optimizedAssumptionHandle = LibGraal.translate(optimizedAssumption);
JNIEnv env = env();
JObject assumptionConsumer = callRegisterOptimizedAssumptionDependency(env, getHandle(), optimizedAssumptionHandle);
return assumptionConsumer.isNull() ? null : new HSConsumer(scope(), assumptionConsumer);
}
use of org.graalvm.jniutils.JNI.JObject in project graal by oracle.
the class HSTruffleCallNode method getCurrentCallTarget.
@TruffleFromLibGraal(GetCurrentCallTarget)
@Override
public CompilableTruffleAST getCurrentCallTarget() {
JNIMethodScope scope = JNIMethodScope.scope();
JObject hsCompilable = callGetCurrentCallTarget(scope.getEnv(), getHandle());
if (hsCompilable.isNull()) {
return null;
} else {
return new HSCompilableTruffleAST(scope, hsCompilable);
}
}
Aggregations