Search in sources :

Example 1 with JString

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

the class TruffleToLibGraalEntryPoints method getGraphDumpDirectory.

@TruffleToLibGraal(GetGraphDumpDirectory)
@SuppressWarnings({ "unused", "try" })
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_getGraphDumpDirectory")
public static JString getGraphDumpDirectory(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId) {
    JNIMethodScope scope = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, GetGraphDumpDirectory, env);
    try (JNIMethodScope s = scope) {
        String path = DebugOptions.getDumpDirectory(HotSpotGraalOptionValues.defaultOptions());
        scope.setObjectResult(createHSString(env, path));
    } catch (IOException ioe) {
        scope.setObjectResult(WordFactory.nullPointer());
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        scope.setObjectResult(WordFactory.nullPointer());
    }
    return scope.getObjectResult();
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) 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) IOException(java.io.IOException) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 2 with JString

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

the class JNIExceptionWrapper method getClassName.

private static String getClassName(JNIEnv env, JThrowable throwableHandle) {
    JClass classHandle = GetObjectClass(env, throwableHandle);
    JString className = callGetClassName(env, classHandle);
    return createString(env, className);
}
Also used : JClass(org.graalvm.jniutils.JNI.JClass) JString(org.graalvm.jniutils.JNI.JString)

Example 3 with JString

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

the class TruffleToLibGraalEntryPoints method openDebugContextScope.

@TruffleToLibGraal(OpenDebugContextScope)
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_openDebugContextScope")
@SuppressWarnings({ "unused", "try" })
public static long openDebugContextScope(JNIEnv env, JClass hsClazz, @CEntryPoint.IsolateThreadContext long isolateThreadId, long handle, JString hsName, long compilationHandle) {
    try (JNIMethodScope s = LibGraalUtil.openScope(TruffleToLibGraalEntryPoints.class, OpenDebugContextScope, env)) {
        TruffleDebugContext debugContext = LibGraalObjectHandles.resolve(handle, TruffleDebugContext.class);
        String name = createString(env, hsName);
        AutoCloseable scope;
        if (compilationHandle == 0) {
            scope = debugContext.scope(name);
        } else {
            TruffleCompilationIdentifier compilation = LibGraalObjectHandles.resolve(compilationHandle, TruffleCompilationIdentifier.class);
            scope = debugContext.scope(name, new TruffleDebugJavaMethod(compilation.getCompilable()));
        }
        if (scope == null) {
            return 0;
        }
        long scopeHandle = LibGraalObjectHandles.create(scope);
        return scopeHandle;
    } catch (Throwable t) {
        JNIExceptionWrapper.throwInHotSpot(env, t);
        return 0;
    }
}
Also used : TruffleCompilationIdentifier(org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) TruffleDebugContext(org.graalvm.compiler.truffle.common.TruffleDebugContext) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) 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) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 4 with JString

use of org.graalvm.jniutils.JNI.JString 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();
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) 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) HotSpotTruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Example 5 with JString

use of org.graalvm.jniutils.JNI.JString 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();
}
Also used : JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) 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) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) TruffleToLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)

Aggregations

JString (org.graalvm.jniutils.JNI.JString)14 JNIUtil.createString (org.graalvm.jniutils.JNIUtil.createString)9 JNIUtil.createHSString (org.graalvm.jniutils.JNIUtil.createHSString)7 TruffleToLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)6 GetSuppliedString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString)6 JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)6 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)6 TruffleFromLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)5 JNIEnv (org.graalvm.jniutils.JNI.JNIEnv)5 CompilableToString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal.Id.CompilableToString)2 TruffleCompilationIdentifier (org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier)2 HSCompilableTruffleASTGen.callCompilableToString (org.graalvm.compiler.truffle.compiler.hotspot.libgraal.HSCompilableTruffleASTGen.callCompilableToString)2 CTypeConversion.toCString (org.graalvm.nativeimage.c.type.CTypeConversion.toCString)2 IOException (java.io.IOException)1 CompilerConfigurationFactory (org.graalvm.compiler.hotspot.CompilerConfigurationFactory)1 HotSpotGraalOptionValues (org.graalvm.compiler.hotspot.HotSpotGraalOptionValues)1 OptionValues (org.graalvm.compiler.options.OptionValues)1 TruffleDebugContext (org.graalvm.compiler.truffle.common.TruffleDebugContext)1 TruffleDebugJavaMethod (org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod)1 HotSpotTruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl)1