Merge
This commit is contained in:
commit
10bc86cc26
@ -77,22 +77,22 @@ public abstract sealed class AbstractMemorySegmentImpl
|
|||||||
|
|
||||||
final long length;
|
final long length;
|
||||||
final boolean readOnly;
|
final boolean readOnly;
|
||||||
final SegmentScope session;
|
final SegmentScope scope;
|
||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
AbstractMemorySegmentImpl(long length, boolean readOnly, SegmentScope session) {
|
AbstractMemorySegmentImpl(long length, boolean readOnly, SegmentScope scope) {
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
this.session = session;
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract AbstractMemorySegmentImpl dup(long offset, long size, boolean readOnly, SegmentScope session);
|
abstract AbstractMemorySegmentImpl dup(long offset, long size, boolean readOnly, SegmentScope scope);
|
||||||
|
|
||||||
abstract ByteBuffer makeByteBuffer();
|
abstract ByteBuffer makeByteBuffer();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractMemorySegmentImpl asReadOnly() {
|
public AbstractMemorySegmentImpl asReadOnly() {
|
||||||
return dup(0, length, true, session);
|
return dup(0, length, true, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -113,7 +113,7 @@ public abstract sealed class AbstractMemorySegmentImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AbstractMemorySegmentImpl asSliceNoCheck(long offset, long newSize) {
|
private AbstractMemorySegmentImpl asSliceNoCheck(long offset, long newSize) {
|
||||||
return dup(offset, newSize, readOnly, session);
|
return dup(offset, newSize, readOnly, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -359,12 +359,12 @@ public abstract sealed class AbstractMemorySegmentImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SegmentScope scope() {
|
public SegmentScope scope() {
|
||||||
return session;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
public final MemorySessionImpl sessionImpl() {
|
public final MemorySessionImpl sessionImpl() {
|
||||||
return (MemorySessionImpl)session;
|
return (MemorySessionImpl)scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IndexOutOfBoundsException outOfBoundException(long offset, long length) {
|
private IndexOutOfBoundsException outOfBoundException(long offset, long length) {
|
||||||
@ -481,11 +481,11 @@ public abstract sealed class AbstractMemorySegmentImpl
|
|||||||
int size = limit - pos;
|
int size = limit - pos;
|
||||||
|
|
||||||
AbstractMemorySegmentImpl bufferSegment = (AbstractMemorySegmentImpl) NIO_ACCESS.bufferSegment(bb);
|
AbstractMemorySegmentImpl bufferSegment = (AbstractMemorySegmentImpl) NIO_ACCESS.bufferSegment(bb);
|
||||||
final SegmentScope bufferSession;
|
final SegmentScope bufferScope;
|
||||||
if (bufferSegment != null) {
|
if (bufferSegment != null) {
|
||||||
bufferSession = bufferSegment.session;
|
bufferScope = bufferSegment.scope;
|
||||||
} else {
|
} else {
|
||||||
bufferSession = MemorySessionImpl.heapSession(bb);
|
bufferScope = MemorySessionImpl.heapSession(bb);
|
||||||
}
|
}
|
||||||
boolean readOnly = bb.isReadOnly();
|
boolean readOnly = bb.isReadOnly();
|
||||||
int scaleFactor = getScaleFactor(bb);
|
int scaleFactor = getScaleFactor(bb);
|
||||||
@ -508,10 +508,10 @@ public abstract sealed class AbstractMemorySegmentImpl
|
|||||||
throw new AssertionError("Cannot get here");
|
throw new AssertionError("Cannot get here");
|
||||||
}
|
}
|
||||||
} else if (unmapper == null) {
|
} else if (unmapper == null) {
|
||||||
return new NativeMemorySegmentImpl(bbAddress + (pos << scaleFactor), size << scaleFactor, readOnly, bufferSession);
|
return new NativeMemorySegmentImpl(bbAddress + (pos << scaleFactor), size << scaleFactor, readOnly, bufferScope);
|
||||||
} else {
|
} else {
|
||||||
// we can ignore scale factor here, a mapped buffer is always a byte buffer, so scaleFactor == 0.
|
// we can ignore scale factor here, a mapped buffer is always a byte buffer, so scaleFactor == 0.
|
||||||
return new MappedMemorySegmentImpl(bbAddress + pos, unmapper, size, readOnly, bufferSession);
|
return new MappedMemorySegmentImpl(bbAddress + pos, unmapper, size, readOnly, bufferScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
abstract HeapMemorySegmentImpl dup(long offset, long size, boolean readOnly, SegmentScope session);
|
abstract HeapMemorySegmentImpl dup(long offset, long size, boolean readOnly, SegmentScope scope);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ByteBuffer makeByteBuffer() {
|
ByteBuffer makeByteBuffer() {
|
||||||
@ -99,7 +99,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
OfByte dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
OfByte dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new OfByte(this.offset + offset, base, size, readOnly);
|
return new OfByte(this.offset + offset, base, size, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
OfChar dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
OfChar dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new OfChar(this.offset + offset, base, size, readOnly);
|
return new OfChar(this.offset + offset, base, size, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
OfShort dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
OfShort dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new OfShort(this.offset + offset, base, size, readOnly);
|
return new OfShort(this.offset + offset, base, size, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
OfInt dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
OfInt dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new OfInt(this.offset + offset, base, size, readOnly);
|
return new OfInt(this.offset + offset, base, size, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
OfLong dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
OfLong dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new OfLong(this.offset + offset, base, size, readOnly);
|
return new OfLong(this.offset + offset, base, size, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
OfFloat dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
OfFloat dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new OfFloat(this.offset + offset, base, size, readOnly);
|
return new OfFloat(this.offset + offset, base, size, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegment
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
OfDouble dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
OfDouble dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new OfDouble(this.offset + offset, base, size, readOnly);
|
return new OfDouble(this.offset + offset, base, size, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,20 +43,20 @@ public sealed class MappedMemorySegmentImpl extends NativeMemorySegmentImpl {
|
|||||||
|
|
||||||
static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess();
|
static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess();
|
||||||
|
|
||||||
public MappedMemorySegmentImpl(long min, UnmapperProxy unmapper, long length, boolean readOnly, SegmentScope session) {
|
public MappedMemorySegmentImpl(long min, UnmapperProxy unmapper, long length, boolean readOnly, SegmentScope scope) {
|
||||||
super(min, length, readOnly, session);
|
super(min, length, readOnly, scope);
|
||||||
this.unmapper = unmapper;
|
this.unmapper = unmapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ByteBuffer makeByteBuffer() {
|
ByteBuffer makeByteBuffer() {
|
||||||
return NIO_ACCESS.newMappedByteBuffer(unmapper, min, (int)length, null,
|
return NIO_ACCESS.newMappedByteBuffer(unmapper, min, (int)length, null,
|
||||||
session == MemorySessionImpl.GLOBAL ? null : this);
|
scope == MemorySessionImpl.GLOBAL ? null : this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
MappedMemorySegmentImpl dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
MappedMemorySegmentImpl dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new MappedMemorySegmentImpl(min + offset, unmapper, size, readOnly, session);
|
return new MappedMemorySegmentImpl(min + offset, unmapper, size, readOnly, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mapped segment methods
|
// mapped segment methods
|
||||||
|
@ -175,9 +175,9 @@ public abstract sealed class MemorySessionImpl
|
|||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean sameOwnerThread(SegmentScope session1, SegmentScope session2) {
|
public static boolean sameOwnerThread(SegmentScope scope1, SegmentScope scope2) {
|
||||||
return ((MemorySessionImpl) session1).ownerThread() ==
|
return ((MemorySessionImpl) scope1).ownerThread() ==
|
||||||
((MemorySessionImpl) session2).ownerThread();
|
((MemorySessionImpl) scope2).ownerThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,8 +52,8 @@ public sealed class NativeMemorySegmentImpl extends AbstractMemorySegmentImpl pe
|
|||||||
final long min;
|
final long min;
|
||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
NativeMemorySegmentImpl(long min, long length, boolean readOnly, SegmentScope session) {
|
NativeMemorySegmentImpl(long min, long length, boolean readOnly, SegmentScope scope) {
|
||||||
super(length, readOnly, session);
|
super(length, readOnly, scope);
|
||||||
this.min = min;
|
this.min = min;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,14 +69,14 @@ public sealed class NativeMemorySegmentImpl extends AbstractMemorySegmentImpl pe
|
|||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
@Override
|
@Override
|
||||||
NativeMemorySegmentImpl dup(long offset, long size, boolean readOnly, SegmentScope session) {
|
NativeMemorySegmentImpl dup(long offset, long size, boolean readOnly, SegmentScope scope) {
|
||||||
return new NativeMemorySegmentImpl(min + offset, size, readOnly, session);
|
return new NativeMemorySegmentImpl(min + offset, size, readOnly, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ByteBuffer makeByteBuffer() {
|
ByteBuffer makeByteBuffer() {
|
||||||
return NIO_ACCESS.newDirectByteBuffer(min, (int) this.length, null,
|
return NIO_ACCESS.newDirectByteBuffer(min, (int) this.length, null,
|
||||||
session == MemorySessionImpl.GLOBAL ? null : this);
|
scope == MemorySessionImpl.GLOBAL ? null : this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -101,8 +101,8 @@ public sealed class NativeMemorySegmentImpl extends AbstractMemorySegmentImpl pe
|
|||||||
|
|
||||||
// factories
|
// factories
|
||||||
|
|
||||||
public static MemorySegment makeNativeSegment(long byteSize, long byteAlignment, SegmentScope session) {
|
public static MemorySegment makeNativeSegment(long byteSize, long byteAlignment, SegmentScope scope) {
|
||||||
MemorySessionImpl sessionImpl = (MemorySessionImpl) session;
|
MemorySessionImpl sessionImpl = (MemorySessionImpl) scope;
|
||||||
sessionImpl.checkValidState();
|
sessionImpl.checkValidState();
|
||||||
if (VM.isDirectMemoryPageAligned()) {
|
if (VM.isDirectMemoryPageAligned()) {
|
||||||
byteAlignment = Math.max(byteAlignment, NIO_ACCESS.pageSize());
|
byteAlignment = Math.max(byteAlignment, NIO_ACCESS.pageSize());
|
||||||
@ -119,7 +119,7 @@ public sealed class NativeMemorySegmentImpl extends AbstractMemorySegmentImpl pe
|
|||||||
}
|
}
|
||||||
long alignedBuf = Utils.alignUp(buf, byteAlignment);
|
long alignedBuf = Utils.alignUp(buf, byteAlignment);
|
||||||
AbstractMemorySegmentImpl segment = new NativeMemorySegmentImpl(buf, alignedSize,
|
AbstractMemorySegmentImpl segment = new NativeMemorySegmentImpl(buf, alignedSize,
|
||||||
false, session);
|
false, scope);
|
||||||
sessionImpl.addOrCleanupIfFail(new MemorySessionImpl.ResourceList.ResourceCleanup() {
|
sessionImpl.addOrCleanupIfFail(new MemorySessionImpl.ResourceList.ResourceCleanup() {
|
||||||
@Override
|
@Override
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
@ -138,21 +138,21 @@ public sealed class NativeMemorySegmentImpl extends AbstractMemorySegmentImpl pe
|
|||||||
// associated with MemorySegment::ofAddress.
|
// associated with MemorySegment::ofAddress.
|
||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
public static MemorySegment makeNativeSegmentUnchecked(long min, long byteSize, SegmentScope session, Runnable action) {
|
public static MemorySegment makeNativeSegmentUnchecked(long min, long byteSize, SegmentScope scope, Runnable action) {
|
||||||
MemorySessionImpl sessionImpl = (MemorySessionImpl) session;
|
MemorySessionImpl sessionImpl = (MemorySessionImpl) scope;
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
sessionImpl.checkValidState();
|
sessionImpl.checkValidState();
|
||||||
} else {
|
} else {
|
||||||
sessionImpl.addCloseAction(action);
|
sessionImpl.addCloseAction(action);
|
||||||
}
|
}
|
||||||
return new NativeMemorySegmentImpl(min, byteSize, false, session);
|
return new NativeMemorySegmentImpl(min, byteSize, false, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
public static MemorySegment makeNativeSegmentUnchecked(long min, long byteSize, SegmentScope session) {
|
public static MemorySegment makeNativeSegmentUnchecked(long min, long byteSize, SegmentScope scope) {
|
||||||
MemorySessionImpl sessionImpl = (MemorySessionImpl) session;
|
MemorySessionImpl sessionImpl = (MemorySessionImpl) scope;
|
||||||
sessionImpl.checkValidState();
|
sessionImpl.checkValidState();
|
||||||
return new NativeMemorySegmentImpl(min, byteSize, false, session);
|
return new NativeMemorySegmentImpl(min, byteSize, false, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ForceInline
|
@ForceInline
|
||||||
|
@ -202,19 +202,19 @@ public interface Binding {
|
|||||||
*/
|
*/
|
||||||
class Context implements AutoCloseable {
|
class Context implements AutoCloseable {
|
||||||
private final SegmentAllocator allocator;
|
private final SegmentAllocator allocator;
|
||||||
private final SegmentScope session;
|
private final SegmentScope scope;
|
||||||
|
|
||||||
private Context(SegmentAllocator allocator, SegmentScope session) {
|
private Context(SegmentAllocator allocator, SegmentScope scope) {
|
||||||
this.allocator = allocator;
|
this.allocator = allocator;
|
||||||
this.session = session;
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SegmentAllocator allocator() {
|
public SegmentAllocator allocator() {
|
||||||
return allocator;
|
return allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SegmentScope session() {
|
public SegmentScope scope() {
|
||||||
return session;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -242,7 +242,7 @@ public interface Binding {
|
|||||||
public static Context ofAllocator(SegmentAllocator allocator) {
|
public static Context ofAllocator(SegmentAllocator allocator) {
|
||||||
return new Context(allocator, null) {
|
return new Context(allocator, null) {
|
||||||
@Override
|
@Override
|
||||||
public SegmentScope session() {
|
public SegmentScope scope() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -252,7 +252,7 @@ public interface Binding {
|
|||||||
* Create a binding context from given scope. The resulting context will throw when
|
* Create a binding context from given scope. The resulting context will throw when
|
||||||
* the context's allocator is accessed.
|
* the context's allocator is accessed.
|
||||||
*/
|
*/
|
||||||
public static Context ofSession() {
|
public static Context ofScope() {
|
||||||
Arena arena = Arena.openConfined();
|
Arena arena = Arena.openConfined();
|
||||||
return new Context(null, arena.scope()) {
|
return new Context(null, arena.scope()) {
|
||||||
@Override
|
@Override
|
||||||
@ -276,7 +276,7 @@ public interface Binding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SegmentScope session() {
|
public SegmentScope scope() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,10 +678,10 @@ public interface Binding {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* BOX_ADDRESS()
|
* BOX_ADDRESS()
|
||||||
* Pops a 'long' from the operand stack, converts it to a 'MemorySegment', with the given size and memory session
|
* Pops a 'long' from the operand stack, converts it to a 'MemorySegment', with the given size and memory scope
|
||||||
* (either the context session, or the global session), and pushes that onto the operand stack.
|
* (either the context scope, or the global scope), and pushes that onto the operand stack.
|
||||||
*/
|
*/
|
||||||
record BoxAddress(long size, boolean needsSession) implements Binding {
|
record BoxAddress(long size, boolean needsScope) implements Binding {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tag tag() {
|
public Tag tag() {
|
||||||
@ -698,9 +698,9 @@ public interface Binding {
|
|||||||
@Override
|
@Override
|
||||||
public void interpret(Deque<Object> stack, BindingInterpreter.StoreFunc storeFunc,
|
public void interpret(Deque<Object> stack, BindingInterpreter.StoreFunc storeFunc,
|
||||||
BindingInterpreter.LoadFunc loadFunc, Context context) {
|
BindingInterpreter.LoadFunc loadFunc, Context context) {
|
||||||
SegmentScope session = needsSession ?
|
SegmentScope scope = needsScope ?
|
||||||
context.session() : SegmentScope.global();
|
context.scope() : SegmentScope.global();
|
||||||
stack.push(NativeMemorySegmentImpl.makeNativeSegmentUnchecked((long) stack.pop(), size, session));
|
stack.push(NativeMemorySegmentImpl.makeNativeSegmentUnchecked((long) stack.pop(), size, scope));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ public class BindingSpecializer {
|
|||||||
|
|
||||||
private static final String BINDING_CONTEXT_DESC = Binding.Context.class.descriptorString();
|
private static final String BINDING_CONTEXT_DESC = Binding.Context.class.descriptorString();
|
||||||
private static final String OF_BOUNDED_ALLOCATOR_DESC = methodType(Binding.Context.class, long.class).descriptorString();
|
private static final String OF_BOUNDED_ALLOCATOR_DESC = methodType(Binding.Context.class, long.class).descriptorString();
|
||||||
private static final String OF_SESSION_DESC = methodType(Binding.Context.class).descriptorString();
|
private static final String OF_SCOPE_DESC = methodType(Binding.Context.class).descriptorString();
|
||||||
private static final String ALLOCATOR_DESC = methodType(SegmentAllocator.class).descriptorString();
|
private static final String ALLOCATOR_DESC = methodType(SegmentAllocator.class).descriptorString();
|
||||||
private static final String SESSION_DESC = methodType(SegmentScope.class).descriptorString();
|
private static final String SCOPE_DESC = methodType(SegmentScope.class).descriptorString();
|
||||||
private static final String SESSION_IMPL_DESC = methodType(MemorySessionImpl.class).descriptorString();
|
private static final String SESSION_IMPL_DESC = methodType(MemorySessionImpl.class).descriptorString();
|
||||||
private static final String CLOSE_DESC = VOID_DESC;
|
private static final String CLOSE_DESC = VOID_DESC;
|
||||||
private static final String UNBOX_SEGMENT_DESC = methodType(long.class, MemorySegment.class).descriptorString();
|
private static final String UNBOX_SEGMENT_DESC = methodType(long.class, MemorySegment.class).descriptorString();
|
||||||
@ -294,7 +294,7 @@ public class BindingSpecializer {
|
|||||||
emitConst(callingSequence.allocationSize());
|
emitConst(callingSequence.allocationSize());
|
||||||
emitInvokeStatic(Binding.Context.class, "ofBoundedAllocator", OF_BOUNDED_ALLOCATOR_DESC);
|
emitInvokeStatic(Binding.Context.class, "ofBoundedAllocator", OF_BOUNDED_ALLOCATOR_DESC);
|
||||||
} else if (callingSequence.forUpcall() && needsSession()) {
|
} else if (callingSequence.forUpcall() && needsSession()) {
|
||||||
emitInvokeStatic(Binding.Context.class, "ofSession", OF_SESSION_DESC);
|
emitInvokeStatic(Binding.Context.class, "ofScope", OF_SCOPE_DESC);
|
||||||
} else {
|
} else {
|
||||||
emitGetStatic(Binding.Context.class, "DUMMY", BINDING_CONTEXT_DESC);
|
emitGetStatic(Binding.Context.class, "DUMMY", BINDING_CONTEXT_DESC);
|
||||||
}
|
}
|
||||||
@ -436,7 +436,7 @@ public class BindingSpecializer {
|
|||||||
return callingSequence.argumentBindings()
|
return callingSequence.argumentBindings()
|
||||||
.filter(Binding.BoxAddress.class::isInstance)
|
.filter(Binding.BoxAddress.class::isInstance)
|
||||||
.map(Binding.BoxAddress.class::cast)
|
.map(Binding.BoxAddress.class::cast)
|
||||||
.anyMatch(Binding.BoxAddress::needsSession);
|
.anyMatch(Binding.BoxAddress::needsScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldAcquire(int paramIndex) {
|
private boolean shouldAcquire(int paramIndex) {
|
||||||
@ -561,7 +561,7 @@ public class BindingSpecializer {
|
|||||||
private void emitLoadInternalSession() {
|
private void emitLoadInternalSession() {
|
||||||
assert contextIdx != -1;
|
assert contextIdx != -1;
|
||||||
emitLoad(Object.class, contextIdx);
|
emitLoad(Object.class, contextIdx);
|
||||||
emitInvokeVirtual(Binding.Context.class, "session", SESSION_DESC);
|
emitInvokeVirtual(Binding.Context.class, "scope", SCOPE_DESC);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void emitLoadInternalAllocator() {
|
private void emitLoadInternalAllocator() {
|
||||||
|
@ -288,21 +288,21 @@ public final class SharedUtils {
|
|||||||
throw new IllegalArgumentException("Symbol is NULL: " + symbol);
|
throw new IllegalArgumentException("Symbol is NULL: " + symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope session) {
|
public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope scope) {
|
||||||
return switch (CABI.current()) {
|
return switch (CABI.current()) {
|
||||||
case WIN_64 -> Windowsx64Linker.newVaList(actions, session);
|
case WIN_64 -> Windowsx64Linker.newVaList(actions, scope);
|
||||||
case SYS_V -> SysVx64Linker.newVaList(actions, session);
|
case SYS_V -> SysVx64Linker.newVaList(actions, scope);
|
||||||
case LINUX_AARCH_64 -> LinuxAArch64Linker.newVaList(actions, session);
|
case LINUX_AARCH_64 -> LinuxAArch64Linker.newVaList(actions, scope);
|
||||||
case MAC_OS_AARCH_64 -> MacOsAArch64Linker.newVaList(actions, session);
|
case MAC_OS_AARCH_64 -> MacOsAArch64Linker.newVaList(actions, scope);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList newVaListOfAddress(long address, SegmentScope session) {
|
public static VaList newVaListOfAddress(long address, SegmentScope scope) {
|
||||||
return switch (CABI.current()) {
|
return switch (CABI.current()) {
|
||||||
case WIN_64 -> Windowsx64Linker.newVaListOfAddress(address, session);
|
case WIN_64 -> Windowsx64Linker.newVaListOfAddress(address, scope);
|
||||||
case SYS_V -> SysVx64Linker.newVaListOfAddress(address, session);
|
case SYS_V -> SysVx64Linker.newVaListOfAddress(address, scope);
|
||||||
case LINUX_AARCH_64 -> LinuxAArch64Linker.newVaListOfAddress(address, session);
|
case LINUX_AARCH_64 -> LinuxAArch64Linker.newVaListOfAddress(address, scope);
|
||||||
case MAC_OS_AARCH_64 -> MacOsAArch64Linker.newVaListOfAddress(address, session);
|
case MAC_OS_AARCH_64 -> MacOsAArch64Linker.newVaListOfAddress(address, scope);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class UpcallLinker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MemorySegment make(ABIDescriptor abi, MethodHandle target, CallingSequence callingSequence, SegmentScope session) {
|
public static MemorySegment make(ABIDescriptor abi, MethodHandle target, CallingSequence callingSequence, SegmentScope scope) {
|
||||||
assert callingSequence.forUpcall();
|
assert callingSequence.forUpcall();
|
||||||
Binding.VMLoad[] argMoves = argMoveBindings(callingSequence);
|
Binding.VMLoad[] argMoves = argMoveBindings(callingSequence);
|
||||||
Binding.VMStore[] retMoves = retMoveBindings(callingSequence);
|
Binding.VMStore[] retMoves = retMoveBindings(callingSequence);
|
||||||
@ -93,7 +93,7 @@ public class UpcallLinker {
|
|||||||
CallRegs conv = new CallRegs(args, rets);
|
CallRegs conv = new CallRegs(args, rets);
|
||||||
long entryPoint = makeUpcallStub(doBindings, abi, conv,
|
long entryPoint = makeUpcallStub(doBindings, abi, conv,
|
||||||
callingSequence.needsReturnBuffer(), callingSequence.returnBufferSize());
|
callingSequence.needsReturnBuffer(), callingSequence.returnBufferSize());
|
||||||
return UpcallStubs.makeUpcall(entryPoint, session);
|
return UpcallStubs.makeUpcall(entryPoint, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkPrimitive(MethodType type) {
|
private static void checkPrimitive(MethodType type) {
|
||||||
@ -130,7 +130,7 @@ public class UpcallLinker {
|
|||||||
private static Object invokeInterpBindings(Object[] lowLevelArgs, InvocationData invData) throws Throwable {
|
private static Object invokeInterpBindings(Object[] lowLevelArgs, InvocationData invData) throws Throwable {
|
||||||
Binding.Context allocator = invData.callingSequence.allocationSize() != 0
|
Binding.Context allocator = invData.callingSequence.allocationSize() != 0
|
||||||
? Binding.Context.ofBoundedAllocator(invData.callingSequence.allocationSize())
|
? Binding.Context.ofBoundedAllocator(invData.callingSequence.allocationSize())
|
||||||
: Binding.Context.ofSession();
|
: Binding.Context.ofScope();
|
||||||
try (allocator) {
|
try (allocator) {
|
||||||
/// Invoke interpreter, got array of high-level arguments back
|
/// Invoke interpreter, got array of high-level arguments back
|
||||||
Object[] highLevelArgs = new Object[invData.callingSequence.calleeMethodType().parameterCount()];
|
Object[] highLevelArgs = new Object[invData.callingSequence.calleeMethodType().parameterCount()];
|
||||||
|
@ -50,13 +50,13 @@ public final class UpcallStubs {
|
|||||||
registerNatives();
|
registerNatives();
|
||||||
}
|
}
|
||||||
|
|
||||||
static MemorySegment makeUpcall(long entry, SegmentScope session) {
|
static MemorySegment makeUpcall(long entry, SegmentScope scope) {
|
||||||
((MemorySessionImpl) session).addOrCleanupIfFail(new MemorySessionImpl.ResourceList.ResourceCleanup() {
|
((MemorySessionImpl) scope).addOrCleanupIfFail(new MemorySessionImpl.ResourceList.ResourceCleanup() {
|
||||||
@Override
|
@Override
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
freeUpcallStub(entry);
|
freeUpcallStub(entry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return MemorySegment.ofAddress(entry, 0, session);
|
return MemorySegment.ofAddress(entry, 0, scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,14 @@ public final class LinuxAArch64Linker extends AbstractLinker {
|
|||||||
return CallArranger.LINUX.arrangeUpcall(target, targetType, function, scope);
|
return CallArranger.LINUX.arrangeUpcall(target, targetType, function, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope session) {
|
public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope scope) {
|
||||||
LinuxAArch64VaList.Builder builder = LinuxAArch64VaList.builder(session);
|
LinuxAArch64VaList.Builder builder = LinuxAArch64VaList.builder(scope);
|
||||||
actions.accept(builder);
|
actions.accept(builder);
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList newVaListOfAddress(long address, SegmentScope session) {
|
public static VaList newVaListOfAddress(long address, SegmentScope scope) {
|
||||||
return LinuxAArch64VaList.ofAddress(address, session);
|
return LinuxAArch64VaList.ofAddress(address, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList emptyVaList() {
|
public static VaList emptyVaList() {
|
||||||
|
@ -120,11 +120,11 @@ public non-sealed class LinuxAArch64VaList implements VaList {
|
|||||||
this.fpLimit = fpLimit;
|
this.fpLimit = fpLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LinuxAArch64VaList readFromAddress(long address, SegmentScope session) {
|
private static LinuxAArch64VaList readFromAddress(long address, SegmentScope scope) {
|
||||||
MemorySegment segment = MemorySegment.ofAddress(address, LAYOUT.byteSize(), session);
|
MemorySegment segment = MemorySegment.ofAddress(address, LAYOUT.byteSize(), scope);
|
||||||
MemorySegment stack = stackPtr(segment); // size unknown
|
MemorySegment stack = stackPtr(segment); // size unknown
|
||||||
MemorySegment gpRegsArea = MemorySegment.ofAddress(grTop(segment).address() - MAX_GP_OFFSET, MAX_GP_OFFSET, session);
|
MemorySegment gpRegsArea = MemorySegment.ofAddress(grTop(segment).address() - MAX_GP_OFFSET, MAX_GP_OFFSET, scope);
|
||||||
MemorySegment fpRegsArea = MemorySegment.ofAddress(vrTop(segment).address() - MAX_FP_OFFSET, MAX_FP_OFFSET, session);
|
MemorySegment fpRegsArea = MemorySegment.ofAddress(vrTop(segment).address() - MAX_FP_OFFSET, MAX_FP_OFFSET, scope);
|
||||||
return new LinuxAArch64VaList(segment, stack, gpRegsArea, MAX_GP_OFFSET, fpRegsArea, MAX_FP_OFFSET);
|
return new LinuxAArch64VaList(segment, stack, gpRegsArea, MAX_GP_OFFSET, fpRegsArea, MAX_FP_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,12 +384,12 @@ public non-sealed class LinuxAArch64VaList implements VaList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static LinuxAArch64VaList.Builder builder(SegmentScope session) {
|
static LinuxAArch64VaList.Builder builder(SegmentScope scope) {
|
||||||
return new LinuxAArch64VaList.Builder(session);
|
return new LinuxAArch64VaList.Builder(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList ofAddress(long address, SegmentScope session) {
|
public static VaList ofAddress(long address, SegmentScope scope) {
|
||||||
return readFromAddress(address, session);
|
return readFromAddress(address, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -432,7 +432,7 @@ public non-sealed class LinuxAArch64VaList implements VaList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static non-sealed class Builder implements VaList.Builder {
|
public static non-sealed class Builder implements VaList.Builder {
|
||||||
private final SegmentScope session;
|
private final SegmentScope scope;
|
||||||
private final MemorySegment gpRegs;
|
private final MemorySegment gpRegs;
|
||||||
private final MemorySegment fpRegs;
|
private final MemorySegment fpRegs;
|
||||||
|
|
||||||
@ -440,10 +440,10 @@ public non-sealed class LinuxAArch64VaList implements VaList {
|
|||||||
private long currentFPOffset = 0;
|
private long currentFPOffset = 0;
|
||||||
private final List<SimpleVaArg> stackArgs = new ArrayList<>();
|
private final List<SimpleVaArg> stackArgs = new ArrayList<>();
|
||||||
|
|
||||||
Builder(SegmentScope session) {
|
Builder(SegmentScope scope) {
|
||||||
this.session = session;
|
this.scope = scope;
|
||||||
this.gpRegs = MemorySegment.allocateNative(LAYOUT_GP_REGS, session);
|
this.gpRegs = MemorySegment.allocateNative(LAYOUT_GP_REGS, scope);
|
||||||
this.fpRegs = MemorySegment.allocateNative(LAYOUT_FP_REGS, session);
|
this.fpRegs = MemorySegment.allocateNative(LAYOUT_FP_REGS, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -536,12 +536,12 @@ public non-sealed class LinuxAArch64VaList implements VaList {
|
|||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemorySegment vaListSegment = MemorySegment.allocateNative(LAYOUT, session);
|
MemorySegment vaListSegment = MemorySegment.allocateNative(LAYOUT, scope);
|
||||||
MemorySegment stackArgsSegment;
|
MemorySegment stackArgsSegment;
|
||||||
if (!stackArgs.isEmpty()) {
|
if (!stackArgs.isEmpty()) {
|
||||||
long stackArgsSize = stackArgs.stream()
|
long stackArgsSize = stackArgs.stream()
|
||||||
.reduce(0L, (acc, e) -> acc + Utils.alignUp(e.layout.byteSize(), STACK_SLOT_SIZE), Long::sum);
|
.reduce(0L, (acc, e) -> acc + Utils.alignUp(e.layout.byteSize(), STACK_SLOT_SIZE), Long::sum);
|
||||||
stackArgsSegment = MemorySegment.allocateNative(stackArgsSize, 16, session);
|
stackArgsSegment = MemorySegment.allocateNative(stackArgsSize, 16, scope);
|
||||||
MemorySegment writeCursor = stackArgsSegment;
|
MemorySegment writeCursor = stackArgsSegment;
|
||||||
for (SimpleVaArg arg : stackArgs) {
|
for (SimpleVaArg arg : stackArgs) {
|
||||||
final long alignedSize = Utils.alignUp(arg.layout.byteSize(), STACK_SLOT_SIZE);
|
final long alignedSize = Utils.alignUp(arg.layout.byteSize(), STACK_SLOT_SIZE);
|
||||||
|
@ -65,14 +65,14 @@ public final class MacOsAArch64Linker extends AbstractLinker {
|
|||||||
return CallArranger.MACOS.arrangeUpcall(target, targetType, function, scope);
|
return CallArranger.MACOS.arrangeUpcall(target, targetType, function, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope session) {
|
public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope scope) {
|
||||||
MacOsAArch64VaList.Builder builder = MacOsAArch64VaList.builder(session);
|
MacOsAArch64VaList.Builder builder = MacOsAArch64VaList.builder(scope);
|
||||||
actions.accept(builder);
|
actions.accept(builder);
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList newVaListOfAddress(long address, SegmentScope session) {
|
public static VaList newVaListOfAddress(long address, SegmentScope scope) {
|
||||||
return MacOsAArch64VaList.ofAddress(address, session);
|
return MacOsAArch64VaList.ofAddress(address, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList emptyVaList() {
|
public static VaList emptyVaList() {
|
||||||
|
@ -132,14 +132,14 @@ public class CallArranger {
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
|
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope scope) {
|
||||||
Bindings bindings = getBindings(mt, cDesc, true);
|
Bindings bindings = getBindings(mt, cDesc, true);
|
||||||
|
|
||||||
if (bindings.isInMemoryReturn) {
|
if (bindings.isInMemoryReturn) {
|
||||||
target = SharedUtils.adaptUpcallForIMR(target, true /* drop return, since we don't have bindings for it */);
|
target = SharedUtils.adaptUpcallForIMR(target, true /* drop return, since we don't have bindings for it */);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UpcallLinker.make(CSysV, target, bindings.callingSequence, session);
|
return UpcallLinker.make(CSysV, target, bindings.callingSequence, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {
|
private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {
|
||||||
|
@ -130,8 +130,8 @@ public non-sealed class SysVVaList implements VaList {
|
|||||||
this.fpLimit = fpLimit;
|
this.fpLimit = fpLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SysVVaList readFromAddress(long address, SegmentScope session) {
|
private static SysVVaList readFromAddress(long address, SegmentScope scope) {
|
||||||
MemorySegment segment = MemorySegment.ofAddress(address, LAYOUT.byteSize(), session);
|
MemorySegment segment = MemorySegment.ofAddress(address, LAYOUT.byteSize(), scope);
|
||||||
MemorySegment regSaveArea = getRegSaveArea(segment);
|
MemorySegment regSaveArea = getRegSaveArea(segment);
|
||||||
MemorySegment overflowArgArea = getArgOverflowArea(segment);
|
MemorySegment overflowArgArea = getArgOverflowArea(segment);
|
||||||
return new SysVVaList(segment, overflowArgArea, regSaveArea, MAX_GP_OFFSET, MAX_FP_OFFSET);
|
return new SysVVaList(segment, overflowArgArea, regSaveArea, MAX_GP_OFFSET, MAX_FP_OFFSET);
|
||||||
@ -322,12 +322,12 @@ public non-sealed class SysVVaList implements VaList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SysVVaList.Builder builder(SegmentScope session) {
|
static SysVVaList.Builder builder(SegmentScope scope) {
|
||||||
return new SysVVaList.Builder(session);
|
return new SysVVaList.Builder(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList ofAddress(long address, SegmentScope session) {
|
public static VaList ofAddress(long address, SegmentScope scope) {
|
||||||
return readFromAddress(address, session);
|
return readFromAddress(address, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -359,15 +359,15 @@ public non-sealed class SysVVaList implements VaList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static non-sealed class Builder implements VaList.Builder {
|
public static non-sealed class Builder implements VaList.Builder {
|
||||||
private final SegmentScope session;
|
private final SegmentScope scope;
|
||||||
private final MemorySegment reg_save_area;
|
private final MemorySegment reg_save_area;
|
||||||
private long currentGPOffset = 0;
|
private long currentGPOffset = 0;
|
||||||
private long currentFPOffset = FP_OFFSET;
|
private long currentFPOffset = FP_OFFSET;
|
||||||
private final List<SimpleVaArg> stackArgs = new ArrayList<>();
|
private final List<SimpleVaArg> stackArgs = new ArrayList<>();
|
||||||
|
|
||||||
public Builder(SegmentScope session) {
|
public Builder(SegmentScope scope) {
|
||||||
this.session = session;
|
this.scope = scope;
|
||||||
this.reg_save_area = MemorySegment.allocateNative(LAYOUT_REG_SAVE_AREA, session);
|
this.reg_save_area = MemorySegment.allocateNative(LAYOUT_REG_SAVE_AREA, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -446,12 +446,12 @@ public non-sealed class SysVVaList implements VaList {
|
|||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemorySegment vaListSegment = MemorySegment.allocateNative(LAYOUT, session);
|
MemorySegment vaListSegment = MemorySegment.allocateNative(LAYOUT, scope);
|
||||||
MemorySegment stackArgsSegment;
|
MemorySegment stackArgsSegment;
|
||||||
if (!stackArgs.isEmpty()) {
|
if (!stackArgs.isEmpty()) {
|
||||||
long stackArgsSize = stackArgs.stream().reduce(0L,
|
long stackArgsSize = stackArgs.stream().reduce(0L,
|
||||||
(acc, e) -> acc + Utils.alignUp(e.layout.byteSize(), STACK_SLOT_SIZE), Long::sum);
|
(acc, e) -> acc + Utils.alignUp(e.layout.byteSize(), STACK_SLOT_SIZE), Long::sum);
|
||||||
stackArgsSegment = MemorySegment.allocateNative(stackArgsSize, 16, session);
|
stackArgsSegment = MemorySegment.allocateNative(stackArgsSize, 16, scope);
|
||||||
MemorySegment writeCursor = stackArgsSegment;
|
MemorySegment writeCursor = stackArgsSegment;
|
||||||
for (SimpleVaArg arg : stackArgs) {
|
for (SimpleVaArg arg : stackArgs) {
|
||||||
if (arg.layout.byteSize() > 8) {
|
if (arg.layout.byteSize() > 8) {
|
||||||
|
@ -68,8 +68,8 @@ public final class SysVx64Linker extends AbstractLinker {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList newVaListOfAddress(long address, SegmentScope session) {
|
public static VaList newVaListOfAddress(long address, SegmentScope scope) {
|
||||||
return SysVVaList.ofAddress(address, session);
|
return SysVVaList.ofAddress(address, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList emptyVaList() {
|
public static VaList emptyVaList() {
|
||||||
|
@ -131,14 +131,14 @@ public class CallArranger {
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
|
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope scope) {
|
||||||
Bindings bindings = getBindings(mt, cDesc, true);
|
Bindings bindings = getBindings(mt, cDesc, true);
|
||||||
|
|
||||||
if (bindings.isInMemoryReturn) {
|
if (bindings.isInMemoryReturn) {
|
||||||
target = SharedUtils.adaptUpcallForIMR(target, false /* need the return value as well */);
|
target = SharedUtils.adaptUpcallForIMR(target, false /* need the return value as well */);
|
||||||
}
|
}
|
||||||
|
|
||||||
return UpcallLinker.make(CWindows, target, bindings.callingSequence, session);
|
return UpcallLinker.make(CWindows, target, bindings.callingSequence, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {
|
private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {
|
||||||
|
@ -149,12 +149,12 @@ public non-sealed class WinVaList implements VaList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static WinVaList ofAddress(long address, SegmentScope session) {
|
static WinVaList ofAddress(long address, SegmentScope scope) {
|
||||||
return new WinVaList(MemorySegment.ofAddress(address, Long.MAX_VALUE, session));
|
return new WinVaList(MemorySegment.ofAddress(address, Long.MAX_VALUE, scope));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Builder builder(SegmentScope session) {
|
static Builder builder(SegmentScope scope) {
|
||||||
return new Builder(session);
|
return new Builder(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -171,12 +171,12 @@ public non-sealed class WinVaList implements VaList {
|
|||||||
|
|
||||||
public static non-sealed class Builder implements VaList.Builder {
|
public static non-sealed class Builder implements VaList.Builder {
|
||||||
|
|
||||||
private final SegmentScope session;
|
private final SegmentScope scope;
|
||||||
private final List<SimpleVaArg> args = new ArrayList<>();
|
private final List<SimpleVaArg> args = new ArrayList<>();
|
||||||
|
|
||||||
public Builder(SegmentScope session) {
|
public Builder(SegmentScope scope) {
|
||||||
((MemorySessionImpl) session).checkValidState();
|
((MemorySessionImpl) scope).checkValidState();
|
||||||
this.session = session;
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder arg(MemoryLayout layout, Object value) {
|
private Builder arg(MemoryLayout layout, Object value) {
|
||||||
@ -216,7 +216,7 @@ public non-sealed class WinVaList implements VaList {
|
|||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemorySegment segment = MemorySegment.allocateNative(VA_SLOT_SIZE_BYTES * args.size(), session);
|
MemorySegment segment = MemorySegment.allocateNative(VA_SLOT_SIZE_BYTES * args.size(), scope);
|
||||||
MemorySegment cursor = segment;
|
MemorySegment cursor = segment;
|
||||||
|
|
||||||
for (SimpleVaArg arg : args) {
|
for (SimpleVaArg arg : args) {
|
||||||
@ -225,7 +225,7 @@ public non-sealed class WinVaList implements VaList {
|
|||||||
TypeClass typeClass = TypeClass.typeClassFor(arg.layout, false);
|
TypeClass typeClass = TypeClass.typeClassFor(arg.layout, false);
|
||||||
switch (typeClass) {
|
switch (typeClass) {
|
||||||
case STRUCT_REFERENCE -> {
|
case STRUCT_REFERENCE -> {
|
||||||
MemorySegment copy = MemorySegment.allocateNative(arg.layout, session);
|
MemorySegment copy = MemorySegment.allocateNative(arg.layout, scope);
|
||||||
copy.copyFrom(msArg); // by-value
|
copy.copyFrom(msArg); // by-value
|
||||||
VH_address.set(cursor, copy);
|
VH_address.set(cursor, copy);
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,8 @@ public final class Windowsx64Linker extends AbstractLinker {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList newVaListOfAddress(long address, SegmentScope session) {
|
public static VaList newVaListOfAddress(long address, SegmentScope scope) {
|
||||||
return WinVaList.ofAddress(address, session);
|
return WinVaList.ofAddress(address, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VaList emptyVaList() {
|
public static VaList emptyVaList() {
|
||||||
|
@ -30,7 +30,7 @@ package gc;
|
|||||||
* @comment Shenandoah has "ExplicitGCInvokesConcurrent" on by default
|
* @comment Shenandoah has "ExplicitGCInvokesConcurrent" on by default
|
||||||
* @requires !(vm.gc == "Shenandoah" & vm.opt.ExplicitGCInvokesConcurrent != false)
|
* @requires !(vm.gc == "Shenandoah" & vm.opt.ExplicitGCInvokesConcurrent != false)
|
||||||
* @comment G1 has separate counters for STW Full GC and concurrent GC.
|
* @comment G1 has separate counters for STW Full GC and concurrent GC.
|
||||||
* @requires !(vm.gc == "G1" & vm.opt.ExplicitGCInvokesConcurrent)
|
* @requires !(vm.gc.G1 & vm.opt.ExplicitGCInvokesConcurrent == true)
|
||||||
* @requires vm.gc != "Z"
|
* @requires vm.gc != "Z"
|
||||||
* @modules java.management
|
* @modules java.management
|
||||||
* @run main/othervm -Xlog:gc gc.TestFullGCCount
|
* @run main/othervm -Xlog:gc gc.TestFullGCCount
|
||||||
|
Loading…
x
Reference in New Issue
Block a user