Skip to content

Commit 8d0f152

Browse files
committed
Add some missing Truffle Boundaries
1 parent 92e08f1 commit 8d0f152

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,14 +2023,15 @@ final MMapHandle mmap(long length, int prot, int flags, int fd, long offset,
20232023
// we create a new channel, the file may be closed but the mmap object should still work
20242024
SeekableByteChannel fileChannel;
20252025
try {
2026-
fileChannel = file.newByteChannel(options);
2026+
fileChannel = newByteChannel(file, options);
20272027
position(fileChannel, offset);
20282028
return new MMapHandle(fileChannel, offset);
20292029
} catch (IOException e) {
20302030
throw posixException(OSErrorEnum.fromException(e));
20312031
}
20322032
}
20332033

2034+
@TruffleBoundary
20342035
private static Set<StandardOpenOption> mmapProtToOptions(int prot) {
20352036
HashSet<StandardOpenOption> options = new HashSet<>();
20362037
if ((prot & PROT_READ) != 0) {
@@ -2045,6 +2046,11 @@ private static Set<StandardOpenOption> mmapProtToOptions(int prot) {
20452046
return options;
20462047
}
20472048

2049+
@TruffleBoundary
2050+
private static SeekableByteChannel newByteChannel(TruffleFile file, Set<StandardOpenOption> options) throws IOException {
2051+
return file.newByteChannel(options);
2052+
}
2053+
20482054
@ExportMessage
20492055
@SuppressWarnings("static-method")
20502056
public byte mmapReadByte(Object mmap, long index,
@@ -2137,14 +2143,19 @@ public void mmapUnmap(Object mmap, @SuppressWarnings("unused") long length) thro
21372143
MMapHandle handle = (MMapHandle) mmap;
21382144
if (handle.channel != null) {
21392145
try {
2140-
handle.channel.close();
2146+
closeChannel(handle.channel);
21412147
} catch (IOException e) {
21422148
throw posixException(OSErrorEnum.fromException(e));
21432149
}
21442150
handle.channel = null;
21452151
}
21462152
}
21472153

2154+
@TruffleBoundary
2155+
private static void closeChannel(Channel ch) throws IOException {
2156+
ch.close();
2157+
}
2158+
21482159
@TruffleBoundary
21492160
private static void position(SeekableByteChannel ch, long offset) throws IOException {
21502161
ch.position(offset);

0 commit comments

Comments
 (0)