[foreign-jextract] RFR: MemorySegmentPool + Allocator [v6]
Radoslaw Smogura
github.com+7535718+rsmogura at openjdk.java.net
Wed Apr 21 07:06:20 UTC 2021
On Tue, 20 Apr 2021 16:46:44 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Radoslaw Smogura has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Use VH insted of volatile
>>
>> Replacee
>> // while ((int) LOCK.compareAndExchange(this, 0, 1) != 1) { }
>> while (!LOCK.compareAndSet(this, 0, 1)) { }
>>
>> Performane around 34 ns / oop
>
> src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemorySegmentPool.java line 154:
>
>> 152: private MemorySegment getSegmentForScope(ResourceScope resourceScope, long size, long alignment) {
>> 153: final var segmentEntry = getSegmentEntryBySize(size, alignment);
>> 154: resourceScope.addOnClose(() -> segmentEntry.close());
>
> There's a potential safety issue here - resourceScope doesn't promise that cleanup actions will be called in a certain order. But I think this should be ok, because the cleanup actions are invoked _after_ the user-provided scope is closed. Meaning that the segments associated with that scope will not be accessible anyway.
Good catch, in case when scope is getting closed in fact segment can be abandoned, and will be permanently removed from pool.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/509
More information about the panama-dev
mailing list