|
26 | 26 |
|
27 | 27 | import java.util.concurrent.locks.ReentrantLock;
|
28 | 28 |
|
29 |
| -import jdk.graal.compiler.word.Word; |
30 | 29 | import org.graalvm.nativeimage.ImageSingletons;
|
31 | 30 | import org.graalvm.nativeimage.Platform;
|
32 | 31 | import org.graalvm.nativeimage.Platforms;
|
|
47 | 46 | import com.oracle.svm.core.util.VMError;
|
48 | 47 |
|
49 | 48 | import jdk.graal.compiler.api.replacements.Fold;
|
| 49 | +import jdk.graal.compiler.word.Word; |
50 | 50 |
|
51 | 51 | /**
|
52 | 52 | * Keeps track of {@link CodeInfo} structures of runtime-compiled methods (including invalidated and
|
@@ -226,6 +226,17 @@ public boolean remove(CodeInfo info) {
|
226 | 226 | }
|
227 | 227 | }
|
228 | 228 |
|
| 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 | + |
229 | 240 | public boolean removeDuringGC(CodeInfo info) {
|
230 | 241 | assert VMOperation.isGCInProgress() : "Otherwise, we would need to protect the CodeInfo from the GC.";
|
231 | 242 | assert info.isNonNull();
|
@@ -308,6 +319,21 @@ private boolean remove0(CodeInfo info) {
|
308 | 319 | return false;
|
309 | 320 | }
|
310 | 321 |
|
| 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 | + |
311 | 337 | /** Rehashes possibly-colliding entries after deletion to preserve collision properties. */
|
312 | 338 | @Uninterruptible(reason = "Manipulate hashtable atomically with regard to GC.")
|
313 | 339 | private void rehashAfterUnregisterAt(int index) { // from IdentityHashMap: Knuth 6.4 Algorithm R
|
|
0 commit comments