RFR: 8345687: Improve the implementation of SegmentFactories::allocateSegment [v3]

Quan Anh Mai qamai at openjdk.org
Sat Jan 25 02:35:52 UTC 2025


On Fri, 24 Jan 2025 11:57:06 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> The main goal here is that passing/receiving raw addresses as longs is cheaper than as `MemorySegment`s.
>
> But the address is immediately converted to memory segment using MemorySegment::ofAddress, which is what the linker does anyway?

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.

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

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


More information about the core-libs-dev mailing list