RFR: 8349146: [REDO] Implement a better allocator for downcalls [v8]
Chen Liang
liach at openjdk.org
Fri May 2 16:44:53 UTC 2025
On Fri, 2 May 2025 16:08:09 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> Using an anonymous class for the cleanup action had very adverse effects on performance. I didn't want to use a lambda for startup performance reasons.
>
> If using lambda affects performance, how about using anonymous classes?
>
> return new PerThread(new ReentrantLock(),
> arena,
> new SlicingAllocator(arena.allocate(byteSize, byteAlignment)),
> new Consumer<MemorySegment>() {
> @Override
> public void accept(MemorySegment memorySegment) {
> Reference.reachabilityFence(arena);
> }});
Anonymous classes also captures outer variables and break cleaner/GC. The only safe measures are local enums or records, which never capture outer variables (anonymous classes cannot be enum or records)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24829#discussion_r2071880222
More information about the core-libs-dev
mailing list