-
Bug
-
Resolution: Fixed
-
P2
-
21
-
b22
-
Verified
Sometimes layouts are used as elements in a "sequence" where the element is repeated, back to back, several times.
We have several instance of this usage of memory layouts in the API:
* MemorySegment::getAtIndex //1
* MemorySegment::copy //1
* ValueLayout::arrayElementVarHandle //1
* MemoryLayout::sequenceLayout //2
* MemorySegment::spliterator //2
* MemorySegment::elements //2
In some cases (1) the layout parameter is a ValueLayout, in other cases (2), the API point is more general and accepts a MemoryLayout.
The implementation asserts layout well-formedness by checking that the layout size is bigger than the alignment. Now, for value layouts, since both are power of two (by construction), this check turns out ok.
But if the accepted layout is more general than a ValueLayout (as in (2)) then we can no longer rely on the "power of two" assumption, and we have to check that the layout size is effectively a multiple of the alignment (otherwise we end up with a "bad" sequence where not all elements are correctly aligned).
We have several instance of this usage of memory layouts in the API:
* MemorySegment::getAtIndex //1
* MemorySegment::copy //1
* ValueLayout::arrayElementVarHandle //1
* MemoryLayout::sequenceLayout //2
* MemorySegment::spliterator //2
* MemorySegment::elements //2
In some cases (1) the layout parameter is a ValueLayout, in other cases (2), the API point is more general and accepts a MemoryLayout.
The implementation asserts layout well-formedness by checking that the layout size is bigger than the alignment. Now, for value layouts, since both are power of two (by construction), this check turns out ok.
But if the accepted layout is more general than a ValueLayout (as in (2)) then we can no longer rely on the "power of two" assumption, and we have to check that the layout size is effectively a multiple of the alignment (otherwise we end up with a "bad" sequence where not all elements are correctly aligned).
- csr for
-
JDK-8307376 Alignment check on layouts used as sequence element is not correct
-
- Closed
-