RFR: 8307181: MemoryLayout.structLayout uses undocumented strict alignment constraints
Jorn Vernee
jvernee at openjdk.org
Wed May 3 14:29:31 UTC 2023
On Wed, 3 May 2023 14:20:22 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> Actually, now that I look at it, it seems that the exception we raise is not correct. I think we need to throw if the element size is not a multiple of the alignment. That is, the size determines the stride, so that has to be a multiple of the alignment, otherwise it won't work.
Hmm, I guess the current check/assertion doesn't work out if we have an element layout which has a size that is not a multiple of its alignment constraint (i.e. it lacks trailing padding). For instance a struct of size 12, with alignment 8. The second element of a sequence with that struct layout would not be aligned.
I think we went back-and-forth on the need to enforce trailing padding in the `structLayout` factory a few times.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13770#issuecomment-1533124172
More information about the core-libs-dev
mailing list