[foreign-abi] [Rev 01] RFR: 8241017: Enhance AllocationScope to support "unbounded" mode

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Mar 13 22:04:23 UTC 2020


On Fri, 13 Mar 2020 19:56:25 GMT, Henry Jen <henryjen at openjdk.org> wrote:

>> Maurizio Cimadamore has updated the pull request incrementally with three additional commits since the last revision:
>> 
>>  - Update src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/AllocationScope.java
>>    
>>    Co-Authored-By: Jorn Vernee <JornVernee at users.noreply.github.com>
>>  - Update src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/AllocationScope.java
>>    
>>    Co-Authored-By: Jorn Vernee <JornVernee at users.noreply.github.com>
>>  - Update src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/AllocationScope.java
>>    
>>    Co-Authored-By: Jorn Vernee <JornVernee at users.noreply.github.com>
>
> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/UnboundedAllocationScope.java line 76:
> 
>> 75:                 usedSegments.add(segment);
>> 76:                 segment = segmentFactory.apply(BLOCK_SIZE);
>> 77:             }
> 
> So we have a hard limit of allocation size no larger then 4K, is the intentional?
> 
> I would like to see what we have for NativeScope  in the foreign-branch for unbounded, when allocation larger than the
> block, we can just allocate it and give back that as a single-used MS.

I considered allocating standalone segments of any size - this is easy to do in the implementation, but there's an
issue: we do not have any way to guarantee alignment for heap-allocated segments, so we can't really preserve the
behavior that we had before.

I'd prefer to go ahead with this change as is - but we should keep thinking about how we want to support (if at all)
alignment for heap allocated allocation scopes. One option could be to drop heap allocation scope altogether - since
alignment doesn't really make sense there. Perhaps one day we will have a way to create aligned arrays in the heap, in
which case we might be able to add that functionality back.

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

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


More information about the panama-dev mailing list