mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-98831: Modernize CALL_FUNCTION_EX (#101627)
New generator feature: Move CHECK_EVAL_BREAKER() call to just before DISPATCH().
This commit is contained in:
parent
790ff6bc6a
commit
a9f01448a9
5 changed files with 41 additions and 37 deletions
|
@ -2951,26 +2951,21 @@ dummy_func(
|
|||
CHECK_EVAL_BREAKER();
|
||||
}
|
||||
|
||||
// error: CALL_FUNCTION_EX has irregular stack effect
|
||||
inst(CALL_FUNCTION_EX) {
|
||||
PyObject *func, *callargs, *kwargs = NULL, *result;
|
||||
if (oparg & 0x01) {
|
||||
kwargs = POP();
|
||||
inst(CALL_FUNCTION_EX, (unused, func, callargs, kwargs if (oparg & 1) -- result)) {
|
||||
if (oparg & 1) {
|
||||
// DICT_MERGE is called before this opcode if there are kwargs.
|
||||
// It converts all dict subtypes in kwargs into regular dicts.
|
||||
assert(PyDict_CheckExact(kwargs));
|
||||
}
|
||||
callargs = POP();
|
||||
func = TOP();
|
||||
if (!PyTuple_CheckExact(callargs)) {
|
||||
if (check_args_iterable(tstate, func, callargs) < 0) {
|
||||
Py_DECREF(callargs);
|
||||
goto error;
|
||||
}
|
||||
Py_SETREF(callargs, PySequence_Tuple(callargs));
|
||||
if (callargs == NULL) {
|
||||
PyObject *tuple = PySequence_Tuple(callargs);
|
||||
if (tuple == NULL) {
|
||||
goto error;
|
||||
}
|
||||
Py_SETREF(callargs, tuple);
|
||||
}
|
||||
assert(PyTuple_CheckExact(callargs));
|
||||
|
||||
|
@ -2979,12 +2974,8 @@ dummy_func(
|
|||
Py_DECREF(callargs);
|
||||
Py_XDECREF(kwargs);
|
||||
|
||||
STACK_SHRINK(1);
|
||||
assert(TOP() == NULL);
|
||||
SET_TOP(result);
|
||||
if (result == NULL) {
|
||||
goto error;
|
||||
}
|
||||
assert(PEEK(3 + (oparg & 1)) == NULL);
|
||||
ERROR_IF(result == NULL, error);
|
||||
CHECK_EVAL_BREAKER();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue