diff --git a/src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java b/src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java index 1297406dcf194..c9b72f818b61f 100644 --- a/src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java +++ b/src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java @@ -171,6 +171,7 @@ default MemorySegment allocateFrom(String str, Charset charset) { * @param layout the layout of the block of memory to be allocated * @param value the value to be set in the newly allocated memory segment */ + @ForceInline default MemorySegment allocateFrom(ValueLayout.OfByte layout, byte value) { Objects.requireNonNull(layout); MemorySegment seg = allocateNoInit(layout); @@ -196,6 +197,7 @@ default MemorySegment allocateFrom(ValueLayout.OfByte layout, byte value) { * @param layout the layout of the block of memory to be allocated * @param value the value to be set in the newly allocated memory segment */ + @ForceInline default MemorySegment allocateFrom(ValueLayout.OfChar layout, char value) { Objects.requireNonNull(layout); MemorySegment seg = allocateNoInit(layout); @@ -221,6 +223,7 @@ default MemorySegment allocateFrom(ValueLayout.OfChar layout, char value) { * @param layout the layout of the block of memory to be allocated * @param value the value to be set in the newly allocated memory segment */ + @ForceInline default MemorySegment allocateFrom(ValueLayout.OfShort layout, short value) { Objects.requireNonNull(layout); MemorySegment seg = allocateNoInit(layout); @@ -246,6 +249,7 @@ default MemorySegment allocateFrom(ValueLayout.OfShort layout, short value) { * @param layout the layout of the block of memory to be allocated * @param value the value to be set in the newly allocated memory segment */ + @ForceInline default MemorySegment allocateFrom(ValueLayout.OfInt layout, int value) { Objects.requireNonNull(layout); MemorySegment seg = allocateNoInit(layout); @@ -271,6 +275,7 @@ default MemorySegment allocateFrom(ValueLayout.OfInt layout, int value) { * @param layout the layout of the block of memory to be allocated * @param value the value to be set in the newly allocated memory segment */ + @ForceInline default MemorySegment allocateFrom(ValueLayout.OfFloat layout, float value) { Objects.requireNonNull(layout); MemorySegment seg = allocateNoInit(layout); @@ -296,6 +301,7 @@ default MemorySegment allocateFrom(ValueLayout.OfFloat layout, float value) { * @param layout the layout of the block of memory to be allocated * @param value the value to be set in the newly allocated memory segment */ + @ForceInline default MemorySegment allocateFrom(ValueLayout.OfLong layout, long value) { Objects.requireNonNull(layout); MemorySegment seg = allocateNoInit(layout); @@ -321,6 +327,7 @@ default MemorySegment allocateFrom(ValueLayout.OfLong layout, long value) { * @param layout the layout of the block of memory to be allocated * @param value the value to be set in the newly allocated memory segment */ + @ForceInline default MemorySegment allocateFrom(ValueLayout.OfDouble layout, double value) { Objects.requireNonNull(layout); MemorySegment seg = allocateNoInit(layout); @@ -353,6 +360,7 @@ default MemorySegment allocateFrom(ValueLayout.OfDouble layout, double value) { * @throws IllegalArgumentException if {@code value} is not * a {@linkplain MemorySegment#isNative() native} segment */ + @ForceInline default MemorySegment allocateFrom(AddressLayout layout, MemorySegment value) { Objects.requireNonNull(value); Objects.requireNonNull(layout); @@ -606,6 +614,7 @@ default MemorySegment allocateFrom(ValueLayout.OfDouble elementLayout, double... * * @param layout the layout of the block of memory to be allocated */ + @ForceInline default MemorySegment allocate(MemoryLayout layout) { Objects.requireNonNull(layout); return allocate(layout.byteSize(), layout.byteAlignment()); @@ -623,6 +632,7 @@ default MemorySegment allocate(MemoryLayout layout) { * overflows * @throws IllegalArgumentException if {@code count < 0} */ + @ForceInline default MemorySegment allocate(MemoryLayout elementLayout, long count) { Objects.requireNonNull(elementLayout); if (count < 0) { @@ -640,6 +650,7 @@ default MemorySegment allocate(MemoryLayout elementLayout, long count) { * @param byteSize the size (in bytes) of the block of memory to be allocated * @throws IllegalArgumentException if {@code byteSize < 0} */ + @ForceInline default MemorySegment allocate(long byteSize) { return allocate(byteSize, 1); }