On Thu, 17 Sep 2026 12:51:57 GMT, Per Minborg <[email protected]> wrote:

>> This PR proposes removing the entire internal `BufferStack` and associated 
>> classes and tests. Instead, we can now simply rely on a `Arena.ofConfined` 
>> which will provide pooling for us automatically.
>> 
>> If integrated, this PR would imply:
>> 1,511 lines removed net across 13 files compared with master:
>> - 602 production-source lines
>> - 909 test and benchmark lines
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Per Minborg has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Remove methods in SlicingAllocator

src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java line 410:

> 408:             final Arena arena = Arena.ofConfined();
> 409:             final SegmentAllocator allocator = 
> SegmentAllocator.slicingAllocator(arena.allocate(size));
> 410:             return new BoundedArena(arena, allocator);

This needs to handle the case when creating the slicing allocator or allocating 
its backing memory fails[^1], to avoid leaking an unclosed confined arena:
Suggestion:

            try {
                final SegmentAllocator allocator = 
SegmentAllocator.slicingAllocator(arena.allocate(size));
                return new BoundedArena(arena, allocator);
            } catch (final Throwable t) {
                try {
                    arena.close();
                } catch (final Throwable inner) {
                    t.addSuppressed(inner);
                }
                throw t;
            }


[^1]: Mainly due to low memory

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32924#discussion_r4044187577

Reply via email to