RFR: 8320649: C2: Optimize scoped values [v4]

Roland Westrelin roland at openjdk.org
Thu Jan 25 16:25:40 UTC 2024


On Wed, 17 Jan 2024 10:59:07 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> And what is the argument for why they always succeed?

Because of the way the cache is constructed:

              theCache = new Object[CACHE_TABLE_SIZE * 2];
              setScopedValueCache(theCache);
 ```
and

            CACHE_TABLE_SIZE = cacheSize;
            SLOT_MASK = cacheSize - 1;

accessed with:

            int n = (hash & Cache.SLOT_MASK) * 2;
            if (objects[n] == this) {
                return (T)objects[n + 1];
            }
            n = ((hash >>> Cache.INDEX_BITS) & Cache.SLOT_MASK) * 2;
            if (objects[n] == this) {
                return (T)objects[n + 1];
            }

> How do we know we do not accidentally kill a unrelated RangeCheck?

They are the only RangeChecks in `ScopedValue.get()`. Of course, because the c2 code pattern matches the IR of `ScopedValue.get()` it assumes it has a certain shape. The java code and c2 code have to stay in sync.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16966#discussion_r1466619427


More information about the hotspot-compiler-dev mailing list