|
44 | 44 |
|
45 | 45 | import com.oracle.graal.python.builtins.objects.bytes.PByteArray; |
46 | 46 | import com.oracle.graal.python.builtins.objects.bytes.PBytes; |
| 47 | +import com.oracle.graal.python.builtins.objects.bytes.PIBytesLike; |
47 | 48 | import com.oracle.graal.python.builtins.objects.cext.CExtNodes.CExtBaseNode; |
48 | 49 | import com.oracle.graal.python.builtins.objects.cext.CExtNodes.ToSulongNode; |
49 | 50 | import com.oracle.graal.python.builtins.objects.cext.NativeWrappers.PySequenceArrayWrapper; |
|
86 | 87 | import com.oracle.truffle.api.interop.UnsupportedMessageException; |
87 | 88 | import com.oracle.truffle.api.nodes.Node; |
88 | 89 | import com.oracle.truffle.api.nodes.UnexpectedResultException; |
| 90 | +import com.oracle.truffle.api.profiles.ValueProfile; |
89 | 91 |
|
90 | 92 | @MessageResolution(receiverType = PySequenceArrayWrapper.class) |
91 | 93 | public class PySequenceArrayWrapperMR { |
@@ -162,17 +164,19 @@ Object doTuple(PList list, long idx, |
162 | 164 | * {@code uint64_t} since we do not know how many bytes are requested. |
163 | 165 | */ |
164 | 166 | @Specialization |
165 | | - long doBytesI64(PBytes bytes, long byteIdx, |
| 167 | + long doBytesI64(PIBytesLike bytesLike, long byteIdx, |
| 168 | + @Cached("createClassProfile()") ValueProfile profile, |
166 | 169 | @Cached("create()") SequenceStorageNodes.LenNode lenNode, |
167 | 170 | @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()); |
169 | 173 | // simulate sentinel value |
170 | 174 | if (byteIdx == len) { |
171 | 175 | return 0L; |
172 | 176 | } |
173 | 177 | int i = (int) byteIdx; |
174 | 178 | long result = 0; |
175 | | - SequenceStorage store = bytes.getSequenceStorage(); |
| 179 | + SequenceStorage store = profiled.getSequenceStorage(); |
176 | 180 | result |= getItemNode.executeInt(store, i); |
177 | 181 | if (i + 1 < len) |
178 | 182 | result |= ((long) getItemNode.executeInt(store, i + 1) << 8L) & 0xFF00L; |
|
0 commit comments