Search in sources :

Example 6 with JObject

use of org.graalvm.jniutils.JNI.JObject in project graal by oracle.

the class HotSpotCalls method callJObject.

/**
 * Performs a JNI call of a method returning {@link Object}.
 */
@HotSpotCall
@SuppressWarnings("unchecked")
public <R extends JObject> R callJObject(JNIEnv env, JObject object, JNIMethod method, JNI.JValue args) {
    traceCall(env, object, method);
    JNI.JObject res = env.getFunctions().getCallObjectMethodA().call(env, object, method.getJMethodID(), args);
    wrapAndThrowPendingJNIException(env, exceptionHandler);
    return (R) res;
}
Also used : JObject(org.graalvm.jniutils.JNI.JObject)

Example 7 with JObject

use of org.graalvm.jniutils.JNI.JObject in project graal by oracle.

the class HotSpotCalls method callNewObject.

/**
 * Creates a new object instance using a given constructor.
 */
@HotSpotCall
@SuppressWarnings("unchecked")
public <R extends JObject> R callNewObject(JNIEnv env, JClass clazz, JNIMethod constructor, JNI.JValue args) {
    traceCall(env, clazz, constructor);
    JNI.JObject res = env.getFunctions().getNewObjectA().call(env, clazz, constructor.getJMethodID(), args);
    wrapAndThrowPendingJNIException(env, exceptionHandler);
    return (R) res;
}
Also used : JObject(org.graalvm.jniutils.JNI.JObject)

Example 8 with JObject

use of org.graalvm.jniutils.JNI.JObject in project graal by oracle.

the class HSCompilableTruffleAST method onCompilationFailed.

@TruffleFromLibGraal(CreateStringSupplier)
@TruffleFromLibGraal(OnCompilationFailed)
@Override
public void onCompilationFailed(Supplier<String> serializedException, boolean silent, boolean bailout, boolean permanentBailout, boolean graphTooBig) {
    long serializedExceptionHandle = LibGraalObjectHandles.create(serializedException);
    boolean success = false;
    JNIEnv env = env();
    try {
        JObject instance = callCreateStringSupplier(env, serializedExceptionHandle);
        callOnCompilationFailed(env, getHandle(), instance, silent, bailout, permanentBailout, graphTooBig);
        success = true;
    } finally {
        if (!success) {
            LibGraalObjectHandles.remove(serializedExceptionHandle);
        }
    }
}
Also used : JObject(org.graalvm.jniutils.JNI.JObject) JNIEnv(org.graalvm.jniutils.JNI.JNIEnv) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 9 with JObject

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

Example 10 with JObject

use of org.graalvm.jniutils.JNI.JObject in project graal by oracle.

the class HSTruffleCompilerRuntime method isSuppressedFailure.

@TruffleFromLibGraal(CreateStringSupplier)
@TruffleFromLibGraal(IsSuppressedFailure)
@Override
public boolean isSuppressedFailure(CompilableTruffleAST compilable, Supplier<String> serializedException) {
    long serializedExceptionHandle = LibGraalObjectHandles.create(serializedException);
    boolean success = false;
    JNIEnv env = env();
    try {
        JObject instance = callCreateStringSupplier(env, serializedExceptionHandle);
        boolean res = callIsSuppressedFailure(env, getHandle(), ((HSCompilableTruffleAST) compilable).getHandle(), instance);
        success = true;
        return res;
    } finally {
        if (!success) {
            LibGraalObjectHandles.remove(serializedExceptionHandle);
        }
    }
}
Also used : JObject(org.graalvm.jniutils.JNI.JObject) JNIEnv(org.graalvm.jniutils.JNI.JNIEnv) 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