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

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Mar 20 11:14:20 UTC 2025


On Wed, 19 Mar 2025 18:31:27 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This PR is an attempt to put var handle support for flat values on a more solid footing. Some more notes in a comment below.

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

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

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


More information about the valhalla-dev mailing list