bpo-45256: Rationalize code around Python-to-Python calls a bit. (GH-29235)

This commit is contained in:
Mark Shannon 2021-10-28 16:14:59 +01:00 committed by GitHub
parent 0a1a36b74b
commit 7f61d9d848
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 121 additions and 70 deletions

View file

@ -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;