Skip to content

Commit

Permalink
[GR-57654] Fix racy assertion for weak keys in shape transition map.
Browse files Browse the repository at this point in the history
PullRequest: graal/18687
  • Loading branch information
woess committed Sep 3, 2024
2 parents 04e79e3 + 6d6afe1 commit 09baec5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,7 @@ E find(K key, int hash, int shift) {
if (index < 0) {
return null;
} else {
E entry = (E) entries[index];
assert entry != null && key(entry).equals(key) : Arrays.asList(entry, key);
return entry;
return (E) entries[index];
}
}

Expand All @@ -408,7 +406,6 @@ TrieNode<K, V, E> put(K key, int hash, E entry, int shift) {
return new HashCollisionNode<>(hash, copyAndAppend(entries, entry));
} else {
E e = (E) entries[index];
assert e != null && key(e).equals(key) : Arrays.asList(e, key);
if (e.equals(entry)) {
return this;
} else {
Expand All @@ -427,7 +424,6 @@ TrieNode<K, V, E> remove(K key, int hash, int shift) {
if (index < 0) {
return this;
} else {
assert entries[index] != null && key((E) entries[index]).equals(key) : Arrays.asList(entries[index], key);
assert entries.length >= 2;
if (entries.length == 2) {
return new BitmapNode<>(bit(this.hashcode, shift), copyAndRemove(entries, index));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public V get(Object key) {

Map.Entry<K, V> getEntry(K key) {
var entry = root.find(key, hash(key));
assert entry == null || entry.getKey().equals(key) : Arrays.asList(entry, key);
assert entry == null || entry.getKey().equals(key) || (entry.getKey() instanceof WeakKey<?> wk && wk.refersTo(null)) : Arrays.asList(entry, key);
return entry;
}

Expand Down

0 comments on commit 09baec5

Please sign in to comment.