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

Quan Anh Mai qamai at openjdk.org
Wed Dec 11 18:44:50 UTC 2024


On Mon, 9 Dec 2024 12:48:07 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java line 213:
>> 
>>> 211: 
>>> 212:     @DontInline
>>> 213:     private static long allocateNativeOveraligned(long byteSize, long byteAlignment, MemorySessionImpl sessionImpl,
>> 
>> This would always make the session escape in the case of over aligned allocation. Maybe it's possible to move the call to `addCleanupIfFail` to `allocateNative` instead? (that seems to be the only use of `sessionImpl` here).
>
> In fact, except for the `alignUp` call, I'm not sure I see enough difference between the two code paths to warrant splitting out the code to a new method? AFAIU, the split was made to avoid playing with slicing in the hot path - but if we create the segment as the very last thing we do in `allocateNative`, do we care?

That's fair, I have moved it back to `SegmentFactories::allocateNative` and got rid of this method.

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

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


More information about the core-libs-dev mailing list