mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8234049: Implementation of Memory Access API (Incubator)
Co-authored-by: Vlaidmir Ivanov <vladimir.x.ivanov@oracle.com> Reviewed-by: alanb, psandoz, chegar, rriggs, plevart, briangoetz, jrose, adinn, vlivanov
This commit is contained in:
parent
7cdecd8981
commit
8f4f088a12
59 changed files with 7849 additions and 147 deletions
|
@ -28,6 +28,7 @@
|
|||
package java.nio;
|
||||
|
||||
import java.util.Objects;
|
||||
import jdk.internal.access.foreign.MemorySegmentProxy;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
||||
|
@ -40,11 +41,11 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
|
||||
#end[rw]
|
||||
|
||||
ByteBufferAs$Type$Buffer$RW$$BO$(ByteBuffer bb) { // package-private
|
||||
ByteBufferAs$Type$Buffer$RW$$BO$(ByteBuffer bb, MemorySegmentProxy segment) { // package-private
|
||||
#if[rw]
|
||||
super(-1, 0,
|
||||
bb.remaining() >> $LG_BYTES_PER_VALUE$,
|
||||
bb.remaining() >> $LG_BYTES_PER_VALUE$);
|
||||
bb.remaining() >> $LG_BYTES_PER_VALUE$, segment);
|
||||
this.bb = bb;
|
||||
// enforce limit == capacity
|
||||
int cap = this.capacity();
|
||||
|
@ -53,21 +54,21 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
assert (pos <= cap);
|
||||
address = bb.address;
|
||||
#else[rw]
|
||||
super(bb);
|
||||
super(bb, segment);
|
||||
#end[rw]
|
||||
}
|
||||
|
||||
ByteBufferAs$Type$Buffer$RW$$BO$(ByteBuffer bb,
|
||||
int mark, int pos, int lim, int cap,
|
||||
long addr)
|
||||
long addr, MemorySegmentProxy segment)
|
||||
{
|
||||
#if[rw]
|
||||
super(mark, pos, lim, cap);
|
||||
super(mark, pos, lim, cap, segment);
|
||||
this.bb = bb;
|
||||
address = addr;
|
||||
assert address >= bb.address;
|
||||
#else[rw]
|
||||
super(bb, mark, pos, lim, cap, addr);
|
||||
super(bb, mark, pos, lim, cap, addr, segment);
|
||||
#end[rw]
|
||||
}
|
||||
|
||||
|
@ -82,7 +83,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
long addr = byteOffset(pos);
|
||||
return new ByteBufferAs$Type$Buffer$RW$$BO$(bb, -1, 0, rem, rem, addr);
|
||||
return new ByteBufferAs$Type$Buffer$RW$$BO$(bb, -1, 0, rem, rem, addr, segment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,7 +94,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
0,
|
||||
length,
|
||||
length,
|
||||
byteOffset(index));
|
||||
byteOffset(index), segment);
|
||||
}
|
||||
|
||||
public $Type$Buffer duplicate() {
|
||||
|
@ -102,7 +103,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
address);
|
||||
address, segment);
|
||||
}
|
||||
|
||||
public $Type$Buffer asReadOnlyBuffer() {
|
||||
|
@ -112,7 +113,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
this.position(),
|
||||
this.limit(),
|
||||
this.capacity(),
|
||||
address);
|
||||
address, segment);
|
||||
#else[rw]
|
||||
return duplicate();
|
||||
#end[rw]
|
||||
|
@ -130,12 +131,14 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
}
|
||||
|
||||
public $type$ get() {
|
||||
checkSegment();
|
||||
$memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(nextGetIndex()),
|
||||
{#if[boB]?true:false});
|
||||
return $fromBits$(x);
|
||||
}
|
||||
|
||||
public $type$ get(int i) {
|
||||
checkSegment();
|
||||
$memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)),
|
||||
{#if[boB]?true:false});
|
||||
return $fromBits$(x);
|
||||
|
@ -153,6 +156,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
|
||||
public $Type$Buffer put($type$ x) {
|
||||
#if[rw]
|
||||
checkSegment();
|
||||
$memtype$ y = $toBits$(x);
|
||||
UNSAFE.put$Memtype$Unaligned(bb.hb, byteOffset(nextPutIndex()), y,
|
||||
{#if[boB]?true:false});
|
||||
|
@ -164,6 +168,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
|
||||
public $Type$Buffer put(int i, $type$ x) {
|
||||
#if[rw]
|
||||
checkSegment();
|
||||
$memtype$ y = $toBits$(x);
|
||||
UNSAFE.put$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), y,
|
||||
{#if[boB]?true:false});
|
||||
|
@ -237,7 +242,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
|||
pos + start,
|
||||
pos + end,
|
||||
capacity(),
|
||||
address);
|
||||
address, segment);
|
||||
}
|
||||
|
||||
#end[char]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue