mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
GH-100982: Restrict FOR_ITER_RANGE
to a single instruction to allow instrumentation. (GH-101985)
This commit is contained in:
parent
8d46c7ed5e
commit
7c106a443f
4 changed files with 22 additions and 30 deletions
|
@ -2155,8 +2155,6 @@ _Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr, int oparg)
|
|||
assert(_PyOpcode_Caches[FOR_ITER] == INLINE_CACHE_ENTRIES_FOR_ITER);
|
||||
_PyForIterCache *cache = (_PyForIterCache *)(instr + 1);
|
||||
PyTypeObject *tp = Py_TYPE(iter);
|
||||
_Py_CODEUNIT next = instr[1+INLINE_CACHE_ENTRIES_FOR_ITER];
|
||||
int next_op = _PyOpcode_Deopt[next.op.code];
|
||||
if (tp == &PyListIter_Type) {
|
||||
instr->op.code = FOR_ITER_LIST;
|
||||
goto success;
|
||||
|
@ -2165,7 +2163,7 @@ _Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr, int oparg)
|
|||
instr->op.code = FOR_ITER_TUPLE;
|
||||
goto success;
|
||||
}
|
||||
else if (tp == &PyRangeIter_Type && next_op == STORE_FAST) {
|
||||
else if (tp == &PyRangeIter_Type) {
|
||||
instr->op.code = FOR_ITER_RANGE;
|
||||
goto success;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue