Search in sources :

Example 36 with JNIMethodScope

use of org.graalvm.jniutils.JNIMethodScope in project graal by oracle.

the class Target_org_graalvm_compiler_truffle_compiler_hotspot_libgraal_TruffleToLibGraalEntryPoints method compileMethod.

@SuppressWarnings({ "unused", "try" })
@Substitute
private static CompilationRequestResult compileMethod(HotSpotGraalCompiler compiler, CompilationRequest request) {
    long offset = compiler.getGraalRuntime().getVMConfig().jniEnvironmentOffset;
    long javaThreadAddr = HotSpotJVMCIRuntime.runtime().getCurrentJavaThread();
    JNI.JNIEnv env = (JNI.JNIEnv) WordFactory.unsigned(javaThreadAddr).add(WordFactory.unsigned(offset));
    // Truffle-specific method annotations.
    try {
        try (JNIMethodScope scope = LibGraalUtil.openScope("<called from VM>", env)) {
            return compiler.compileMethod(request, true, compiler.getGraalRuntime().getOptions());
        }
    } finally {
        /*
             * libgraal doesn't use a dedicated reference handler thread, so we trigger the
             * reference handling manually when a compilation finishes.
             */
        Heap.getHeap().doReferenceHandling();
    }
}
Also used : JNI(org.graalvm.jniutils.JNI) JNIMethodScope(org.graalvm.jniutils.JNIMethodScope) Substitute(com.oracle.svm.core.annotate.Substitute)

Aggregations

JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)36 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)32 TruffleToLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal)25 GetSuppliedString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleToLibGraal.Id.GetSuppliedString)12 JString (org.graalvm.jniutils.JNI.JString)12 JNIUtil.createHSString (org.graalvm.jniutils.JNIUtil.createHSString)12 JNIUtil.createString (org.graalvm.jniutils.JNIUtil.createString)12 HotSpotTruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.hotspot.HotSpotTruffleCompilerImpl)9 JMXToLibGraal (org.graalvm.compiler.hotspot.management.libgraal.annotation.JMXToLibGraal)7 JObject (org.graalvm.jniutils.JNI.JObject)7 TruffleDebugContext (org.graalvm.compiler.truffle.common.TruffleDebugContext)5 TruffleCompilationIdentifier (org.graalvm.compiler.truffle.compiler.TruffleCompilationIdentifier)4 HSObject (org.graalvm.jniutils.HSObject)4 ObjectHandles (org.graalvm.nativeimage.ObjectHandles)4 AttributeList (javax.management.AttributeList)3 CompilableTruffleAST (org.graalvm.compiler.truffle.common.CompilableTruffleAST)3 TruffleCompilation (org.graalvm.compiler.truffle.common.TruffleCompilation)3 TruffleFromLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)3 JNI (org.graalvm.jniutils.JNI)3 JObjectArray (org.graalvm.jniutils.JNI.JObjectArray)3