RFR: 8329997: Add provisions for checking memory segment alignment constraints [v2]

Per Minborg pminborg at openjdk.org
Mon Apr 15 13:19:47 UTC 2024


On Mon, 15 Apr 2024 10:16:30 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Per Minborg has updated the pull request incrementally with three additional commits since the last revision:
>> 
>>  - Update src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java
>>    
>>    Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
>>  - Update src/java.base/share/classes/jdk/internal/foreign/NativeMemorySegmentImpl.java
>>    
>>    Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
>>  - Update src/java.base/share/classes/java/lang/foreign/MemorySegment.java
>>    
>>    Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com>
>
> test/jdk/java/foreign/TestMemoryAlignment.java line 154:
> 
>> 152:              Arena arena = Arena.ofConfined()) {
>> 153:             var segment =channel.map(FileChannel.MapMode.READ_WRITE, 0L, 32L, arena);
>> 154:             assertTrue(segment.maxByteAlignment() >= Long.BYTES);
> 
> Is this always the case? Smells of platform-dependent... (e.g. think also of x86)

I think the alignment is always the biggest of the directly supported primitive types so maybe we should change to `Integer.BYTES` here.

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

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


More information about the core-libs-dev mailing list