summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-01-06 14:55:56 (GMT)
committerGitHub <noreply@github.com>2023-01-06 14:55:56 (GMT)
commit15c44789bb125b93e96815a336ec73423c47508e (patch)
treed8962fa33de6dc997e397a8856eb70d72a542ba7 /Include
parent78068126a1f2172ff61a0871ba43d8530bc73905 (diff)
downloadcpython-15c44789bb125b93e96815a336ec73423c47508e.zip
cpython-15c44789bb125b93e96815a336ec73423c47508e.tar.gz
cpython-15c44789bb125b93e96815a336ec73423c47508e.tar.bz2
gh-100758: Refactor initialisation of frame headers into a single function (_PyFrame_Initialize) (GH-100759)
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_frame.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h
index d5c1dcc..4e2051f 100644
--- a/Include/internal/pycore_frame.h
+++ b/Include/internal/pycore_frame.h
@@ -110,9 +110,9 @@ void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest);
when frame is linked into the frame stack.
*/
static inline void
-_PyFrame_InitializeSpecials(
+_PyFrame_Initialize(
_PyInterpreterFrame *frame, PyFunctionObject *func,
- PyObject *locals, PyCodeObject *code)
+ PyObject *locals, PyCodeObject *code, int null_locals_from)
{
frame->f_funcobj = (PyObject *)func;
frame->f_code = (PyCodeObject *)Py_NewRef(code);
@@ -124,6 +124,10 @@ _PyFrame_InitializeSpecials(
frame->prev_instr = _PyCode_CODE(code) - 1;
frame->yield_offset = 0;
frame->owner = FRAME_OWNED_BY_THREAD;
+
+ for (int i = null_locals_from; i < code->co_nlocalsplus; i++) {
+ frame->localsplus[i] = NULL;
+ }
}
/* Gets the pointer to the locals array
@@ -224,14 +228,14 @@ void _PyThreadState_PopFrame(PyThreadState *tstate, _PyInterpreterFrame *frame);
* Must be guarded by _PyThreadState_HasStackSpace()
* Consumes reference to func. */
static inline _PyInterpreterFrame *
-_PyFrame_PushUnchecked(PyThreadState *tstate, PyFunctionObject *func)
+_PyFrame_PushUnchecked(PyThreadState *tstate, PyFunctionObject *func, int null_locals_from)
{
CALL_STAT_INC(frames_pushed);
PyCodeObject *code = (PyCodeObject *)func->func_code;
_PyInterpreterFrame *new_frame = (_PyInterpreterFrame *)tstate->datastack_top;
tstate->datastack_top += code->co_framesize;
assert(tstate->datastack_top < tstate->datastack_limit);
- _PyFrame_InitializeSpecials(new_frame, func, NULL, code);
+ _PyFrame_Initialize(new_frame, func, NULL, code, null_locals_from);
return new_frame;
}