[foreign-memaccess+abi] RFR: 8284300: Explicitly reject layouts that don't have the correct alignment during linking

Jorn Vernee jvernee at openjdk.org
Tue Sep 20 16:38:39 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/SharedUtils.java line 101:

> 99:      * @return The address the data should be at based on alignment requirement
> 100:      */
> 101:     public static long align(MemoryLayout t, boolean isVar, long addr) {

Noticed this code was dead, so I removed it.

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

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


More information about the panama-dev mailing list