summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-04-24 13:37:55 (GMT)
committerGitHub <noreply@github.com>2024-04-24 13:37:55 (GMT)
commit77cd0428b698a743844179f7babead43b2794d77 (patch)
tree8a2d151832d26c111d01fa75200c46eb4dd81f10 /Python
parent7d369d471cf2b067c4d795d70b75201c48b46f5b (diff)
downloadcpython-77cd0428b698a743844179f7babead43b2794d77.zip
cpython-77cd0428b698a743844179f7babead43b2794d77.tar.gz
cpython-77cd0428b698a743844179f7babead43b2794d77.tar.bz2
GH-118095: Convert DEOPT_IFs on likely side exits to EXIT_IFs (GH-118106)
Covert DEOPT_IFs on likely side exits to EXIT_IFs
Diffstat (limited to 'Python')
-rw-r--r--Python/bytecodes.c22
-rw-r--r--Python/optimizer.c2
2 files changed, 12 insertions, 12 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 4541eb6..1f908a9 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -2628,7 +2628,7 @@ dummy_func(
}
op(_ITER_CHECK_LIST, (iter -- iter)) {
- DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type);
+ EXIT_IF(Py_TYPE(iter) != &PyListIter_Type);
}
replaced op(_ITER_JUMP_LIST, (iter -- iter)) {
@@ -2657,8 +2657,8 @@ dummy_func(
_PyListIterObject *it = (_PyListIterObject *)iter;
assert(Py_TYPE(iter) == &PyListIter_Type);
PyListObject *seq = it->it_seq;
- DEOPT_IF(seq == NULL);
- DEOPT_IF((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq));
+ EXIT_IF(seq == NULL);
+ EXIT_IF((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq));
}
op(_ITER_NEXT_LIST, (iter -- iter, next)) {
@@ -2677,7 +2677,7 @@ dummy_func(
_ITER_NEXT_LIST;
op(_ITER_CHECK_TUPLE, (iter -- iter)) {
- DEOPT_IF(Py_TYPE(iter) != &PyTupleIter_Type);
+ EXIT_IF(Py_TYPE(iter) != &PyTupleIter_Type);
}
replaced op(_ITER_JUMP_TUPLE, (iter -- iter)) {
@@ -2703,8 +2703,8 @@ dummy_func(
_PyTupleIterObject *it = (_PyTupleIterObject *)iter;
assert(Py_TYPE(iter) == &PyTupleIter_Type);
PyTupleObject *seq = it->it_seq;
- DEOPT_IF(seq == NULL);
- DEOPT_IF(it->it_index >= PyTuple_GET_SIZE(seq));
+ EXIT_IF(seq == NULL);
+ EXIT_IF(it->it_index >= PyTuple_GET_SIZE(seq));
}
op(_ITER_NEXT_TUPLE, (iter -- iter, next)) {
@@ -2724,7 +2724,7 @@ dummy_func(
op(_ITER_CHECK_RANGE, (iter -- iter)) {
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
- DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type);
+ EXIT_IF(Py_TYPE(r) != &PyRangeIter_Type);
}
replaced op(_ITER_JUMP_RANGE, (iter -- iter)) {
@@ -2744,7 +2744,7 @@ dummy_func(
op(_GUARD_NOT_EXHAUSTED_RANGE, (iter -- iter)) {
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
assert(Py_TYPE(r) == &PyRangeIter_Type);
- DEOPT_IF(r->len <= 0);
+ EXIT_IF(r->len <= 0);
}
op(_ITER_NEXT_RANGE, (iter -- iter, next)) {
@@ -3145,11 +3145,11 @@ dummy_func(
}
op(_CHECK_FUNCTION_EXACT_ARGS, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
- DEOPT_IF(!PyFunction_Check(callable));
+ EXIT_IF(!PyFunction_Check(callable));
PyFunctionObject *func = (PyFunctionObject *)callable;
- DEOPT_IF(func->func_version != func_version);
+ EXIT_IF(func->func_version != func_version);
PyCodeObject *code = (PyCodeObject *)func->func_code;
- DEOPT_IF(code->co_argcount != oparg + (self_or_null != NULL));
+ EXIT_IF(code->co_argcount != oparg + (self_or_null != NULL));
}
op(_CHECK_STACK_SPACE, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) {
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 0017965..6a8b4f3 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -696,7 +696,7 @@ top: // Jump here after _PUSH_FRAME or likely branches
if (expansion->nuops > 0) {
// Reserve space for nuops (+ _SET_IP + _EXIT_TRACE)
int nuops = expansion->nuops;
- RESERVE(nuops);
+ RESERVE(nuops + 1); /* One extra for exit */
if (expansion->uops[nuops-1].uop == _POP_FRAME) {
// Check for trace stack underflow now:
// We can't bail e.g. in the middle of