[code-reflection] RFR: Use memory segment

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Feb 26 12:53:19 UTC 2025


On Wed, 26 Feb 2025 12:45:59 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> No - `allocateFrom` creates a new off-heap segment when invoked on an `Arena`. `Arena` is a segment allocator that always allocates off-heap. The `allocateFrom` functions are explicitly designed for use cases when you want to allocate and copy existing data on top of the new allocated segment -- in which case the FFM knows that zeroing the allocated segment is redundant. I think that should be used here.

Note: what I'm pointing out is that, performance-wise, `allocateFrom` is not the same as `allocate` + `copyFrom`. Internally, `allocateFrom` will still create a temporary on-heap view of the byte array (w/o allocating a new heap array though) -- but that will be passed to an allocation routine that does allocation + copy w/o zeroring. If you call `allocate` zeroing will happen no matter what.

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

PR Review Comment: https://git.openjdk.org/babylon/pull/328#discussion_r1971529704


More information about the babylon-dev mailing list