Skip to content

Commit

Permalink
Implement InteropLibrary#readBuffer on a new object SharedInterop.
Browse files Browse the repository at this point in the history
  • Loading branch information
jchalou committed Nov 27, 2023
1 parent 2c17ca6 commit ae38af4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public enum Message {
IsBufferWritable,
GetBufferSize,
ReadBufferByte,
ReadBuffer,
WriteBufferByte,
ReadBufferShort,
WriteBufferShort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,23 @@ public static byte readBufferByte(StaticObject receiver, long byteOffset,
throw unsupported();
}

@ExportMessage
public static byte readBuffer(StaticObject receiver, long byteOffset, byte[] destination, int destinationOffset, int length,
@Cached IndirectCallNode callNode,
@Cached CallSharedInteropMessage sharedCallNode) throws UnsupportedMessageException {
int dispatchId = receiver.getKlass().getDispatchId();
InteropMessage.Message message = InteropMessage.Message.ReadBuffer;
if (InteropMessageFactories.isShareable(dispatchId, message)) {
dispatchId = InteropMessageFactories.sourceDispatch(dispatchId, message);
return (byte) sharedCallNode.call(dispatchId, message, receiver, byteOffset, destination, destinationOffset, length);
}
CallTarget target = getTarget(receiver, InteropMessage.Message.ReadBuffer);
if (target != null) {
return (byte) callNode.call(target, receiver, byteOffset);
}
throw unsupported();
}

@ExportMessage
public static void writeBufferByte(StaticObject receiver, long byteOffset, byte value,
@Cached IndirectCallNode callNode,
Expand Down

0 comments on commit ae38af4

Please sign in to comment.