Search in sources :

Example 11 with JObject

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);
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JObject(org.graalvm.jniutils.JNI.JObject) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 12 with JObject

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;
}
Also used : JObject(org.graalvm.jniutils.JNI.JObject)

Example 13 with JObject

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);
    }
}
Also used : TruffleCompilationIdentifier(org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) 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) TruffleCompilationTask(org.graalvm.compiler.truffle.common.TruffleCompilationTask) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) CompilationContext(org.graalvm.compiler.hotspot.CompilationContext) HSObject(org.graalvm.jniutils.HSObject) JObject(org.graalvm.jniutils.JNI.JObject) TruffleCompilerListener(org.graalvm.compiler.truffle.common.TruffleCompilerListener) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 14 with JObject

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);
}
Also used : JObject(org.graalvm.jniutils.JNI.JObject) JNIEnv(org.graalvm.jniutils.JNI.JNIEnv) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 15 with JObject

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);
    }
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JObject(org.graalvm.jniutils.JNI.JObject) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Aggregations

JObject (org.graalvm.jniutils.JNI.JObject)20 TruffleFromLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)15 JNIEnv (org.graalvm.jniutils.JNI.JNIEnv)12 JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)5 JString (org.graalvm.jniutils.JNI.JString)3 TruffleToLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)2 GetSuppliedString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString)2 HotSpotTruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl)2 HSObject (org.graalvm.jniutils.HSObject)2 JNIUtil.createHSString (org.graalvm.jniutils.JNIUtil.createHSString)2 JNIUtil.createString (org.graalvm.jniutils.JNIUtil.createString)2 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)2 CompilationContext (org.graalvm.compiler.hotspot.CompilationContext)1 CompilableTruffleAST (org.graalvm.compiler.truffle.common.CompilableTruffleAST)1 TruffleCallNode (org.graalvm.compiler.truffle.common.TruffleCallNode)1 TruffleCompilationTask (org.graalvm.compiler.truffle.common.TruffleCompilationTask)1 TruffleCompilerListener (org.graalvm.compiler.truffle.common.TruffleCompilerListener)1 TruffleDebugContext (org.graalvm.compiler.truffle.common.TruffleDebugContext)1 TruffleCompilationIdentifier (org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier)1 TruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl)1