summaryrefslogtreecommitdiffstats
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-08-02 15:31:17 (GMT)
committerGitHub <noreply@github.com>2024-08-02 15:31:17 (GMT)
commit7aca84e557d0a6d242f322c493d53947a56bde91 (patch)
tree748b14a2221f090721673c936f20f21e7d87d323 /Python/generated_cases.c.h
parent498376d7a7d6f704f22a2c963130cc15c17e7a6f (diff)
downloadcpython-7aca84e557d0a6d242f322c493d53947a56bde91.zip
cpython-7aca84e557d0a6d242f322c493d53947a56bde91.tar.gz
cpython-7aca84e557d0a6d242f322c493d53947a56bde91.tar.bz2
GH-117224: Move the body of a few large-ish micro-ops into helper functions (GH-122601)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h117
1 files changed, 8 insertions, 109 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 4efaf89..bed194e 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -3468,45 +3468,9 @@
_PyStackRef aiter;
_PyStackRef awaitable;
aiter = stack_pointer[-1];
- unaryfunc getter = NULL;
- PyObject *next_iter = NULL;
- PyObject *awaitable_o;
- PyObject *aiter_o = PyStackRef_AsPyObjectBorrow(aiter);
- PyTypeObject *type = Py_TYPE(aiter_o);
- if (PyAsyncGen_CheckExact(aiter_o)) {
- awaitable_o = type->tp_as_async->am_anext(aiter_o);
- if (awaitable_o == NULL) {
- goto error;
- }
- } else {
- if (type->tp_as_async != NULL){
- getter = type->tp_as_async->am_anext;
- }
- if (getter != NULL) {
- next_iter = (*getter)(aiter_o);
- if (next_iter == NULL) {
- goto error;
- }
- }
- else {
- _PyErr_Format(tstate, PyExc_TypeError,
- "'async for' requires an iterator with "
- "__anext__ method, got %.100s",
- type->tp_name);
- goto error;
- }
- awaitable_o = _PyCoro_GetAwaitableIter(next_iter);
- if (awaitable_o == NULL) {
- _PyErr_FormatFromCause(
- PyExc_TypeError,
- "'async for' received an invalid object "
- "from __anext__: %.100s",
- Py_TYPE(next_iter)->tp_name);
- Py_DECREF(next_iter);
- goto error;
- } else {
- Py_DECREF(next_iter);
- }
+ PyObject *awaitable_o = _PyEval_GetANext(PyStackRef_AsPyObjectBorrow(aiter));
+ if (awaitable_o == NULL) {
+ goto error;
}
awaitable = PyStackRef_FromPyObjectSteal(awaitable_o);
stack_pointer[0] = awaitable;
@@ -3522,25 +3486,8 @@
_PyStackRef iterable;
_PyStackRef iter;
iterable = stack_pointer[-1];
- PyObject *iter_o = _PyCoro_GetAwaitableIter(PyStackRef_AsPyObjectBorrow(iterable));
- if (iter_o == NULL) {
- _PyEval_FormatAwaitableError(tstate,
- Py_TYPE(PyStackRef_AsPyObjectBorrow(iterable)), oparg);
- }
+ PyObject *iter_o = _PyEval_GetAwaitable(PyStackRef_AsPyObjectBorrow(iterable), oparg);
PyStackRef_CLOSE(iterable);
- if (iter_o != NULL && PyCoro_CheckExact(iter_o)) {
- PyObject *yf = _PyGen_yf((PyGenObject*)iter_o);
- if (yf != NULL) {
- /* `iter` is a coroutine object that is being
- awaited, `yf` is a pointer to the current awaitable
- being awaited on. */
- Py_DECREF(yf);
- Py_CLEAR(iter_o);
- _PyErr_SetString(tstate, PyExc_RuntimeError,
- "coroutine is being awaited already");
- /* The code below jumps to `error` if `iter` is NULL. */
- }
- }
if (iter_o == NULL) goto pop_1_error;
iter = PyStackRef_FromPyObjectSteal(iter_o);
stack_pointer[-1] = iter;
@@ -5231,38 +5178,8 @@
// _LOAD_GLOBAL
{
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
- PyObject *res_o;
- if (PyDict_CheckExact(GLOBALS())
- && PyDict_CheckExact(BUILTINS()))
- {
- res_o = _PyDict_LoadGlobal((PyDictObject *)GLOBALS(),
- (PyDictObject *)BUILTINS(),
- name);
- if (res_o == NULL) {
- if (!_PyErr_Occurred(tstate)) {
- /* _PyDict_LoadGlobal() returns NULL without raising
- * an exception if the key doesn't exist */
- _PyEval_FormatExcCheckArg(tstate, PyExc_NameError,
- NAME_ERROR_MSG, name);
- }
- if (true) goto error;
- }
- }
- else {
- /* Slow-path if globals or builtins is not a dict */
- /* namespace 1: globals */
- if (PyMapping_GetOptionalItem(GLOBALS(), name, &res_o) < 0) goto error;
- if (res_o == NULL) {
- /* namespace 2: builtins */
- if (PyMapping_GetOptionalItem(BUILTINS(), name, &res_o) < 0) goto error;
- if (res_o == NULL) {
- _PyEval_FormatExcCheckArg(
- tstate, PyExc_NameError,
- NAME_ERROR_MSG, name);
- if (true) goto error;
- }
- }
- }
+ PyObject *res_o = _PyEval_LoadGlobal(GLOBALS(), BUILTINS(), name);
+ if (res_o == NULL) goto error;
null = PyStackRef_NULL;
res = PyStackRef_FromPyObjectSteal(res_o);
}
@@ -5375,27 +5292,9 @@
next_instr += 1;
INSTRUCTION_STATS(LOAD_NAME);
_PyStackRef v;
- PyObject *v_o;
- PyObject *mod_or_class_dict = LOCALS();
- if (mod_or_class_dict == NULL) {
- _PyErr_SetString(tstate, PyExc_SystemError,
- "no locals found");
- if (true) goto error;
- }
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
- if (PyMapping_GetOptionalItem(mod_or_class_dict, name, &v_o) < 0) goto error;
- if (v_o == NULL) {
- if (PyDict_GetItemRef(GLOBALS(), name, &v_o) < 0) goto error;
- if (v_o == NULL) {
- if (PyMapping_GetOptionalItem(BUILTINS(), name, &v_o) < 0) goto error;
- if (v_o == NULL) {
- _PyEval_FormatExcCheckArg(
- tstate, PyExc_NameError,
- NAME_ERROR_MSG, name);
- if (true) goto error;
- }
- }
- }
+ PyObject *v_o = _PyEval_LoadName(tstate, frame, name);
+ if (v_o == NULL) goto error;
v = PyStackRef_FromPyObjectSteal(v_o);
stack_pointer[0] = v;
stack_pointer += 1;