[foreign-memaccess+abi] RFR: 8267240: Bounded arena allocator doesn't work if bounded size > BLOCK_SIZE [v2]

Jorn Vernee jvernee at openjdk.java.net
Mon May 17 15:31:42 UTC 2021

On Mon, 17 May 2021 15:08:24 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> This patch follows the discussion in [1], and splits the unbounded allocator from the bounded one, as attempts to reusing logic were causing issues when bounded arena allocators were created with bounded size > BLOCK_SIZE.
>> I have looked for simplifications of the `trySlice` logic (also mentioned in the emails) - but in my opinion it cannot be simplified much. When an allocator is unbounded, if we receive a request that is more than half the size of the allocator block, we cannot guarantee that we can align it correctly in a segment whose size is BLOCK_SIZE. So, I think the limit of MAX_ALLOC_SIZE = BLOCK_SIZE / 2 is correct, in the sense that anything above that limit needs a standalone allocation (or we won't be able to align it in certain edge cases).
>> Of course, if we didn't care about alignment, the logic could be simplified, but since this is a native allocator, I think respecting alignment of the allocation request is important.
>> [1] - https://mail.openjdk.java.net/pipermail/panama-dev/2021-May/013796.html
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>   Address review comment



Marked as reviewed by jvernee (Committer).

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

More information about the panama-dev mailing list