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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon May 17 11:49:07 UTC 2021


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

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

Commit messages:
 - Fix issue with bounded allocators

Changes: https://git.openjdk.java.net/panama-foreign/pull/537/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=537&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8267240
  Stats: 112 lines in 3 files changed: 61 ins; 37 del; 14 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/537.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/537/head:pull/537

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


More information about the panama-dev mailing list