Skip to content

Commit 458d82f

Browse files
committed
Covert DEOPT_IFs on likely side exits to EXIT_IFs
1 parent 7e6fa5f commit 458d82f

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,7 +2604,7 @@ dummy_func(
26042604
}
26052605

26062606
op(_ITER_CHECK_LIST, (iter -- iter)) {
2607-
DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type);
2607+
EXIT_IF(Py_TYPE(iter) != &PyListIter_Type);
26082608
}
26092609

26102610
replaced op(_ITER_JUMP_LIST, (iter -- iter)) {
@@ -2633,8 +2633,8 @@ dummy_func(
26332633
_PyListIterObject *it = (_PyListIterObject *)iter;
26342634
assert(Py_TYPE(iter) == &PyListIter_Type);
26352635
PyListObject *seq = it->it_seq;
2636-
DEOPT_IF(seq == NULL);
2637-
DEOPT_IF((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq));
2636+
EXIT_IF(seq == NULL);
2637+
EXIT_IF((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq));
26382638
}
26392639

26402640
op(_ITER_NEXT_LIST, (iter -- iter, next)) {
@@ -2653,7 +2653,7 @@ dummy_func(
26532653
_ITER_NEXT_LIST;
26542654

26552655
op(_ITER_CHECK_TUPLE, (iter -- iter)) {
2656-
DEOPT_IF(Py_TYPE(iter) != &PyTupleIter_Type);
2656+
EXIT_IF(Py_TYPE(iter) != &PyTupleIter_Type);
26572657
}
26582658

26592659
replaced op(_ITER_JUMP_TUPLE, (iter -- iter)) {
@@ -2679,8 +2679,8 @@ dummy_func(
26792679
_PyTupleIterObject *it = (_PyTupleIterObject *)iter;
26802680
assert(Py_TYPE(iter) == &PyTupleIter_Type);
26812681
PyTupleObject *seq = it->it_seq;
2682-
DEOPT_IF(seq == NULL);
2683-
DEOPT_IF(it->it_index >= PyTuple_GET_SIZE(seq));
2682+
EXIT_IF(seq == NULL);
2683+
EXIT_IF(it->it_index >= PyTuple_GET_SIZE(seq));
26842684
}
26852685

26862686
op(_ITER_NEXT_TUPLE, (iter -- iter, next)) {
@@ -2700,7 +2700,7 @@ dummy_func(
27002700

27012701
op(_ITER_CHECK_RANGE, (iter -- iter)) {
27022702
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
2703-
DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type);
2703+
EXIT_IF(Py_TYPE(r) != &PyRangeIter_Type);
27042704
}
27052705

27062706
replaced op(_ITER_JUMP_RANGE, (iter -- iter)) {
@@ -2720,7 +2720,7 @@ dummy_func(
27202720
op(_GUARD_NOT_EXHAUSTED_RANGE, (iter -- iter)) {
27212721
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
27222722
assert(Py_TYPE(r) == &PyRangeIter_Type);
2723-
DEOPT_IF(r->len <= 0);
2723+
EXIT_IF(r->len <= 0);
27242724
}
27252725

27262726
op(_ITER_NEXT_RANGE, (iter -- iter, next)) {
@@ -3121,11 +3121,11 @@ dummy_func(
31213121
}
31223122

31233123
op(_CHECK_FUNCTION_EXACT_ARGS, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
3124-
DEOPT_IF(!PyFunction_Check(callable));
3124+
EXIT_IF(!PyFunction_Check(callable));
31253125
PyFunctionObject *func = (PyFunctionObject *)callable;
3126-
DEOPT_IF(func->func_version != func_version);
3126+
EXIT_IF(func->func_version != func_version);
31273127
PyCodeObject *code = (PyCodeObject *)func->func_code;
3128-
DEOPT_IF(code->co_argcount != oparg + (self_or_null != NULL));
3128+
EXIT_IF(code->co_argcount != oparg + (self_or_null != NULL));
31293129
}
31303130

31313131
op(_CHECK_STACK_SPACE, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) {

Python/optimizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ translate_bytecode_to_trace(
689689
if (expansion->nuops > 0) {
690690
// Reserve space for nuops (+ _SET_IP + _EXIT_TRACE)
691691
int nuops = expansion->nuops;
692-
RESERVE(nuops);
692+
RESERVE(nuops + 1); /* One extra for exit */
693693
if (expansion->uops[nuops-1].uop == _POP_FRAME) {
694694
// Check for trace stack underflow now:
695695
// We can't bail e.g. in the middle of

0 commit comments

Comments
 (0)