diff options
author | Guido van Rossum <guido@python.org> | 2023-07-12 17:23:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-12 17:23:59 (GMT) |
commit | dd1884dc5dc1a540c60e98ea1bc482a51d996564 (patch) | |
tree | 7b32b0062a4d1f3734c0a9b6ba4473e51fe4aa59 /Python/executor_cases.c.h | |
parent | 7f55f58b6c97306da350f5b441d26f859e9d8f16 (diff) | |
download | cpython-dd1884dc5dc1a540c60e98ea1bc482a51d996564.zip cpython-dd1884dc5dc1a540c60e98ea1bc482a51d996564.tar.gz cpython-dd1884dc5dc1a540c60e98ea1bc482a51d996564.tar.bz2 |
gh-106529: Split FOR_ITER_RANGE into uops (#106638)
For an example of what this does for Tier 1 and Tier 2, see
https://github.com/python/cpython/issues/106529#issuecomment-1631649920
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r-- | Python/executor_cases.c.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 1df8feb..2c2dbf4 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1720,6 +1720,40 @@ break; } + case _ITER_CHECK_RANGE: { + PyObject *iter = stack_pointer[-1]; + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); + break; + } + + case _ITER_EXHAUSTED_RANGE: { + PyObject *iter = stack_pointer[-1]; + PyObject *exhausted; + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); + exhausted = r->len <= 0 ? Py_True : Py_False; + STACK_GROW(1); + stack_pointer[-1] = exhausted; + break; + } + + case _ITER_NEXT_RANGE: { + PyObject *iter = stack_pointer[-1]; + PyObject *next; + _PyRangeIterObject *r = (_PyRangeIterObject *)iter; + assert(Py_TYPE(r) == &PyRangeIter_Type); + assert(r->len > 0); + long value = r->start; + r->start = value + r->step; + r->len--; + next = PyLong_FromLong(value); + if (next == NULL) goto error; + STACK_GROW(1); + stack_pointer[-1] = next; + break; + } + case WITH_EXCEPT_START: { PyObject *val = stack_pointer[-1]; PyObject *lasti = stack_pointer[-3]; |