From b11a951f16f0603d98de24fee5c023df83ea552c Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Fri, 21 May 2021 10:57:35 +0100 Subject: bpo-44032: Move data stack to thread from FrameObject. (GH-26076) * Remove 'zombie' frames. We won't need them once we are allocating fixed-size frames. * Add co_nlocalplus field to code object to avoid recomputing size of locals + frees + cells. * Move locals, cells and freevars out of frame object into separate memory buffer. * Use per-threadstate allocated memory chunks for local variables. * Move globals and builtins from frame object to per-thread stack. * Move (slow) locals frame object to per-thread stack. * Move internal frame functions to internal header. --- Objects/codeobject.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Objects/codeobject.c') diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 6ac11562254..8b2cee2ea4a 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -280,6 +280,8 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, co->co_posonlyargcount = posonlyargcount; co->co_kwonlyargcount = kwonlyargcount; co->co_nlocals = nlocals; + co->co_nlocalsplus = nlocals + + (int)PyTuple_GET_SIZE(freevars) + (int)PyTuple_GET_SIZE(cellvars); co->co_stacksize = stacksize; co->co_flags = flags; Py_INCREF(code); @@ -304,7 +306,6 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, co->co_linetable = linetable; Py_INCREF(exceptiontable); co->co_exceptiontable = exceptiontable; - co->co_zombieframe = NULL; co->co_weakreflist = NULL; co->co_extra = NULL; @@ -968,8 +969,6 @@ code_dealloc(PyCodeObject *co) Py_XDECREF(co->co_exceptiontable); if (co->co_cell2arg != NULL) PyMem_Free(co->co_cell2arg); - if (co->co_zombieframe != NULL) - PyObject_GC_Del(co->co_zombieframe); if (co->co_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject*)co); PyObject_Free(co); -- cgit v1.2.3