Skip to content

Commit f84754b

Browse files
authored
pythonGH-118093: Turn some DEOPT_IFs into EXIT_IFs (pythonGH-122998)
1 parent 5118592 commit f84754b

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

Diff for: Include/internal/pycore_opcode_metadata.h

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Include/internal/pycore_uop_metadata.h

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Python/bytecodes.c

+25-25
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ dummy_func(
20612061

20622062
assert(Py_TYPE(owner_o)->tp_flags & Py_TPFLAGS_MANAGED_DICT);
20632063
PyDictObject *dict = _PyObject_GetManagedDict(owner_o);
2064-
DEOPT_IF(dict == NULL);
2064+
EXIT_IF(dict == NULL);
20652065
assert(PyDict_CheckExact((PyObject *)dict));
20662066
}
20672067

@@ -2112,9 +2112,9 @@ dummy_func(
21122112
op(_CHECK_ATTR_CLASS, (type_version/2, owner -- owner)) {
21132113
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);
21142114

2115-
DEOPT_IF(!PyType_Check(owner_o));
2115+
EXIT_IF(!PyType_Check(owner_o));
21162116
assert(type_version != 0);
2117-
DEOPT_IF(((PyTypeObject *)owner_o)->tp_version_tag != type_version);
2117+
EXIT_IF(((PyTypeObject *)owner_o)->tp_version_tag != type_version);
21182118

21192119
}
21202120

@@ -2189,8 +2189,8 @@ dummy_func(
21892189

21902190
assert(Py_TYPE(owner_o)->tp_dictoffset < 0);
21912191
assert(Py_TYPE(owner_o)->tp_flags & Py_TPFLAGS_INLINE_VALUES);
2192-
DEOPT_IF(_PyObject_GetManagedDict(owner_o));
2193-
DEOPT_IF(_PyObject_InlineValues(owner_o)->valid == 0);
2192+
EXIT_IF(_PyObject_GetManagedDict(owner_o));
2193+
EXIT_IF(_PyObject_InlineValues(owner_o)->valid == 0);
21942194
}
21952195

21962196
op(_STORE_ATTR_INSTANCE_VALUE, (index/1, value, owner --)) {
@@ -3655,11 +3655,11 @@ dummy_func(
36553655
args--;
36563656
total_args++;
36573657
}
3658-
DEOPT_IF(total_args != 1);
3659-
DEOPT_IF(!PyCFunction_CheckExact(callable_o));
3660-
DEOPT_IF(PyCFunction_GET_FLAGS(callable_o) != METH_O);
3658+
EXIT_IF(total_args != 1);
3659+
EXIT_IF(!PyCFunction_CheckExact(callable_o));
3660+
EXIT_IF(PyCFunction_GET_FLAGS(callable_o) != METH_O);
36613661
// CPython promises to check all non-vectorcall function calls.
3662-
DEOPT_IF(tstate->c_recursion_remaining <= 0);
3662+
EXIT_IF(tstate->c_recursion_remaining <= 0);
36633663
STAT_INC(CALL, hit);
36643664
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable_o);
36653665
_PyStackRef arg = args[0];
@@ -3851,15 +3851,15 @@ dummy_func(
38513851
}
38523852

38533853
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
3854-
DEOPT_IF(total_args != 2);
3855-
DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
3854+
EXIT_IF(total_args != 2);
3855+
EXIT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
38563856
PyMethodDef *meth = method->d_method;
3857-
DEOPT_IF(meth->ml_flags != METH_O);
3857+
EXIT_IF(meth->ml_flags != METH_O);
38583858
// CPython promises to check all non-vectorcall function calls.
3859-
DEOPT_IF(tstate->c_recursion_remaining <= 0);
3859+
EXIT_IF(tstate->c_recursion_remaining <= 0);
38603860
_PyStackRef arg_stackref = args[1];
38613861
_PyStackRef self_stackref = args[0];
3862-
DEOPT_IF(!Py_IS_TYPE(PyStackRef_AsPyObjectBorrow(self_stackref),
3862+
EXIT_IF(!Py_IS_TYPE(PyStackRef_AsPyObjectBorrow(self_stackref),
38633863
method->d_common.d_type));
38643864
STAT_INC(CALL, hit);
38653865
PyCFunction cfunc = meth->ml_meth;
@@ -3891,12 +3891,12 @@ dummy_func(
38913891
total_args++;
38923892
}
38933893
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
3894-
DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
3894+
EXIT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
38953895
PyMethodDef *meth = method->d_method;
3896-
DEOPT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS));
3896+
EXIT_IF(meth->ml_flags != (METH_FASTCALL|METH_KEYWORDS));
38973897
PyTypeObject *d_type = method->d_common.d_type;
38983898
PyObject *self = PyStackRef_AsPyObjectBorrow(args[0]);
3899-
DEOPT_IF(!Py_IS_TYPE(self, d_type));
3899+
EXIT_IF(!Py_IS_TYPE(self, d_type));
39003900
STAT_INC(CALL, hit);
39013901
int nargs = total_args - 1;
39023902
PyCFunctionFastWithKeywords cfunc =
@@ -3935,16 +3935,16 @@ dummy_func(
39353935
args--;
39363936
total_args++;
39373937
}
3938-
DEOPT_IF(total_args != 1);
3938+
EXIT_IF(total_args != 1);
39393939
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
3940-
DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
3940+
EXIT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
39413941
PyMethodDef *meth = method->d_method;
39423942
_PyStackRef self_stackref = args[0];
39433943
PyObject *self = PyStackRef_AsPyObjectBorrow(self_stackref);
3944-
DEOPT_IF(!Py_IS_TYPE(self, method->d_common.d_type));
3945-
DEOPT_IF(meth->ml_flags != METH_NOARGS);
3944+
EXIT_IF(!Py_IS_TYPE(self, method->d_common.d_type));
3945+
EXIT_IF(meth->ml_flags != METH_NOARGS);
39463946
// CPython promises to check all non-vectorcall function calls.
3947-
DEOPT_IF(tstate->c_recursion_remaining <= 0);
3947+
EXIT_IF(tstate->c_recursion_remaining <= 0);
39483948
STAT_INC(CALL, hit);
39493949
PyCFunction cfunc = meth->ml_meth;
39503950
_Py_EnterRecursiveCallTstateUnchecked(tstate);
@@ -3973,11 +3973,11 @@ dummy_func(
39733973
}
39743974
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
39753975
/* Builtin METH_FASTCALL methods, without keywords */
3976-
DEOPT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
3976+
EXIT_IF(!Py_IS_TYPE(method, &PyMethodDescr_Type));
39773977
PyMethodDef *meth = method->d_method;
3978-
DEOPT_IF(meth->ml_flags != METH_FASTCALL);
3978+
EXIT_IF(meth->ml_flags != METH_FASTCALL);
39793979
PyObject *self = PyStackRef_AsPyObjectBorrow(args[0]);
3980-
DEOPT_IF(!Py_IS_TYPE(self, method->d_common.d_type));
3980+
EXIT_IF(!Py_IS_TYPE(self, method->d_common.d_type));
39813981
STAT_INC(CALL, hit);
39823982
PyCFunctionFast cfunc =
39833983
(PyCFunctionFast)(void(*)(void))meth->ml_meth;

Diff for: Python/executor_cases.c.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Python/generated_cases.c.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)