Skip to content

Commit 9b1d19d

Browse files
committed
Also support 'PByteArray' in 'PySequenceArrayWrapperMR'.
1 parent de8b572 commit 9b1d19d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PySequenceArrayWrapperMR.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
import com.oracle.graal.python.builtins.objects.bytes.PByteArray;
4646
import com.oracle.graal.python.builtins.objects.bytes.PBytes;
47+
import com.oracle.graal.python.builtins.objects.bytes.PIBytesLike;
4748
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.CExtBaseNode;
4849
import com.oracle.graal.python.builtins.objects.cext.CExtNodes.ToSulongNode;
4950
import com.oracle.graal.python.builtins.objects.cext.NativeWrappers.PySequenceArrayWrapper;
@@ -86,6 +87,7 @@
8687
import com.oracle.truffle.api.interop.UnsupportedMessageException;
8788
import com.oracle.truffle.api.nodes.Node;
8889
import com.oracle.truffle.api.nodes.UnexpectedResultException;
90+
import com.oracle.truffle.api.profiles.ValueProfile;
8991

9092
@MessageResolution(receiverType = PySequenceArrayWrapper.class)
9193
public class PySequenceArrayWrapperMR {
@@ -162,17 +164,19 @@ Object doTuple(PList list, long idx,
162164
* {@code uint64_t} since we do not know how many bytes are requested.
163165
*/
164166
@Specialization
165-
long doBytesI64(PBytes bytes, long byteIdx,
167+
long doBytesI64(PIBytesLike bytesLike, long byteIdx,
168+
@Cached("createClassProfile()") ValueProfile profile,
166169
@Cached("create()") SequenceStorageNodes.LenNode lenNode,
167170
@Cached("create()") SequenceStorageNodes.GetItemNode getItemNode) {
168-
int len = lenNode.execute(bytes.getSequenceStorage());
171+
PIBytesLike profiled = profile.profile(bytesLike);
172+
int len = lenNode.execute(profiled.getSequenceStorage());
169173
// simulate sentinel value
170174
if (byteIdx == len) {
171175
return 0L;
172176
}
173177
int i = (int) byteIdx;
174178
long result = 0;
175-
SequenceStorage store = bytes.getSequenceStorage();
179+
SequenceStorage store = profiled.getSequenceStorage();
176180
result |= getItemNode.executeInt(store, i);
177181
if (i + 1 < len)
178182
result |= ((long) getItemNode.executeInt(store, i + 1) << 8L) & 0xFF00L;

0 commit comments

Comments
 (0)