On Mon, 16 Dec 2024 11:01:11 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> Quan Anh Mai has updated the pull request incrementally with two additional 
>> commits since the last revision:
>> 
>>  - wrong init
>>  - move segment instance creation to SegmentFactories
>
> test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java line 77:
> 
>> 75:             var freeAddr = lookup.findOrThrow("free");
>> 76:             CALLOC = linker.downcallHandle(callocAddr, 
>> FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG, 
>> ValueLayout.JAVA_LONG));
>> 77:             FREE = linker.downcallHandle(freeAddr, 
>> FunctionDescriptor.ofVoid(ValueLayout.JAVA_LONG));
> 
> I'm not sure these changes are needed. It seems the main goal here is to 
> avoid the cost of the capture associated with `CLayouts::freeMemory` ? If so, 
> can't we just store that consumer into a static final and call it a day? I 
> think then we could avoid the `static` init, and leave most of the code 
> unchanged, except for the additional static field?

The main goal here is that passing/receiving raw addresses as longs is cheaper 
than as `MemorySegment`s.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22610#discussion_r1925646301

Reply via email to