On Wed, 5 Feb 2025 10:18:01 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> wrote:
>> Only the return value of `CALLOC` is converted to `MemorySegment` in an >> equivalent way, I believe passing a `MemorySegment` to a downcall involves >> acquiring the corresponding segment? As a result, `FREE` is made to accept >> the raw address, and `CALLOC` is changed in the same manner for consistency. > > Yes, passing segments to a downcall will acquire -- but if the segment is a > wrapper around a long (a zero-length memory segment), its scope is the global > scope, and acquire is a no-op. Stepping back what worries me with the changes > in this benchmark is that we're replacing idiomatic FFM code with very > low-level code which seems less representative of code people would write. > Maybe if we need a dedicated benchmark to ensure there's no escaping in the > innards of the API impl, we should write one specifically for that? Got it, I have reverted the change here. `CLayouts::freeMemory` does not capture anything so I think it should not allocate? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22610#discussion_r1945291260