|
46 | 46 | import com.oracle.graal.python.builtins.objects.common.HashingStorage;
|
47 | 47 | import com.oracle.graal.python.builtins.objects.common.HashingStorageLibrary;
|
48 | 48 | import com.oracle.graal.python.builtins.objects.common.PHashingCollection;
|
| 49 | +import com.oracle.graal.python.builtins.objects.common.SequenceNodes; |
| 50 | +import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; |
49 | 51 | import com.oracle.graal.python.builtins.objects.dict.PDictView;
|
50 | 52 | import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
|
51 | 53 | import com.oracle.graal.python.builtins.objects.str.PString;
|
|
65 | 67 | import com.oracle.graal.python.runtime.exception.PythonErrorType;
|
66 | 68 | import com.oracle.graal.python.runtime.sequence.PSequence;
|
67 | 69 | import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
|
68 |
| -import com.oracle.truffle.api.dsl.Bind; |
69 | 70 | import com.oracle.truffle.api.dsl.Cached;
|
70 | 71 | import com.oracle.truffle.api.dsl.Fallback;
|
71 | 72 | import com.oracle.truffle.api.dsl.GenerateNodeFactory;
|
@@ -226,24 +227,19 @@ static boolean isBuiltinSequence(Object other, GetClassNode getClassNode) {
|
226 | 227 | return other instanceof PSequence && !(other instanceof PString) && getClassNode.execute((PSequence) other) instanceof PythonBuiltinClassType;
|
227 | 228 | }
|
228 | 229 |
|
229 |
| - static SequenceStorage getSequenceStorage(PSequence sequence, Class<? extends PSequence> clazz) { |
230 |
| - return clazz.cast(sequence).getSequenceStorage(); |
231 |
| - } |
232 |
| - |
233 |
| - @Specialization(guards = {"isBuiltinSequence(other, getClassNode)", "other.getClass() == sequenceClass", |
234 |
| - "sequenceStorage.getClass() == storageClass"}, limit = "getCallSiteInlineCacheMaxDepth()") |
235 |
| - static HashingStorage doIterable(VirtualFrame frame, HashingStorage storage, @SuppressWarnings("unused") PSequence other, |
| 230 | + @Specialization(guards = "isBuiltinSequence(other, getClassNode)", limit = "1") |
| 231 | + static HashingStorage doBuiltin(VirtualFrame frame, HashingStorage storage, @SuppressWarnings("unused") PSequence other, |
236 | 232 | @SuppressWarnings("unused") @Cached GetClassNode getClassNode,
|
237 |
| - @SuppressWarnings("unused") @Cached("other.getClass()") Class<? extends PSequence> sequenceClass, |
238 |
| - @Bind("getSequenceStorage(other, sequenceClass)") SequenceStorage sequenceStorage, |
239 |
| - @SuppressWarnings("unused") @Cached("sequenceStorage.getClass()") Class<? extends SequenceStorage> storageClass, |
| 233 | + @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, |
| 234 | + @Cached SequenceStorageNodes.LenNode lenNode, |
| 235 | + @Cached SequenceStorageNodes.GetItemScalarNode getItemScalarNode, |
240 | 236 | @Cached ConditionProfile hasFrame,
|
241 | 237 | @CachedLibrary(limit = "2") HashingStorageLibrary lib) {
|
242 |
| - SequenceStorage profiledSequenceStorage = storageClass.cast(sequenceStorage); |
243 |
| - int length = profiledSequenceStorage.length(); |
| 238 | + SequenceStorage sequenceStorage = getSequenceStorageNode.execute(other); |
| 239 | + int length = lenNode.execute(sequenceStorage); |
244 | 240 | HashingStorage curStorage = storage;
|
245 | 241 | for (int i = 0; i < length; i++) {
|
246 |
| - Object key = profiledSequenceStorage.getItemNormalized(i); |
| 242 | + Object key = getItemScalarNode.execute(sequenceStorage, i); |
247 | 243 | curStorage = lib.setItemWithFrame(curStorage, key, PNone.NONE, hasFrame, frame);
|
248 | 244 | }
|
249 | 245 | return curStorage;
|
|
0 commit comments