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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon May 17 15:08:28 UTC 2021


On Mon, 17 May 2021 14:41:08 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Address review comment
>
> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/ArenaAllocator.java line 61:
> 
>> 59:                 return slice;
>> 60:             } else {
>> 61:                 if (Utils.alignUp(bytesSize, bytesAlignment) > DEFAULT_MAX_ALLOC_SIZE) {
> 
> This seems to be the subject of some of the emails. I think maybe it might be worth it to break this out into an intermediate variable with a good name?
> 
> I also think the DEFAULT_MAX_ALLOC_SIZE could just be DEFAULT_BLOCK_SIZE, if we change this check to check for the maximum allocation size computed by `byteSize + bytesAlignment - 1` instead of using `alignUp`:
> 
> Suggestion:
> 
>                 long maxPossibleAllocationSize = bytesSize + bytesAlignment - 1;
>                 if (maxPossibleAllocationSize > DEFAULT_BLOCK_SIZE) {
> 
> 
> e.g. if we have an allocation aligned to 8 bytes, we can have a maximum of 7 bytes of alignment padding (in case the address is off by just 1 byte).

I've accepted this comment

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

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


More information about the panama-dev mailing list