RFR: 8312132: Add tracking of multiple address spaces in NMT [v5]

Johan Sjölen jsjolen at openjdk.org
Tue Apr 30 10:06:10 UTC 2024


On Tue, 30 Apr 2024 07:59:09 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> Should the indexes not be stable across resize?

**No.** The hash is determined as: `int place_to_put_element = hash_of(the_thing) % size_of_array;`

The `size_of_array` will change, so when probing for/inserting the same NCS after a resize a new index may be used. Meaning, we will have duplicate entries. If we're OK with this, then that's fine. It means that equality checking will require dereferencing the index and doing the full NCS comparison.

```c++
GA<int> ht(2); // Size 2
int oldidx = hash(4) % ht.size(); // oldidx == 0
ht.put(oldidx, 4);
// Out of room, resize
ht.grow(4);
// Now imagine you insert oldidx into some treap node's metadata
// Now we're adding the same int, 4, again but get a different index
int newidx = hash(4) % ht.size(); // newidx == 2
// Now what?

>> Can't be const unless we want merge to be a function.
>
> Okay!

Merge is gone, and they are const now :-).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18289#discussion_r1584467403
PR Review Comment: https://git.openjdk.org/jdk/pull/18289#discussion_r1584494946


More information about the hotspot-dev mailing list