mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8310053: VarHandle and slice handle derived from layout are lacking alignment check
Reviewed-by: mcimadamore
This commit is contained in:
parent
45eaf5edd8
commit
e022e87654
4 changed files with 94 additions and 17 deletions
|
@ -380,6 +380,10 @@ public sealed interface MemoryLayout permits SequenceLayout, GroupLayout, Paddin
|
|||
* Additionally, the provided dynamic values must conform to bounds which are derived from the layout path, that is,
|
||||
* {@code 0 <= x_i < b_i}, where {@code 1 <= i <= n}, or {@link IndexOutOfBoundsException} is thrown.
|
||||
* <p>
|
||||
* The base address must be <a href="MemorySegment.html#segment-alignment">aligned</a> according to the {@linkplain
|
||||
* #byteAlignment() alignment constraint} of the root layout (this layout). Note that this can be more strict
|
||||
* (but not less) than the alignment constraint of the selected value layout.
|
||||
* <p>
|
||||
* Multiple paths can be chained, with <a href=#deref-path-elements>dereference path elements</a>.
|
||||
* A dereference path element constructs a fresh native memory segment whose base address is the address value
|
||||
* read obtained by accessing a memory segment at the offset determined by the layout path elements immediately preceding
|
||||
|
@ -436,6 +440,10 @@ public sealed interface MemoryLayout permits SequenceLayout, GroupLayout, Paddin
|
|||
* long size = select(elements).byteSize();
|
||||
* MemorySegment slice = segment.asSlice(offset, size);
|
||||
* }
|
||||
* <p>
|
||||
* The segment to be sliced must be <a href="MemorySegment.html#segment-alignment">aligned</a> according to the
|
||||
* {@linkplain #byteAlignment() alignment constraint} of the root layout (this layout). Note that this can be more
|
||||
* strict (but not less) than the alignment constraint of the selected value layout.
|
||||
*
|
||||
* @apiNote The returned method handle can be used to obtain a memory segment slice, similarly to {@link MemorySegment#asSlice(long, long)},
|
||||
* but more flexibly, as some indices can be specified when invoking the method handle.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue