Skip to content

Commit 1adbf04

Browse files
Automatic merge of master into galahad
2 parents dd30ea1 + 4575f8c commit 1adbf04

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeCodeInfoMemory.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import java.util.concurrent.locks.ReentrantLock;
2828

29-
import jdk.graal.compiler.word.Word;
3029
import org.graalvm.nativeimage.ImageSingletons;
3130
import org.graalvm.nativeimage.Platform;
3231
import org.graalvm.nativeimage.Platforms;
@@ -47,6 +46,7 @@
4746
import com.oracle.svm.core.util.VMError;
4847

4948
import jdk.graal.compiler.api.replacements.Fold;
49+
import jdk.graal.compiler.word.Word;
5050

5151
/**
5252
* Keeps track of {@link CodeInfo} structures of runtime-compiled methods (including invalidated and
@@ -226,6 +226,17 @@ public boolean remove(CodeInfo info) {
226226
}
227227
}
228228

229+
public boolean contains(CodeInfo info) {
230+
assert !VMOperation.isGCInProgress();
231+
assert info.isNonNull() : "null";
232+
lock.lock();
233+
try {
234+
return contains0(info);
235+
} finally {
236+
lock.unlock();
237+
}
238+
}
239+
229240
public boolean removeDuringGC(CodeInfo info) {
230241
assert VMOperation.isGCInProgress() : "Otherwise, we would need to protect the CodeInfo from the GC.";
231242
assert info.isNonNull();
@@ -308,6 +319,21 @@ private boolean remove0(CodeInfo info) {
308319
return false;
309320
}
310321

322+
@Uninterruptible(reason = "Access hashtable atomically with regard to GC.")
323+
private boolean contains0(CodeInfo info) {
324+
int length = NonmovableArrays.lengthOf(table);
325+
int index = hashIndex(info, length);
326+
UntetheredCodeInfo entry = NonmovableArrays.getWord(table, index);
327+
while (entry.isNonNull()) {
328+
if (entry.equal(info)) {
329+
return true;
330+
}
331+
index = nextIndex(index, length);
332+
entry = NonmovableArrays.getWord(table, index);
333+
}
334+
return false;
335+
}
336+
311337
/** Rehashes possibly-colliding entries after deletion to preserve collision properties. */
312338
@Uninterruptible(reason = "Manipulate hashtable atomically with regard to GC.")
313339
private void rehashAfterUnregisterAt(int index) { // from IdentityHashMap: Knuth 6.4 Algorithm R

0 commit comments

Comments
 (0)