Skip to content

Commit

Permalink
Trigger the reference handling after a Truffle compilation finishes i…
Browse files Browse the repository at this point in the history
…n libgraal.
  • Loading branch information
christianhaeubl committed Feb 7, 2022
1 parent 7ed3399 commit dd7e8b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,17 @@ public static void closeCompilation(JNIEnv env, JClass hsClazz, @CEntryPoint.Iso
} finally {
compilable.release(env);
HSObject.cleanHandles(env);
doReferenceHandling();
}
} catch (Throwable t) {
JNIExceptionWrapper.throwInHotSpot(env, t);
}
}

private static void doReferenceHandling() {
// Substituted in LibGraalFeature.
}

@TruffleToLibGraal(Shutdown)
@SuppressWarnings({"unused", "try"})
@CEntryPoint(name = "Java_org_graalvm_compiler_truffle_runtime_hotspot_libgraal_TruffleToLibGraalCalls_shutdown")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.graalvm.word.Pointer;
import org.graalvm.word.UnsignedWord;

import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.annotate.Uninterruptible;
import com.oracle.svm.core.hub.DynamicHub;
import com.oracle.svm.core.hub.PredefinedClassesSupport;
Expand Down Expand Up @@ -200,10 +199,10 @@ public List<Class<?>> getLoadedClasses() {

/**
* If the automatic reference handling is disabled (see
* {@link SubstrateOptions.ConcealedOptions#AutomaticReferenceHandling}), then this method can
* be called to do the reference handling manually. On execution, the current thread will
* enqueue pending {@link Reference}s into their corresponding {@link ReferenceQueue}s and it
* will execute pending cleaners.
* {@link com.oracle.svm.core.SubstrateOptions.ConcealedOptions#AutomaticReferenceHandling}),
* then this method can be called to do the reference handling manually. On execution, the
* current thread will enqueue pending {@link Reference}s into their corresponding
* {@link ReferenceQueue}s and it will execute pending cleaners.
*
* This method must not be called from within a VM operation as this could result in deadlocks.
* Furthermore, it is up to the caller to ensure that this method is only called in places where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,3 +863,12 @@ private static void notifyCrash(String crashMessage) {
@Delete("shouldn't appear in libgraal")
final class Target_org_graalvm_compiler_hotspot_SymbolicSnippetEncoder {
}

@TargetClass(className = "org.graalvm.compiler.truffle.compiler.hotspot.libgraal.TruffleToLibGraalEntryPoints", onlyWith = LibGraalFeature.IsEnabled.class)
final class Target_org_graalvm_compiler_truffle_compiler_hotspot_libgraal_TruffleToLibGraalEntryPoints {
@SuppressWarnings("unused")
@Substitute
private static void doReferenceHandling() {
Heap.getHeap().doReferenceHandling();
}
}

0 comments on commit dd7e8b1

Please sign in to comment.