[lworld] RFR: 8351569: [lworld] Revisit atomic access modes in flat var handles [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Mar 20 14:08:43 UTC 2025
On Thu, 20 Mar 2025 14:06:02 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.
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>
> Enhance compareAndSetFlatValueAsBytes to work on different kinds of flat arrays
> Cache result of oop-free analysis
> Beef up tests to check different combinations of VM flags
src/java.base/share/classes/jdk/internal/misc/Unsafe.java line 2851:
> 2849: Object expectedArray = ValueClass.newNullableAtomicArray(valueType, 1);
> 2850: Object xArray = ValueClass.newNullableAtomicArray(valueType, 1);
> 2851: if (arrayLayout(expectedArray.getClass()) != layout) {
This part feels a bit dirty: we are receiving a request for layout X - we need to be able to create an array with _that same layout_ -- but there's no primitive for doing that. Which means I have to try using different factories and make sure that I get something compatible (which isn't always guaranteed because of VM flags). All this guesswork should not be necessary -- that is, there should be an unsafe API to create an array with the layout I want (assuming that layout is supported of course)
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1402#discussion_r2005727171
More information about the valhalla-dev
mailing list