RFR: 8343188: Investigate ways to simplify MemorySegment::ofBuffer
Jorn Vernee
jvernee at openjdk.org
Wed Oct 30 18:30:07 UTC 2024
On Tue, 29 Oct 2024 14:51:33 GMT, Per Minborg <pminborg at openjdk.org> wrote:
> This PR proposes to improve `MemorySegment::ofBuffer` making it more amenable to inlining and generally improving performance.
>
> Testing successfully on tier1-3
src/java.base/share/classes/java/nio/Buffer.java line 33:
> 31: import jdk.internal.access.foreign.UnmapperProxy;
> 32: import jdk.internal.foreign.AbstractMemorySegmentImpl;
> 33: import jdk.internal.foreign.HeapMemorySegmentImpl;
Spurious import?
src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template line 545:
> 543: boolean readOnly,
> 544: MemorySessionImpl bufferScope) {
> 545: return SegmentFactories.arrayOf$Type$Segment(base, offset, length, readOnly, bufferScope);
For direct buffers I don't think we can get here since the base should be `null`? I think this should be changed to throw UOE (if we ever do end up here, we don't want to return a heap segment with a `null` base).
src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java line 49:
> 47: * such as the elimination of store barriers in methods like {@link HeapMemorySegmentImpl#dup(long, long, boolean, MemorySessionImpl)}.
> 48: */
> 49: public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegmentImpl {
This change doesn't seem to be needed.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21764#discussion_r1823178554
PR Review Comment: https://git.openjdk.org/jdk/pull/21764#discussion_r1823180881
PR Review Comment: https://git.openjdk.org/jdk/pull/21764#discussion_r1823179015
More information about the core-libs-dev
mailing list