Skip to content

Commit

Permalink
Fixes after rebasing.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhaeubl committed Feb 7, 2022
1 parent dd7e8b1 commit a4e4f3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.lang.ref.Reference;

import com.oracle.svm.core.thread.JavaThreads;
import com.oracle.svm.core.thread.PlatformThreads;
import org.graalvm.compiler.api.replacements.Fold;
import org.graalvm.nativeimage.CurrentIsolate;
import org.graalvm.nativeimage.IsolateThread;
Expand Down Expand Up @@ -1058,7 +1059,7 @@ private void finishCollection() {

// This method will be removed as soon as possible, see GR-36676.
static void doReferenceHandlingInRegularThread() {
if (ReferenceHandler.useRegularJavaThread() && !VMOperation.isInProgress() && JavaThreads.currentJavaThreadInitialized()) {
if (ReferenceHandler.useRegularJavaThread() && !VMOperation.isInProgress() && PlatformThreads.isCurrentAssigned()) {
doReferenceHandling();
}
}
Expand All @@ -1070,7 +1071,7 @@ static void doReferenceHandlingInRegularThread() {
*/
static void doReferenceHandling() {
assert !VMOperation.isInProgress() : "could result in deadlocks";
assert JavaThreads.currentJavaThreadInitialized() : "thread is not fully initialized yet";
assert PlatformThreads.isCurrentAssigned() : "thread is not fully initialized yet";
/* Most of the time, we won't have a pending reference list. So, we do that check first. */
if (HeapImpl.getHeapImpl().hasReferencePendingListUnsafe()) {
long startTime = System.nanoTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@ static void processCleaners() {
}
}

public static boolean isReferenceHandlingAllowed() {
/*
* Inside a VMOperation, we are not allowed to do certain things, e.g., perform
* synchronization (because it can deadlock when a lock is held outside the VMOperation).
* Similar restrictions apply if we are too early in the attach sequence of a thread.
*/
return !VMOperation.isInProgress() && JavaThreads.currentJavaThreadInitialized();
}

private ReferenceHandler() {
}
}

0 comments on commit a4e4f3d

Please sign in to comment.