Skip to content

Commit ee6f222

Browse files
committed
Fix: ReadNode did not accept PInt.
1 parent 6a07170 commit ee6f222

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
134134
import com.oracle.graal.python.nodes.util.CastToIndexNode;
135135
import com.oracle.graal.python.nodes.util.CastToIntegerFromIntNode;
136+
import com.oracle.graal.python.nodes.util.CastToJavaLongNode;
136137
import com.oracle.graal.python.nodes.util.CastToStringNode;
137138
import com.oracle.graal.python.nodes.util.ChannelNodes.ReadFromChannelNode;
138139
import com.oracle.graal.python.runtime.PosixResources;
@@ -150,6 +151,7 @@
150151
import com.oracle.truffle.api.TruffleFile;
151152
import com.oracle.truffle.api.TruffleLanguage.Env;
152153
import com.oracle.truffle.api.dsl.Cached;
154+
import com.oracle.truffle.api.dsl.Cached.Shared;
153155
import com.oracle.truffle.api.dsl.Fallback;
154156
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
155157
import com.oracle.truffle.api.dsl.NodeFactory;
@@ -1244,9 +1246,9 @@ public abstract static class ReadNode extends PythonFileNode {
12441246
@CompilationFinal private BranchProfile tooLargeProfile = BranchProfile.create();
12451247

12461248
@Specialization
1247-
Object read(@SuppressWarnings("unused") VirtualFrame frame, int fd, long requestedSize,
1248-
@Cached("createClassProfile()") ValueProfile channelClassProfile,
1249-
@Cached("create()") ReadFromChannelNode readNode) {
1249+
Object readLong(@SuppressWarnings("unused") VirtualFrame frame, int fd, long requestedSize,
1250+
@Shared("profile") @Cached("createClassProfile()") ValueProfile channelClassProfile,
1251+
@Shared("readNode") @Cached ReadFromChannelNode readNode) {
12501252
int size;
12511253
try {
12521254
size = Math.toIntExact(requestedSize);
@@ -1258,6 +1260,14 @@ Object read(@SuppressWarnings("unused") VirtualFrame frame, int fd, long request
12581260
ByteSequenceStorage array = readNode.execute(channel, size);
12591261
return factory().createBytes(array);
12601262
}
1263+
1264+
@Specialization
1265+
Object read(@SuppressWarnings("unused") VirtualFrame frame, int fd, Object requestedSize,
1266+
@Shared("profile") @Cached("createClassProfile()") ValueProfile channelClassProfile,
1267+
@Shared("readNode") @Cached ReadFromChannelNode readNode,
1268+
@Cached CastToJavaLongNode castToLongNode) {
1269+
return readLong(frame, fd, castToLongNode.execute(requestedSize), channelClassProfile, readNode);
1270+
}
12611271
}
12621272

12631273
@Builtin(name = "isatty", minNumOfPositionalArgs = 1)

0 commit comments

Comments
 (0)