Skip to content

Commit

Permalink
Automatic merge of master into galahad
Browse files Browse the repository at this point in the history
  • Loading branch information
OracleLabsAutomation committed Jan 22, 2025
2 parents dd30ea1 + 4575f8c commit 1adbf04
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.util.concurrent.locks.ReentrantLock;

import jdk.graal.compiler.word.Word;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
Expand All @@ -47,6 +46,7 @@
import com.oracle.svm.core.util.VMError;

import jdk.graal.compiler.api.replacements.Fold;
import jdk.graal.compiler.word.Word;

/**
* Keeps track of {@link CodeInfo} structures of runtime-compiled methods (including invalidated and
Expand Down Expand Up @@ -226,6 +226,17 @@ public boolean remove(CodeInfo info) {
}
}

public boolean contains(CodeInfo info) {
assert !VMOperation.isGCInProgress();
assert info.isNonNull() : "null";
lock.lock();
try {
return contains0(info);
} finally {
lock.unlock();
}
}

public boolean removeDuringGC(CodeInfo info) {
assert VMOperation.isGCInProgress() : "Otherwise, we would need to protect the CodeInfo from the GC.";
assert info.isNonNull();
Expand Down Expand Up @@ -308,6 +319,21 @@ private boolean remove0(CodeInfo info) {
return false;
}

@Uninterruptible(reason = "Access hashtable atomically with regard to GC.")
private boolean contains0(CodeInfo info) {
int length = NonmovableArrays.lengthOf(table);
int index = hashIndex(info, length);
UntetheredCodeInfo entry = NonmovableArrays.getWord(table, index);
while (entry.isNonNull()) {
if (entry.equal(info)) {
return true;
}
index = nextIndex(index, length);
entry = NonmovableArrays.getWord(table, index);
}
return false;
}

/** Rehashes possibly-colliding entries after deletion to preserve collision properties. */
@Uninterruptible(reason = "Manipulate hashtable atomically with regard to GC.")
private void rehashAfterUnregisterAt(int index) { // from IdentityHashMap: Knuth 6.4 Algorithm R
Expand Down

0 comments on commit 1adbf04

Please sign in to comment.