diff options
author | Mark Shannon <mark@hotpy.org> | 2022-01-28 12:42:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 12:42:30 (GMT) |
commit | 89fd7c34520aac493a8784a221366ed04452612b (patch) | |
tree | da2dd6dfe862b1351063e2c0ee2a3564c4773416 /Python/frame.c | |
parent | 5a9e423473bf2c4eb32a0982e8d73420875db1da (diff) | |
download | cpython-89fd7c34520aac493a8784a221366ed04452612b.zip cpython-89fd7c34520aac493a8784a221366ed04452612b.tar.gz cpython-89fd7c34520aac493a8784a221366ed04452612b.tar.bz2 |
bpo-46329: Split calls into precall and call instructions. (GH-30855)
* Add PRECALL_FUNCTION opcode.
* Move 'call shape' varaibles into struct.
* Replace CALL_NO_KW and CALL_KW with KW_NAMES and CALL instructions.
* Specialize for builtin methods taking using the METH_FASTCALL | METH_KEYWORDS protocol.
* Allow kwnames for specialized calls to builtin types.
* Specialize calls to tuple(arg) and str(arg).
Diffstat (limited to 'Python/frame.c')
-rw-r--r-- | Python/frame.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Python/frame.c b/Python/frame.c index 9578747..771de75 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -83,7 +83,7 @@ take_ownership(PyFrameObject *f, InterpreterFrame *frame) } void -_PyFrame_Clear(InterpreterFrame * frame) +_PyFrame_Clear(InterpreterFrame *frame) { /* It is the responsibility of the owning generator/coroutine * to have cleared the enclosing generator, if any. */ @@ -107,3 +107,16 @@ _PyFrame_Clear(InterpreterFrame * frame) Py_DECREF(frame->f_func); Py_DECREF(frame->f_code); } + +InterpreterFrame * +_PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func) +{ + PyCodeObject *code = (PyCodeObject *)func->func_code; + size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE; + InterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size); + if (new_frame == NULL) { + return NULL; + } + _PyFrame_InitializeSpecials(new_frame, func, NULL, code->co_nlocalsplus); + return new_frame; +} |