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).
This commit is contained in:
Mark Shannon 2022-01-28 12:42:30 +00:00 committed by GitHub
parent 5a9e423473
commit 89fd7c3452
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 957 additions and 674 deletions

View file

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