[foreign-memaccess+abi] RFR: 8284300: Explicitly reject layouts that don't have the correct alignment during linking
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Sep 20 17:49:08 UTC 2022
On Mon, 19 Sep 2022 17:39:23 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> I realized that rejecting layouts that don't have natural alignment also prevents us from supporting packed structs in the future. I tested out the packed struct support and it works on Windows pretty much out of the box. It doesn't work on SysV, some changes to CallArranger are needed. So, there are some options:
> 1. reject layouts that don't have natural alignment on all platforms (Windows won't be able to use packed structs)
> 2. reject layouts that don't have natural alignment on platforms besides Windows (yay Windows users)
> 3. align the status quos: Windows and AArch64 re-compute the alignment. It's not used on Windows, so it can be dropped there. On AArch64 we could "trust" the alignment that is attached to the layout given by the user, same as SysV, but it would fail for packed structs. With the intention of fixing the failure in the future.
>
> I'm leaning most towards 1 at the moment, and that's what this patch implements. We can change that approach when we add reliable support for packed structs across platforms.
src/java.base/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java line 279:
> 277: long copy = Math.min(layout.byteSize() - offset, COPY_CHUNK_SIZE);
> 278: VMStorage storage = storageCalculator.stackAlloc(copy, align);
> 279: align = 1; // only first copy needs aligning
so, this was an issue in the old code? (seems like in old code we always align to STACK_SLOT_SIZE)
-------------
PR: https://git.openjdk.org/panama-foreign/pull/728
More information about the panama-dev
mailing list