GH-106701: Move _PyUopExecute to Python/executor.c (GH-106924)

This commit is contained in:
Brandt Bucher 2023-07-20 13:37:19 -07:00 committed by GitHub
parent 9c81fc2dbe
commit 8f4de57699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 276 additions and 247 deletions

View file

@ -77,7 +77,6 @@ dummy_func(
PyObject **stack_pointer,
PyObject *kwnames,
int throwflag,
binaryfunc binary_ops[],
PyObject *args[]
)
{
@ -893,7 +892,7 @@ dummy_func(
iter = _PyCoro_GetAwaitableIter(iterable);
if (iter == NULL) {
format_awaitable_error(tstate, Py_TYPE(iterable), oparg);
_PyEval_FormatAwaitableError(tstate, Py_TYPE(iterable), oparg);
}
DECREF_INPUTS();
@ -1120,9 +1119,9 @@ dummy_func(
err = PyObject_DelItem(ns, name);
// Can't use ERROR_IF here.
if (err != 0) {
format_exc_check_arg(tstate, PyExc_NameError,
NAME_ERROR_MSG,
name);
_PyEval_FormatExcCheckArg(tstate, PyExc_NameError,
NAME_ERROR_MSG,
name);
goto error;
}
}
@ -1145,7 +1144,7 @@ dummy_func(
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
#endif /* ENABLE_SPECIALIZATION */
PyObject **top = stack_pointer + oparg - 1;
int res = unpack_iterable(tstate, seq, oparg, -1, top);
int res = _PyEval_UnpackIterable(tstate, seq, oparg, -1, top);
DECREF_INPUTS();
ERROR_IF(res == 0, error);
}
@ -1185,7 +1184,7 @@ dummy_func(
inst(UNPACK_EX, (seq -- unused[oparg & 0xFF], unused, unused[oparg >> 8])) {
int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8);
PyObject **top = stack_pointer + totalargs - 1;
int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top);
int res = _PyEval_UnpackIterable(tstate, seq, oparg & 0xFF, oparg >> 8, top);
DECREF_INPUTS();
ERROR_IF(res == 0, error);
}
@ -1235,8 +1234,8 @@ dummy_func(
// Can't use ERROR_IF here.
if (err != 0) {
if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
format_exc_check_arg(tstate, PyExc_NameError,
NAME_ERROR_MSG, name);
_PyEval_FormatExcCheckArg(tstate, PyExc_NameError,
NAME_ERROR_MSG, name);
}
goto error;
}
@ -1274,7 +1273,7 @@ dummy_func(
goto error;
}
if (v == NULL) {
format_exc_check_arg(
_PyEval_FormatExcCheckArg(
tstate, PyExc_NameError,
NAME_ERROR_MSG, name);
goto error;
@ -1315,8 +1314,8 @@ dummy_func(
if (!_PyErr_Occurred(tstate)) {
/* _PyDict_LoadGlobal() returns NULL without raising
* an exception if the key doesn't exist */
format_exc_check_arg(tstate, PyExc_NameError,
NAME_ERROR_MSG, name);
_PyEval_FormatExcCheckArg(tstate, PyExc_NameError,
NAME_ERROR_MSG, name);
}
ERROR_IF(true, error);
}
@ -1331,7 +1330,7 @@ dummy_func(
/* namespace 2: builtins */
ERROR_IF(PyMapping_GetOptionalItem(BUILTINS(), name, &v) < 0, error);
if (v == NULL) {
format_exc_check_arg(
_PyEval_FormatExcCheckArg(
tstate, PyExc_NameError,
NAME_ERROR_MSG, name);
ERROR_IF(true, error);
@ -1413,7 +1412,7 @@ dummy_func(
// Can't use ERROR_IF here.
// Fortunately we don't need its superpower.
if (oldobj == NULL) {
format_exc_unbound(tstate, _PyFrame_GetCode(frame), oparg);
_PyEval_FormatExcUnbound(tstate, _PyFrame_GetCode(frame), oparg);
goto error;
}
PyCell_SET(cell, NULL);
@ -1434,7 +1433,7 @@ dummy_func(
PyObject *cell = GETLOCAL(oparg);
value = PyCell_GET(cell);
if (value == NULL) {
format_exc_unbound(tstate, _PyFrame_GetCode(frame), oparg);
_PyEval_FormatExcUnbound(tstate, _PyFrame_GetCode(frame), oparg);
goto error;
}
Py_INCREF(value);
@ -1445,7 +1444,7 @@ dummy_func(
PyObject *cell = GETLOCAL(oparg);
value = PyCell_GET(cell);
if (value == NULL) {
format_exc_unbound(tstate, _PyFrame_GetCode(frame), oparg);
_PyEval_FormatExcUnbound(tstate, _PyFrame_GetCode(frame), oparg);
ERROR_IF(true, error);
}
Py_INCREF(value);
@ -1612,7 +1611,7 @@ dummy_func(
PyObject *dict = PEEK(oparg + 1); // update is still on the stack
if (_PyDict_MergeEx(dict, update, 2) < 0) {
format_kwargs_error(tstate, PEEK(3 + oparg), update);
_PyEval_FormatKwargsError(tstate, PEEK(3 + oparg), update);
DECREF_INPUTS();
ERROR_IF(true, error);
}
@ -2126,15 +2125,15 @@ dummy_func(
}
inst(CHECK_EG_MATCH, (exc_value, match_type -- rest, match)) {
if (check_except_star_type_valid(tstate, match_type) < 0) {
if (_PyEval_CheckExceptStarTypeValid(tstate, match_type) < 0) {
DECREF_INPUTS();
ERROR_IF(true, error);
}
match = NULL;
rest = NULL;
int res = exception_group_match(exc_value, match_type,
&match, &rest);
int res = _PyEval_ExceptionGroupMatch(exc_value, match_type,
&match, &rest);
DECREF_INPUTS();
ERROR_IF(res < 0, error);
@ -2148,7 +2147,7 @@ dummy_func(
inst(CHECK_EXC_MATCH, (left, right -- left, b)) {
assert(PyExceptionInstance_Check(left));
if (check_except_type_valid(tstate, right) < 0) {
if (_PyEval_CheckExceptTypeValid(tstate, right) < 0) {
DECREF_INPUTS();
ERROR_IF(true, error);
}
@ -2275,7 +2274,7 @@ dummy_func(
// Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or
// None on failure.
assert(PyTuple_CheckExact(names));
attrs = match_class(tstate, subject, type, oparg, names);
attrs = _PyEval_MatchClass(tstate, subject, type, oparg, names);
DECREF_INPUTS();
if (attrs) {
assert(PyTuple_CheckExact(attrs)); // Success!
@ -2298,7 +2297,7 @@ dummy_func(
inst(MATCH_KEYS, (subject, keys -- subject, keys, values_or_none)) {
// On successful match, PUSH(values). Otherwise, PUSH(None).
values_or_none = match_keys(tstate, subject, keys);
values_or_none = _PyEval_MatchKeys(tstate, subject, keys);
ERROR_IF(values_or_none == NULL, error);
}
@ -3617,10 +3616,10 @@ dummy_func(
STAT_INC(BINARY_OP, deferred);
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
#endif /* ENABLE_SPECIALIZATION */
assert(0 <= oparg);
assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
assert(binary_ops[oparg]);
res = binary_ops[oparg](lhs, rhs);
assert(NB_ADD <= oparg);
assert(oparg <= NB_INPLACE_XOR);
assert(_PyEval_BinaryOps[oparg]);
res = _PyEval_BinaryOps[oparg](lhs, rhs);
DECREF_INPUTS();
ERROR_IF(res == NULL, error);
}