]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127022: Remove `_PyEvalFramePushAndInit_UnTagged` (gh-127168)
authorSam Gross <colesbury@gmail.com>
Mon, 25 Nov 2024 17:24:37 +0000 (17:24 +0000)
committerGitHub <noreply@github.com>
Mon, 25 Nov 2024 17:24:37 +0000 (12:24 -0500)
The interpreter now handles `_PyStackRef`s pointing to immortal objects
without the deferred bit set, so `_PyEvalFramePushAndInit_UnTagged` is
no longer necessary.

Python/ceval.c

index 2a3938572c156984b7939280d6eca9764b5965e2..eba0f233a81ef35b27cddf615f6f49f9932bc2b2 100644 (file)
@@ -1800,33 +1800,6 @@ fail:
     return NULL;
 }
 
-static _PyInterpreterFrame *
-_PyEvalFramePushAndInit_UnTagged(PyThreadState *tstate, _PyStackRef func,
-                        PyObject *locals, PyObject *const* args,
-                        size_t argcount, PyObject *kwnames, _PyInterpreterFrame *previous)
-{
-#if defined(Py_GIL_DISABLED)
-    size_t kw_count = kwnames == NULL ? 0 : PyTuple_GET_SIZE(kwnames);
-    size_t total_argcount = argcount + kw_count;
-    _PyStackRef *tagged_args_buffer = PyMem_Malloc(sizeof(_PyStackRef) * total_argcount);
-    if (tagged_args_buffer == NULL) {
-        PyErr_NoMemory();
-        return NULL;
-    }
-    for (size_t i = 0; i < argcount; i++) {
-        tagged_args_buffer[i] = PyStackRef_FromPyObjectSteal(args[i]);
-    }
-    for (size_t i = 0; i < kw_count; i++) {
-        tagged_args_buffer[argcount + i] = PyStackRef_FromPyObjectSteal(args[argcount + i]);
-    }
-    _PyInterpreterFrame *res = _PyEvalFramePushAndInit(tstate, func, locals, (_PyStackRef const *)tagged_args_buffer, argcount, kwnames, previous);
-    PyMem_Free(tagged_args_buffer);
-    return res;
-#else
-    return _PyEvalFramePushAndInit(tstate, func, locals, (_PyStackRef const *)args, argcount, kwnames, previous);
-#endif
-}
-
 /* Same as _PyEvalFramePushAndInit but takes an args tuple and kwargs dict.
    Steals references to func, callargs and kwargs.
 */
@@ -1851,9 +1824,9 @@ _PyEvalFramePushAndInit_Ex(PyThreadState *tstate, _PyStackRef func,
             Py_INCREF(PyTuple_GET_ITEM(callargs, i));
         }
     }
-    _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit_UnTagged(
+    _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit(
         tstate, func, locals,
-        newargs, nargs, kwnames, previous
+        (_PyStackRef const *)newargs, nargs, kwnames, previous
     );
     if (has_dict) {
         _PyStack_UnpackDict_FreeNoDecRef(newargs, kwnames);
@@ -1888,9 +1861,9 @@ _PyEval_Vector(PyThreadState *tstate, PyFunctionObject *func,
             Py_INCREF(args[i+argcount]);
         }
     }
-    _PyInterpreterFrame *frame = _PyEvalFramePushAndInit_UnTagged(
+    _PyInterpreterFrame *frame = _PyEvalFramePushAndInit(
         tstate, PyStackRef_FromPyObjectNew(func), locals,
-        args, argcount, kwnames, NULL);
+        (_PyStackRef const *)args, argcount, kwnames, NULL);
     if (frame == NULL) {
         return NULL;
     }