mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8307375: Alignment check on layouts used as sequence element is not correct
Reviewed-by: jvernee
This commit is contained in:
parent
3968ab5db5
commit
47422be2d1
6 changed files with 85 additions and 24 deletions
|
@ -704,12 +704,12 @@ public sealed interface MemoryLayout permits SequenceLayout, GroupLayout, Paddin
|
|||
* @param elementLayout the sequence element layout.
|
||||
* @return the new sequence layout with the given element layout and size.
|
||||
* @throws IllegalArgumentException if {@code elementCount } is negative.
|
||||
* @throws IllegalArgumentException if {@code elementLayout.bitAlignment() > elementLayout.bitSize()}.
|
||||
* @throws IllegalArgumentException if {@code elementLayout.bitSize() % elementLayout.bitAlignment() != 0}.
|
||||
*/
|
||||
static SequenceLayout sequenceLayout(long elementCount, MemoryLayout elementLayout) {
|
||||
MemoryLayoutUtil.requireNonNegative(elementCount);
|
||||
Objects.requireNonNull(elementLayout);
|
||||
Utils.checkElementAlignment(elementLayout, "Element layout alignment greater than its size");
|
||||
Utils.checkElementAlignment(elementLayout, "Element layout size is not multiple of alignment");
|
||||
return wrapOverflow(() ->
|
||||
SequenceLayoutImpl.of(elementCount, elementLayout));
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ public sealed interface MemoryLayout permits SequenceLayout, GroupLayout, Paddin
|
|||
*
|
||||
* @param elementLayout the sequence element layout.
|
||||
* @return a new sequence layout with the given element layout and maximum element count.
|
||||
* @throws IllegalArgumentException if {@code elementLayout.bitAlignment() > elementLayout.bitSize()}.
|
||||
* @throws IllegalArgumentException if {@code elementLayout.bitSize() % elementLayout.bitAlignment() != 0}.
|
||||
*/
|
||||
static SequenceLayout sequenceLayout(MemoryLayout elementLayout) {
|
||||
Objects.requireNonNull(elementLayout);
|
||||
|
|
|
@ -459,10 +459,11 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
*
|
||||
* @param elementLayout the layout to be used for splitting.
|
||||
* @return the element spliterator for this segment
|
||||
* @throws IllegalArgumentException if the {@code elementLayout} size is zero, or the segment size modulo the
|
||||
* {@code elementLayout} size is greater than zero, if this segment is
|
||||
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a> in the provided layout,
|
||||
* or if the {@code elementLayout} alignment is greater than its size.
|
||||
* @throws IllegalArgumentException if {@code elementLayout.byteSize() == 0}.
|
||||
* @throws IllegalArgumentException if {@code byteSize() % elementLayout.byteSize() != 0}.
|
||||
* @throws IllegalArgumentException if {@code elementLayout.bitSize() % elementLayout.bitAlignment() != 0}.
|
||||
* @throws IllegalArgumentException if this segment is <a href="MemorySegment.html#segment-alignment">incompatible
|
||||
* with the alignment constraint</a> in the provided layout.
|
||||
*/
|
||||
Spliterator<MemorySegment> spliterator(MemoryLayout elementLayout);
|
||||
|
||||
|
@ -475,10 +476,11 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl {
|
|||
*
|
||||
* @param elementLayout the layout to be used for splitting.
|
||||
* @return a sequential {@code Stream} over disjoint slices in this segment.
|
||||
* @throws IllegalArgumentException if the {@code elementLayout} size is zero, or the segment size modulo the
|
||||
* {@code elementLayout} size is greater than zero, if this segment is
|
||||
* <a href="MemorySegment.html#segment-alignment">incompatible with the alignment constraint</a> in the provided layout,
|
||||
* or if the {@code elementLayout} alignment is greater than its size.
|
||||
* @throws IllegalArgumentException if {@code elementLayout.byteSize() == 0}.
|
||||
* @throws IllegalArgumentException if {@code byteSize() % elementLayout.byteSize() != 0}.
|
||||
* @throws IllegalArgumentException if {@code elementLayout.bitSize() % elementLayout.bitAlignment() != 0}.
|
||||
* @throws IllegalArgumentException if this segment is <a href="MemorySegment.html#segment-alignment">incompatible
|
||||
* with the alignment constraint</a> in the provided layout.
|
||||
*/
|
||||
Stream<MemorySegment> elements(MemoryLayout elementLayout);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue