RFR: 8295044: Implementation of Foreign Function and Memory API (Second Preview) [v6]
Paul Sandoz
psandoz at openjdk.org
Mon Nov 7 19:11:15 UTC 2022
On Mon, 7 Nov 2022 15:00:02 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> This PR contains the API and implementation changes for JEP-434 [1]. A more detailed description of such changes, to avoid repetitions during the review process, is included as a separate comment.
>>
>> [1] - https://openjdk.org/jeps/434
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>
> Make memory session a pure lifetime abstraction
src/java.base/share/classes/java/lang/foreign/Arena.java line 37:
> 35: * This session is created with the arena, and is closed when the arena is {@linkplain #close() closed}.
> 36: * Furthermore, all the native segments {@linkplain #allocate(long, long) allocated} by the arena are associated
> 37: * with that session.
I think we can simplify the wording by saying an arena has a session:
Suggestion:
* An arena is a {@linkplain AutoCloseable closeable} segment allocator that has a {@link #session() memory session}.
* The arena's session is created when the arena is created, and is closed when the arena is {@linkplain #close() closed}.
* All native segments {@linkplain #allocate(long, long) allocated} by the arena are associated
* with its session.
src/java.base/share/classes/java/lang/foreign/Arena.java line 65:
> 63: * The {@link MemorySegment#address()} of the returned memory segment is the starting address of the
> 64: * allocated off-heap memory region backing the segment. Moreover, the {@linkplain MemorySegment#address() address}
> 65: * of the returned segment is aligned according the provided alignment constraint.
Suggestion:
/**
* Creates a native memory segment with the given size (in bytes) and alignment constraint (in bytes).
* The returned segment is associated with the arena's memory session.
* The segment's {@link MemorySegment#address() address} is the starting address of the
* allocated off-heap memory region backing the segment, and the address is
* aligned according the provided alignment constraint.
-------------
PR: https://git.openjdk.org/jdk/pull/10872
More information about the hotspot-dev
mailing list