RFR: 8308248: Revisit alignment of layout constants on 32-bit platforms [v3]
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu May 18 09:33:00 UTC 2023
> The FFM API exposes layout constants for Java primitives. Among those there are constants for `JAVA_LONG` and `JAVA_DOUBLE`. Currently, the alignment of these layouts is set the same as their size (e.g. 8 bytes).
>
> This is obviously correct on 64-bit platforms, but on 32-bit platform it is not, as such platforms cannot guarantee that doubles and longs will be always 64-bit aligned. This will also result in problems when trying to use e.g. `JAVA_DOUBLE` to model a C double for the linker API on 32-bit platforms.
>
> For these reasons, it would be preferable to define the alignment of `JAVA_LONG` and `JAVA_DOUBLE` constants as `ADDRESS.byteSize()`.
>
> This patch rectifies alignment of those layout constants to reflect platform-dependent constraints. It also fixes the maximum alignment constraint supported by heap segments, so that it is 4 for long[] and double[] on 32-bit platforms.
Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
Address review comments
Actually tweak alignment of ValueLayout.OfLong/ValueLayout.OfDouble
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/14007/files
- new: https://git.openjdk.org/jdk/pull/14007/files/731095e9..0cb7d5a9
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=14007&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=14007&range=01-02
Stats: 6 lines in 2 files changed: 2 ins; 0 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/14007.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14007/head:pull/14007
PR: https://git.openjdk.org/jdk/pull/14007
More information about the core-libs-dev
mailing list