Search in sources :

Example 1 with JObjectArray

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

the class TruffleToLibGraalEntryPoints method getNodeTypes.

@TruffleToLibGraal(GetNodeTypes)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getNodeTypes")
@SuppressWarnings({ "unused", "try" })
public static JObjectArray getNodeTypes(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle, boolean simpleNames) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetNodeTypes, env);
    try (JNIMethodScope s = scope) {
        GraphInfo orig = LibGraalObjectHandles.resolve(handle, GraphInfo.class);
        String[] nodeTypes = orig.getNodeTypes(simpleNames);
        JClass componentType = FromLibGraalCalls.getJNIClass(env, String.class);
        JObjectArray res = NewObjectArray(env, nodeTypes.length, componentType, WordFactory.nullPointer());
        for (int i = 0; i < nodeTypes.length; i++) {
            SetObjectArrayElement(env, res, i, JNIUtil.createHSString(env, nodeTypes[i]));
        }
        scope.setObjectResult(res);
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        scope.setObjectResult(WordFactory.nullPointer());
    }
    return scope.getObjectResult();
}
Also used : GraphInfo(org.graalvm.compiler.truffle.common.TruffleCompilerListener.GraphInfo) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JClass(org.graalvm.jniutils.JNI.JClass) 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) JObjectArray(org.graalvm.jniutils.JNI.JObjectArray) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 2 with JObjectArray

use of org.graalvm.jniutils.JNI.JObjectArray 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 3 with JObjectArray

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

the class TruffleToLibGraalEntryPoints method getInfopoints.

@TruffleToLibGraal(GetInfopoints)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getInfopoints")
@SuppressWarnings({ "unused", "try" })
public static JObjectArray getInfopoints(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetInfopoints, env);
    try (JNIMethodScope s = scope) {
        String[] infoPoints = LibGraalObjectHandles.resolve(handle, CompilationResultInfo.class).getInfopoints();
        JClass componentType = FromLibGraalCalls.getJNIClass(env, String.class);
        JObjectArray res = NewObjectArray(env, infoPoints.length, componentType, WordFactory.nullPointer());
        for (int i = 0; i < infoPoints.length; i++) {
            SetObjectArrayElement(env, res, i, createHSString(env, infoPoints[i]));
        }
        scope.setObjectResult(res);
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        scope.setObjectResult(WordFactory.nullPointer());
    }
    return scope.getObjectResult();
}
Also used : CompilationResultInfo(org.graalvm.compiler.truffle.common.TruffleCompilerListener.CompilationResultInfo) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) JClass(org.graalvm.jniutils.JNI.JClass) 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) JObjectArray(org.graalvm.jniutils.JNI.JObjectArray) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Aggregations

JObjectArray (org.graalvm.jniutils.JNI.JObjectArray)3 JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)3 TruffleToLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)2 GetSuppliedString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString)2 JClass (org.graalvm.jniutils.JNI.JClass)2 JString (org.graalvm.jniutils.JNI.JString)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 TruffleCallNode (org.graalvm.compiler.truffle.common.TruffleCallNode)1 CompilationResultInfo (org.graalvm.compiler.truffle.common.TruffleCompilerListener.CompilationResultInfo)1 GraphInfo (org.graalvm.compiler.truffle.common.TruffleCompilerListener.GraphInfo)1 TruffleFromLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)1 JNIEnv (org.graalvm.jniutils.JNI.JNIEnv)1 JObject (org.graalvm.jniutils.JNI.JObject)1