Skip to content

Commit acf49cb

Browse files
committed
[GR-28428] EmulatedPosixSupport: remove artificial Truffle boundaries on mmap messages.
PullRequest: graalpython/1678
2 parents 439e851 + 46f23ab commit acf49cb

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
@@ -1928,8 +1928,6 @@ public void finish() {
19281928
}
19291929
}
19301930

1931-
// Note: all the mmap related messages are behind Truffle boundary until GR-29663 is resolved
1932-
19331931
public static final class MMapHandle {
19341932
private static final MMapHandle NONE = new MMapHandle(null, 0);
19351933
private SeekableByteChannel channel;
@@ -2011,7 +2009,6 @@ public SeekableByteChannel truncate(long size) throws IOException {
20112009

20122010
@ExportMessage
20132011
@SuppressWarnings("static-method")
2014-
@TruffleBoundary
20152012
final MMapHandle mmap(long length, int prot, int flags, int fd, long offset,
20162013
@Shared("defaultDirProfile") @Cached ConditionProfile isAnonymousProfile) throws PosixException {
20172014
if (prot == PROT_NONE.value) {
@@ -2065,7 +2062,6 @@ private static SeekableByteChannel newByteChannel(TruffleFile file, Set<Standard
20652062

20662063
@ExportMessage
20672064
@SuppressWarnings("static-method")
2068-
@TruffleBoundary
20692065
public byte mmapReadByte(Object mmap, long index,
20702066
@Shared("errorBranch") @Cached BranchProfile errBranch) throws PosixException {
20712067
if (mmap == MMapHandle.NONE) {
@@ -2083,7 +2079,6 @@ public byte mmapReadByte(Object mmap, long index,
20832079

20842080
@ExportMessage
20852081
@SuppressWarnings("static-method")
2086-
@TruffleBoundary
20872082
public int mmapReadBytes(Object mmap, long index, byte[] bytes, int length,
20882083
@Shared("errorBranch") @Cached BranchProfile errBranch) throws PosixException {
20892084
if (mmap == MMapHandle.NONE) {
@@ -2118,7 +2113,6 @@ private static int readBytes(MMapHandle handle, long index, ByteBuffer readingBu
21182113

21192114
@ExportMessage
21202115
@SuppressWarnings("static-method")
2121-
@TruffleBoundary
21222116
public void mmapWriteBytes(Object mmap, long index, byte[] bytes, int length,
21232117
@Shared("errorBranch") @Cached BranchProfile errBranch) throws PosixException {
21242118
if (mmap == MMapHandle.NONE) {
@@ -2127,8 +2121,9 @@ public void mmapWriteBytes(Object mmap, long index, byte[] bytes, int length,
21272121
}
21282122
MMapHandle handle = (MMapHandle) mmap;
21292123
try {
2130-
position(handle.channel, handle.offset + index);
2131-
int written = handle.channel.write(ByteBuffer.wrap(bytes, 0, length));
2124+
SeekableByteChannel channel = handle.channel;
2125+
position(channel, handle.offset + index);
2126+
int written = writeChannel(channel, bytes, length);
21322127
if (written != length) {
21332128
throw posixException(OSErrorEnum.EIO);
21342129
}
@@ -2139,9 +2134,13 @@ public void mmapWriteBytes(Object mmap, long index, byte[] bytes, int length,
21392134
}
21402135
}
21412136

2137+
@TruffleBoundary
2138+
private static int writeChannel(SeekableByteChannel channel, byte[] bytes, int length) throws IOException {
2139+
return channel.write(ByteBuffer.wrap(bytes, 0, length));
2140+
}
2141+
21422142
@ExportMessage
21432143
@SuppressWarnings({"static-method", "unused"})
2144-
@TruffleBoundary
21452144
public void mmapFlush(Object mmap, long offset, long length) {
21462145
// Intentionally noop
21472146
// If we had access to the underlying NIO FileChannel, we could explicitly set force(true)
@@ -2152,7 +2151,6 @@ public void mmapFlush(Object mmap, long offset, long length) {
21522151

21532152
@ExportMessage
21542153
@SuppressWarnings("static-method")
2155-
@TruffleBoundary
21562154
public void mmapUnmap(Object mmap, @SuppressWarnings("unused") long length) throws PosixException {
21572155
if (mmap == MMapHandle.NONE) {
21582156
return;

0 commit comments

Comments
 (0)