|
64 | 64 | import com.oracle.graal.python.builtins.objects.code.PCode;
|
65 | 65 | import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes.SetItemNode;
|
66 | 66 | import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes;
|
| 67 | +import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; |
67 | 68 | import com.oracle.graal.python.builtins.objects.dict.PDict;
|
68 | 69 | import com.oracle.graal.python.builtins.objects.exception.PBaseException;
|
69 | 70 | import com.oracle.graal.python.builtins.objects.ints.PInt;
|
|
86 | 87 | import com.oracle.graal.python.runtime.PythonOptions;
|
87 | 88 | import com.oracle.graal.python.runtime.exception.PException;
|
88 | 89 | import com.oracle.graal.python.runtime.exception.PythonErrorType;
|
| 90 | +import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; |
89 | 91 | import com.oracle.truffle.api.CallTarget;
|
90 | 92 | import com.oracle.truffle.api.CompilerAsserts;
|
91 | 93 | import com.oracle.truffle.api.CompilerDirectives;
|
@@ -467,12 +469,16 @@ public Object run(String modulename, String moduleFile, @SuppressWarnings("unuse
|
467 | 469 |
|
468 | 470 | @Specialization
|
469 | 471 | public Object run(VirtualFrame frame, String modulename, String moduleFile, PList modulepath,
|
| 472 | + @Cached SequenceStorageNodes.LenNode lenNode, |
470 | 473 | @Shared("cast") @Cached CastToStringNode castString,
|
471 | 474 | @Shared("ctxt") @CachedContext(PythonLanguage.class) PythonContext ctxt,
|
472 | 475 | @Shared("lang") @CachedLanguage PythonLanguage lang) {
|
473 |
| - Object[] pathList = modulepath.getSequenceStorage().getInternalArray(); |
474 |
| - String[] paths = new String[pathList.length]; |
475 |
| - for (int i = 0; i < pathList.length; i++) { |
| 476 | + SequenceStorage sequenceStorage = modulepath.getSequenceStorage(); |
| 477 | + int n = lenNode.execute(sequenceStorage); |
| 478 | + Object[] pathList = sequenceStorage.getInternalArray(); |
| 479 | + assert n <= pathList.length; |
| 480 | + String[] paths = new String[n]; |
| 481 | + for (int i = 0; i < n; i++) { |
476 | 482 | paths[i] = castString.execute(frame, pathList[i]);
|
477 | 483 | }
|
478 | 484 | return doCache(modulename, moduleFile, paths, ctxt, lang);
|
|
0 commit comments