On Mon, 15 Apr 2024 07:50:24 GMT, Per Minborg <pminb...@openjdk.org> wrote:

> This PR proposes to add a new method `MemorySegment::maxByteAlignment` that 
> returns the maximum byte alignment of a segment (both heap and native 
> segments).
> 
> Clients can then use this method to determine if a segment is properly 
> aligned for any given layout (e.g. following a `MemorySegment::reinterpret` 
> operation).

src/java.base/share/classes/java/lang/foreign/MemorySegment.java line 99:

> 97:  * Every memory segment has a {@linkplain #maxByteAlignment() maximum 
> byte alignment}
> 98:  * (see <a href="#segment-alignment">Alignment</a>"), expressed as a 
> {@code long} value
> 99:  * that is always an even power of two.

I think it's better not to say too much about alignment here, otherwise we end 
up referring to concepts that are not well adequately introduced. Perhaps it 
would be better to just say:

Every memory segment has a maximum byte alignment, expressed as a long value. 
The maximum alignment is always a power of two, derived from the segment 
address, and the segment type, as explained in more details below <link>.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18779#discussion_r1565511275

Reply via email to