On Wed, 11 Dec 2024 18:37:06 GMT, Quan Anh Mai <qa...@openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/ArenaImpl.java line 53: >> >>> 51: Utils.checkAllocationSizeAndAlign(byteSize, byteAlignment); >>> 52: long address = SegmentFactories.allocateNative(byteSize, >>> byteAlignment, session, shouldReserveMemory, false); >>> 53: return new NativeMemorySegmentImpl(address, byteSize, false, >>> session); >> >> Could you move this constructor call (and the one below) to >> `allocateNative`? All segment construction calls are currently in >> `SegmentFactories` as a measure to avoid bootstrap cycles, which we had >> problems with in the past. > > I want to put it here so that even if `SegmentFactories::allocateNative` is > not inlined, this small method will be more likely to be inlined and the > segment can be non-escape, then. I have added a comment regarding class > initialization cycles. I understand, but can't we then move this method to `SegmentFactories` - e.g. maybe have a private `allocateNativeInternal` and an `allocateNative` ? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22610#discussion_r1880739249