summaryrefslogtreecommitdiffstats
path: root/Python/executor_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-11-08 13:31:55 (GMT)
committerGitHub <noreply@github.com>2023-11-08 13:31:55 (GMT)
commit06efb602645226f108e02bde716f9061f1ec4cdd (patch)
tree7a40ebfa72e9035738468f8494827fc0fd455993 /Python/executor_cases.c.h
parent11e83488c5a4a6e75a4f363a2e1a45574fd53573 (diff)
downloadcpython-06efb602645226f108e02bde716f9061f1ec4cdd.zip
cpython-06efb602645226f108e02bde716f9061f1ec4cdd.tar.gz
cpython-06efb602645226f108e02bde716f9061f1ec4cdd.tar.bz2
GH-111848: Tidy up tier 2 handling of FOR_ITER specialization by using DEOPT_IF instead of jumps. (GH-111849)
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r--Python/executor_cases.c.h43
1 files changed, 8 insertions, 35 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index d9e9ad1..d94a7cc 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -2138,26 +2138,14 @@
break;
}
- case _IS_ITER_EXHAUSTED_LIST: {
+ case _GUARD_NOT_EXHAUSTED_LIST: {
PyObject *iter;
- PyObject *exhausted;
iter = stack_pointer[-1];
_PyListIterObject *it = (_PyListIterObject *)iter;
assert(Py_TYPE(iter) == &PyListIter_Type);
PyListObject *seq = it->it_seq;
- if (seq == NULL) {
- exhausted = Py_True;
- }
- else if (it->it_index >= PyList_GET_SIZE(seq)) {
- Py_DECREF(seq);
- it->it_seq = NULL;
- exhausted = Py_True;
- }
- else {
- exhausted = Py_False;
- }
- STACK_GROW(1);
- stack_pointer[-1] = exhausted;
+ DEOPT_IF(seq == NULL, _GUARD_NOT_EXHAUSTED_LIST);
+ DEOPT_IF(it->it_index >= PyList_GET_SIZE(seq), _GUARD_NOT_EXHAUSTED_LIST);
break;
}
@@ -2183,26 +2171,14 @@
break;
}
- case _IS_ITER_EXHAUSTED_TUPLE: {
+ case _GUARD_NOT_EXHAUSTED_TUPLE: {
PyObject *iter;
- PyObject *exhausted;
iter = stack_pointer[-1];
_PyTupleIterObject *it = (_PyTupleIterObject *)iter;
assert(Py_TYPE(iter) == &PyTupleIter_Type);
PyTupleObject *seq = it->it_seq;
- if (seq == NULL) {
- exhausted = Py_True;
- }
- else if (it->it_index >= PyTuple_GET_SIZE(seq)) {
- Py_DECREF(seq);
- it->it_seq = NULL;
- exhausted = Py_True;
- }
- else {
- exhausted = Py_False;
- }
- STACK_GROW(1);
- stack_pointer[-1] = exhausted;
+ DEOPT_IF(seq == NULL, _GUARD_NOT_EXHAUSTED_TUPLE);
+ DEOPT_IF(it->it_index >= PyTuple_GET_SIZE(seq), _GUARD_NOT_EXHAUSTED_TUPLE);
break;
}
@@ -2229,15 +2205,12 @@
break;
}
- case _IS_ITER_EXHAUSTED_RANGE: {
+ case _GUARD_NOT_EXHAUSTED_RANGE: {
PyObject *iter;
- PyObject *exhausted;
iter = stack_pointer[-1];
_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;
+ DEOPT_IF(r->len <= 0, _GUARD_NOT_EXHAUSTED_RANGE);
break;
}