mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
GH-93897: Store frame size in code object and de-opt if insufficient space on thread frame stack. (GH-93908)
This commit is contained in:
parent
774ef28814
commit
45e62a2bc1
8 changed files with 50 additions and 67 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "opcode.h"
|
||||
#include "structmember.h" // PyMemberDef
|
||||
#include "pycore_code.h" // _PyCodeConstructor
|
||||
#include "pycore_frame.h" // FRAME_SPECIALS_SIZE
|
||||
#include "pycore_interp.h" // PyInterpreterState.co_extra_freefuncs
|
||||
#include "pycore_opcode.h" // _PyOpcode_Deopt
|
||||
#include "pycore_pystate.h" // _PyInterpreterState_GET()
|
||||
|
|
@ -327,6 +328,7 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
|
|||
/* derived values */
|
||||
co->co_nlocalsplus = nlocalsplus;
|
||||
co->co_nlocals = nlocals;
|
||||
co->co_framesize = nlocalsplus + con->stacksize + FRAME_SPECIALS_SIZE;
|
||||
co->co_nplaincellvars = nplaincellvars;
|
||||
co->co_ncellvars = ncellvars;
|
||||
co->co_nfreevars = nfreevars;
|
||||
|
|
|
|||
|
|
@ -858,8 +858,9 @@ init_frame(_PyInterpreterFrame *frame, PyFunctionObject *func, PyObject *locals)
|
|||
{
|
||||
/* _PyFrame_InitializeSpecials consumes reference to func */
|
||||
Py_INCREF(func);
|
||||
Py_XINCREF(locals);
|
||||
PyCodeObject *code = (PyCodeObject *)func->func_code;
|
||||
_PyFrame_InitializeSpecials(frame, func, locals, code->co_nlocalsplus);
|
||||
_PyFrame_InitializeSpecials(frame, func, locals, code);
|
||||
for (Py_ssize_t i = 0; i < code->co_nlocalsplus; i++) {
|
||||
frame->localsplus[i] = NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue