Skip to content

Commit 46f23ab

Browse files
committed
EmulatedPosixSupport: remove artificial Truffle boundaries on mmap messages
1 parent e84b253 commit 46f23ab

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,8 +1921,6 @@ public void finish() {
19211921
}
19221922
}
19231923

1924-
// Note: all the mmap related messages are behind Truffle boundary until GR-29663 is resolved
1925-
19261924
public static final class MMapHandle {
19271925
private static final MMapHandle NONE = new MMapHandle(null, 0);
19281926
private SeekableByteChannel channel;
@@ -2004,7 +2002,6 @@ public SeekableByteChannel truncate(long size) throws IOException {
20042002

20052003
@ExportMessage
20062004
@SuppressWarnings("static-method")
2007-
@TruffleBoundary
20082005
final MMapHandle mmap(long length, int prot, int flags, int fd, long offset,
20092006
@Shared("defaultDirProfile") @Cached ConditionProfile isAnonymousProfile) throws PosixException {
20102007
if (prot == PROT_NONE) {
@@ -2058,7 +2055,6 @@ private static SeekableByteChannel newByteChannel(TruffleFile file, Set<Standard
20582055

20592056
@ExportMessage
20602057
@SuppressWarnings("static-method")
2061-
@TruffleBoundary
20622058
public byte mmapReadByte(Object mmap, long index,
20632059
@Shared("errorBranch") @Cached BranchProfile errBranch) throws PosixException {
20642060
if (mmap == MMapHandle.NONE) {
@@ -2076,7 +2072,6 @@ public byte mmapReadByte(Object mmap, long index,
20762072

20772073
@ExportMessage
20782074
@SuppressWarnings("static-method")
2079-
@TruffleBoundary
20802075
public int mmapReadBytes(Object mmap, long index, byte[] bytes, int length,
20812076
@Shared("errorBranch") @Cached BranchProfile errBranch) throws PosixException {
20822077
if (mmap == MMapHandle.NONE) {
@@ -2111,7 +2106,6 @@ private static int readBytes(MMapHandle handle, long index, ByteBuffer readingBu
21112106

21122107
@ExportMessage
21132108
@SuppressWarnings("static-method")
2114-
@TruffleBoundary
21152109
public void mmapWriteBytes(Object mmap, long index, byte[] bytes, int length,
21162110
@Shared("errorBranch") @Cached BranchProfile errBranch) throws PosixException {
21172111
if (mmap == MMapHandle.NONE) {
@@ -2120,8 +2114,9 @@ public void mmapWriteBytes(Object mmap, long index, byte[] bytes, int length,
21202114
}
21212115
MMapHandle handle = (MMapHandle) mmap;
21222116
try {
2123-
position(handle.channel, handle.offset + index);
2124-
int written = handle.channel.write(ByteBuffer.wrap(bytes, 0, length));
2117+
SeekableByteChannel channel = handle.channel;
2118+
position(channel, handle.offset + index);
2119+
int written = writeChannel(channel, bytes, length);
21252120
if (written != length) {
21262121
throw posixException(OSErrorEnum.EIO);
21272122
}
@@ -2132,9 +2127,13 @@ public void mmapWriteBytes(Object mmap, long index, byte[] bytes, int length,
21322127
}
21332128
}
21342129

2130+
@TruffleBoundary
2131+
private static int writeChannel(SeekableByteChannel channel, byte[] bytes, int length) throws IOException {
2132+
return channel.write(ByteBuffer.wrap(bytes, 0, length));
2133+
}
2134+
21352135
@ExportMessage
21362136
@SuppressWarnings({"static-method", "unused"})
2137-
@TruffleBoundary
21382137
public void mmapFlush(Object mmap, long offset, long length) {
21392138
// Intentionally noop
21402139
// If we had access to the underlying NIO FileChannel, we could explicitly set force(true)
@@ -2145,7 +2144,6 @@ public void mmapFlush(Object mmap, long offset, long length) {
21452144

21462145
@ExportMessage
21472146
@SuppressWarnings("static-method")
2148-
@TruffleBoundary
21492147
public void mmapUnmap(Object mmap, @SuppressWarnings("unused") long length) throws PosixException {
21502148
if (mmap == MMapHandle.NONE) {
21512149
return;

0 commit comments

Comments
 (0)