[foreign-memaccess+abi] Integrated: 8305087: MemoryLayout API checks should be more eager
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Mar 31 15:48:40 UTC 2023
On Tue, 28 Mar 2023 14:04:35 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This patch adds eager check on construction of sequence and group layouts. More specifically:
>
> * sequenceLayout(L) is well-formed iff L.bitAlignment() <= L.bitSize()
> * groupLayout(L1, … Ln) is well-formed iff for-each 1..n, offset(Li) % Li.bitAlignment() == 0
>
> Moreover, this patch also validates the alignment parameter to calls of `MemoryLayout::withBitAlignment` on sequence and group layouts:
>
> * sequenceLayout(L).withBitAlignment(a) is well-formed iff L.bitAlignment() <= a
> * groupLayout(L1, ..., Ln).withBitAlignment(a) is well-formed iff max(L1.bitAlignment(), ..., Ln.bitAlignment()) <= a
>
> These checks prevent bad layouts from being constructed (either with factories, or with bad calls to `withBitAlignment`), w/o restricting the expressiveness of the memory layout API.
> Moreover, since all layouts are now well-formed by construction, we no longer need lazy checks when creating a deferefence var handle.
This pull request has now been integrated.
Changeset: 6211e0c4
Author: Maurizio Cimadamore <mcimadamore at openjdk.org>
URL: https://git.openjdk.org/panama-foreign/commit/6211e0c459444dc4ec27326b9adb7f117d8bce8e
Stats: 295 lines in 19 files changed: 87 ins; 176 del; 32 mod
8305087: MemoryLayout API checks should be more eager
Reviewed-by: jvernee, pminborg
-------------
PR: https://git.openjdk.org/panama-foreign/pull/824
More information about the panama-dev
mailing list