On Fri, 31 May 2024 16:18:33 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> This PR restores a var handle cache in `Utils::makeSegmentViewVarHandle`. 
>> The cache was moved to `ValueLayouts::varHandle` as part of 
>> [pull/19251](https://git.openjdk.org/jdk/pull/19251), on the basis that we 
>> want to optimize the common case like:
>> 
>> 
>> ValueLayout layout = ...
>> layout.varHandle().get(...)
>> 
>> 
>> And that caching more complex var handles didn't seem to add value, given 
>> that, for these var handles, the logic in `LayoutPath` needs to adapt the 
>> returned var handle anyways.
>> 
>> But, `TestAccessModes` revealed a different picture - w/o any cache in 
>> `Utils` the test end up allocating 8963 var handle instances (instead of 
>> just 4), in each of the 4 runs the test includes. While this is admittedly a 
>> stress test, it seems nice to restore the level of sharing we had before 
>> [pull/19251](https://git.openjdk.org/jdk/pull/19251).
>
> Maurizio Cimadamore has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Address review comments

Thanks for adding the comment. Looks good

src/java.base/share/classes/jdk/internal/foreign/Utils.java line 98:

> 96:      * <p>
> 97:      * We provide two level of caching of the generated var handles. 
> First, the var handle associated
> 98:      * to a {@link ValueLayout#varHandle()} call is cached inside a 
> stable field of the value layout implementation.

Suggestion:

     * with a {@link ValueLayout#varHandle()} call is cached inside a stable 
field of the value layout implementation.

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

Marked as reviewed by jvernee (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/19485#pullrequestreview-2091379947
PR Review Comment: https://git.openjdk.org/jdk/pull/19485#discussion_r1622749916

Reply via email to