[foreign-memaccess+abi] RFR: 8292174: Add unaligned layouts to ValueLayout

Per Minborg duke at openjdk.org
Thu Aug 11 07:55:57 UTC 2022


On Wed, 10 Aug 2022 13:41:13 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/foreign/ValueLayout.java line 672:
>> 
>>> 670:          *          performance and portability issues.
>>> 671:          */
>>> 672:         public static final OfAddress UNALIGNED_ADDRESS = new OfAddress(ByteOrder.nativeOrder());
>> 
>> This seems to create an address layout with the alignment set to the size of the layout? For unaligned layouts we want the alignment set to 1 byte/8 bits I think.
>
> I'd like not to have a separate nested class if possible. That will show up in javadoc and make those constants less discoverable.
> 
> Also, I think it would be better to use UNALIGNED as a suffix - e.g. JAVA_INT_UNALIGNED.

> This seems to create an address layout with the alignment set to the size of the layout? For unaligned layouts we want the alignment set to 1 byte/8 bits I think.

You are right. So, parts like `new OfInt(ByteOrder.nativeOrder()).withBitAlignment(32)` could be simplified to `new OfInt(ByteOrder.nativeOrder())`.

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

PR: https://git.openjdk.org/panama-foreign/pull/705


More information about the panama-dev mailing list