[foreign-memaccess+abi] RFR: 8301801: Implement arena-centric API [v4]
    Jorn Vernee 
    jvernee at openjdk.org
       
    Fri Feb 10 15:05:21 UTC 2023
    
    
  
On Fri, 10 Feb 2023 13:58:51 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> This patch implements the API proposal described here:
>> 
>> https://cr.openjdk.java.net/~mcimadamore/panama/scoped_arenas.html
>> 
>> The main changes are:
>> 
>> * Static factories `MemorySegment::allocateNative` are gone;
>> * The static factory `SegmentAllocator::nativeAllocator` is also gone;
>> * `SegmentScope` moved as nested class in `MemorySegment` (e.g. `MemorySegment.Scope`);
>> * Tweak methods accepting `SegmentScope` to accept `Arena` instead;
>> * Simplify `Arena` API, by removing predicates (`isCloseable`/`isAccessibleBy`) and by dropping `whileAlive`;
>> * Change arena factories to use `of` prefix instead of `open` - and rename `auto()` to `ofAuto()`.
>> 
>>  The API changes are rather straightforward, but they lead to several shallow test and microbenchmark changes, so the number of affected file is quite big (mostly because of the rename `openConfined` -> `ofConfined`).
>> 
>> A javadoc of the proposed changes is available here:
>> 
>> http://cr.openjdk.java.net/~mcimadamore/panama/scoped_arena_interface_lump_predicates/
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Clarify lifetime of segments which wrap external resources.
Marked as reviewed by jvernee (Committer).
test/jdk/java/foreign/TestSegments.java line 121:
> 119:         assertEquals(segment.scope(), segment.scope());
> 120:         assertEquals(segment.asSlice(0).scope(), segment.scope());
> 121:         assertEquals(segment.asReadOnly().scope(), segment.scope());
I think it would be good to also test multiple levels of nesting here, e.g. `segment.asSlice(0).asSlice(0).asSlice(0).scope()`
-------------
PR: https://git.openjdk.org/panama-foreign/pull/781
    
    
More information about the panama-dev
mailing list