[foreign-memaccess+abi] RFR: 8274287: Add a way to specify block size of unbounded arena allocator

Jorn Vernee jvernee at openjdk.java.net
Fri Sep 24 14:35:21 UTC 2021


On Fri, 24 Sep 2021 14:00:23 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> Following the discussion here:
> 
> https://mail.openjdk.java.net/pipermail/panama-dev/2021-May/013815.html
> 
> This patch renames arena allocator factories, to make room for new unbounded factory which allows clients to specify a custom block size.

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/SegmentAllocator.java line 399:

> 397:      *     and set {@code S = S'}; the allocator then tries to respond to the same allocation request again.
> 398:      *     <li>if the size of the allocation requests is bigger than the size of {@code S}, allocate a new segment {@code S'}
> 399:      *     (using malloc), which has a sufficient size to satisfy the allocation request, and return {@code S'}.

Instead of mentioning `malloc` here, I think it's better to say something like "using MemorySegment::allocateNative", so as not to over-specify (e.g. in case we want to change the allocator).

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/SegmentAllocator.java line 418:

> 416:      * than the thread owning {@code scope}.
> 417:      */
> 418:     static SegmentAllocator arenaUnbounded(long blockSize, ResourceScope scope) {

Would be good to check if `blockSize > 0` here I think (and add javadoc, test for that).

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

PR: https://git.openjdk.java.net/panama-foreign/pull/583


More information about the panama-dev mailing list