Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77cd042

Browse files
authored
GH-118095: Convert DEOPT_IFs on likely side exits to EXIT_IFs (GH-118106)
Covert DEOPT_IFs on likely side exits to EXIT_IFs
1 parent 7d369d4 commit 77cd042

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
@@ -2628,7 +2628,7 @@ dummy_func(
26282628
}
26292629

26302630
op(_ITER_CHECK_LIST, (iter -- iter)) {
2631-
DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type);
2631+
EXIT_IF(Py_TYPE(iter) != &PyListIter_Type);
26322632
}
26332633

26342634
replaced op(_ITER_JUMP_LIST, (iter -- iter)) {
@@ -2657,8 +2657,8 @@ dummy_func(
26572657
_PyListIterObject *it = (_PyListIterObject *)iter;
26582658
assert(Py_TYPE(iter) == &PyListIter_Type);
26592659
PyListObject *seq = it->it_seq;
2660-
DEOPT_IF(seq == NULL);
2661-
DEOPT_IF((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq));
2660+
EXIT_IF(seq == NULL);
2661+
EXIT_IF((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq));
26622662
}
26632663

26642664
op(_ITER_NEXT_LIST, (iter -- iter, next)) {
@@ -2677,7 +2677,7 @@ dummy_func(
26772677
_ITER_NEXT_LIST;
26782678

26792679
op(_ITER_CHECK_TUPLE, (iter -- iter)) {
2680-
DEOPT_IF(Py_TYPE(iter) != &PyTupleIter_Type);
2680+
EXIT_IF(Py_TYPE(iter) != &PyTupleIter_Type);
26812681
}
26822682

26832683
replaced op(_ITER_JUMP_TUPLE, (iter -- iter)) {
@@ -2703,8 +2703,8 @@ dummy_func(
27032703
_PyTupleIterObject *it = (_PyTupleIterObject *)iter;
27042704
assert(Py_TYPE(iter) == &PyTupleIter_Type);
27052705
PyTupleObject *seq = it->it_seq;
2706-
DEOPT_IF(seq == NULL);
2707-
DEOPT_IF(it->it_index >= PyTuple_GET_SIZE(seq));
2706+
EXIT_IF(seq == NULL);
2707+
EXIT_IF(it->it_index >= PyTuple_GET_SIZE(seq));
27082708
}
27092709

27102710
op(_ITER_NEXT_TUPLE, (iter -- iter, next)) {
@@ -2724,7 +2724,7 @@ dummy_func(
27242724

27252725
op(_ITER_CHECK_RANGE, (iter -- iter)) {
27262726
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
2727-
DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type);
2727+
EXIT_IF(Py_TYPE(r) != &PyRangeIter_Type);
27282728
}
27292729

27302730
replaced op(_ITER_JUMP_RANGE, (iter -- iter)) {
@@ -2744,7 +2744,7 @@ dummy_func(
27442744
op(_GUARD_NOT_EXHAUSTED_RANGE, (iter -- iter)) {
27452745
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
27462746
assert(Py_TYPE(r) == &PyRangeIter_Type);
2747-
DEOPT_IF(r->len <= 0);
2747+
EXIT_IF(r->len <= 0);
27482748
}
27492749

27502750
op(_ITER_NEXT_RANGE, (iter -- iter, next)) {
@@ -3145,11 +3145,11 @@ dummy_func(
31453145
}
31463146

31473147
op(_CHECK_FUNCTION_EXACT_ARGS, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
3148-
DEOPT_IF(!PyFunction_Check(callable));
3148+
EXIT_IF(!PyFunction_Check(callable));
31493149
PyFunctionObject *func = (PyFunctionObject *)callable;
3150-
DEOPT_IF(func->func_version != func_version);
3150+
EXIT_IF(func->func_version != func_version);
31513151
PyCodeObject *code = (PyCodeObject *)func->func_code;
3152-
DEOPT_IF(code->co_argcount != oparg + (self_or_null != NULL));
3152+
EXIT_IF(code->co_argcount != oparg + (self_or_null != NULL));
31533153
}
31543154

31553155
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
@@ -696,7 +696,7 @@ translate_bytecode_to_trace(
696696
if (expansion->nuops > 0) {
697697
// Reserve space for nuops (+ _SET_IP + _EXIT_TRACE)
698698
int nuops = expansion->nuops;
699-
RESERVE(nuops);
699+
RESERVE(nuops + 1); /* One extra for exit */
700700
if (expansion->uops[nuops-1].uop == _POP_FRAME) {
701701
// Check for trace stack underflow now:
702702
// We can't bail e.g. in the middle of

0 commit comments

Comments
 (0)