[lworld] RFR: 8351569: [lworld] Revisit atomic access modes in flat var handles [v7]

Chen Liang liach at openjdk.org
Fri Mar 21 17:53:17 UTC 2025


On Thu, 20 Mar 2025 11:15:34 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/invoke/VarHandles.java line 311:
>> 
>>> 309:             // do not check for atomicity now -- atomicity will be checked on the accessed array object
>>> 310:             // a sharper var handle will be obtained (dynamically) from flatArrayElementHandleFor(Object)
>>> 311:             return maybeAdapt(new VarHandleReferences.Array(aoffset, ashift, arrayClass));
>> 
>> Note: this works because:
>> * the reference Array plain access uses array syntax (which works no matter the array passed in)
>> * non-plain access modes always delegate to sharper var handles based on the type of the accessed array
>
> Another note: at the language level there's no mechanism to obtain a class mirror for a null-restricted, or atomic array. This means we can't really create an array var handle that works only on one array shape (which would allow us to eliminate the dynamic dispatch completely, at least for some array var handles).

Yep, now it is crucial for us to benchmark these var handles - I suspect they are very sensitive to profile pollutions.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1402#discussion_r2008047511


More information about the valhalla-dev mailing list