summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-10-28 15:14:59 (GMT)
committerGitHub <noreply@github.com>2021-10-28 15:14:59 (GMT)
commit7f61d9d84843e3445f62eb00c47902f0daa30a72 (patch)
tree054cc49374ae490d85a6e23b9c969d2af7f0c159 /Python/pystate.c
parent0a1a36b74bdf8da286924a1c9652853b1c46f536 (diff)
downloadcpython-7f61d9d84843e3445f62eb00c47902f0daa30a72.zip
cpython-7f61d9d84843e3445f62eb00c47902f0daa30a72.tar.gz
cpython-7f61d9d84843e3445f62eb00c47902f0daa30a72.tar.bz2
bpo-45256: Rationalize code around Python-to-Python calls a bit. (GH-29235)
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 114f915..a9ed08a 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -2065,12 +2065,8 @@ push_chunk(PyThreadState *tstate, int size)
}
InterpreterFrame *
-_PyThreadState_PushFrame(PyThreadState *tstate, PyFrameConstructor *con, PyObject *locals)
+_PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size)
{
- PyCodeObject *code = (PyCodeObject *)con->fc_code;
- int nlocalsplus = code->co_nlocalsplus;
- size_t size = nlocalsplus + code->co_stacksize +
- FRAME_SPECIALS_SIZE;
assert(size < INT_MAX/sizeof(PyObject *));
PyObject **base = tstate->datastack_top;
PyObject **top = base + size;
@@ -2083,7 +2079,21 @@ _PyThreadState_PushFrame(PyThreadState *tstate, PyFrameConstructor *con, PyObjec
else {
tstate->datastack_top = top;
}
- InterpreterFrame *frame = (InterpreterFrame *)base;
+ return (InterpreterFrame *)base;
+}
+
+
+InterpreterFrame *
+_PyThreadState_PushFrame(PyThreadState *tstate, PyFrameConstructor *con, PyObject *locals)
+{
+ PyCodeObject *code = (PyCodeObject *)con->fc_code;
+ int nlocalsplus = code->co_nlocalsplus;
+ size_t size = nlocalsplus + code->co_stacksize +
+ FRAME_SPECIALS_SIZE;
+ InterpreterFrame *frame = _PyThreadState_BumpFramePointer(tstate, size);
+ if (frame == NULL) {
+ return NULL;
+ }
_PyFrame_InitializeSpecials(frame, con, locals, nlocalsplus);
for (int i=0; i < nlocalsplus; i++) {
frame->localsplus[i] = NULL;