mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
GH-118093: Make CALL_ALLOC_AND_ENTER_INIT
suitable for tier 2. (GH-123140)
* Convert CALL_ALLOC_AND_ENTER_INIT to micro-ops such that tier 2 supports it * Allow inexact arguments for CALL_ALLOC_AND_ENTER_INIT.
This commit is contained in:
parent
bffed80230
commit
bb1d30336e
17 changed files with 464 additions and 299 deletions
|
@ -246,7 +246,7 @@ static int check_args_iterable(PyThreadState *, PyObject *func, PyObject *vararg
|
|||
static int get_exception_handler(PyCodeObject *, int, int*, int*, int*);
|
||||
static _PyInterpreterFrame *
|
||||
_PyEvalFramePushAndInit_Ex(PyThreadState *tstate, PyFunctionObject *func,
|
||||
PyObject *locals, Py_ssize_t nargs, PyObject *callargs, PyObject *kwargs);
|
||||
PyObject *locals, Py_ssize_t nargs, PyObject *callargs, PyObject *kwargs, _PyInterpreterFrame *previous);
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
|
@ -671,8 +671,6 @@ static const _Py_CODEUNIT _Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS[] = {
|
|||
{ .op.code = RESUME, .op.arg = RESUME_OPARG_DEPTH1_MASK | RESUME_AT_FUNC_START }
|
||||
};
|
||||
|
||||
extern const struct _PyCode_DEF(8) _Py_InitCleanup;
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
extern void _PyUOpPrint(const _PyUOpInstruction *uop);
|
||||
#endif
|
||||
|
@ -1691,7 +1689,7 @@ _PyEval_FrameClearAndPop(PyThreadState *tstate, _PyInterpreterFrame * frame)
|
|||
_PyInterpreterFrame *
|
||||
_PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
|
||||
PyObject *locals, _PyStackRef const* args,
|
||||
size_t argcount, PyObject *kwnames)
|
||||
size_t argcount, PyObject *kwnames, _PyInterpreterFrame *previous)
|
||||
{
|
||||
PyCodeObject * code = (PyCodeObject *)func->func_code;
|
||||
CALL_STAT_INC(frames_pushed);
|
||||
|
@ -1699,7 +1697,7 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
|
|||
if (frame == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
_PyFrame_Initialize(frame, func, locals, code, 0);
|
||||
_PyFrame_Initialize(frame, func, locals, code, 0, previous);
|
||||
if (initialize_locals(tstate, func, frame->localsplus, args, argcount, kwnames)) {
|
||||
assert(frame->owner == FRAME_OWNED_BY_THREAD);
|
||||
clear_thread_frame(tstate, frame);
|
||||
|
@ -1726,7 +1724,7 @@ fail:
|
|||
static _PyInterpreterFrame *
|
||||
_PyEvalFramePushAndInit_UnTagged(PyThreadState *tstate, PyFunctionObject *func,
|
||||
PyObject *locals, PyObject *const* args,
|
||||
size_t argcount, PyObject *kwnames)
|
||||
size_t argcount, PyObject *kwnames, _PyInterpreterFrame *previous)
|
||||
{
|
||||
#if defined(Py_GIL_DISABLED)
|
||||
size_t kw_count = kwnames == NULL ? 0 : PyTuple_GET_SIZE(kwnames);
|
||||
|
@ -1742,11 +1740,11 @@ _PyEvalFramePushAndInit_UnTagged(PyThreadState *tstate, PyFunctionObject *func,
|
|||
for (size_t i = 0; i < kw_count; i++) {
|
||||
tagged_args_buffer[argcount + i] = PyStackRef_FromPyObjectSteal(args[argcount + i]);
|
||||
}
|
||||
_PyInterpreterFrame *res = _PyEvalFramePushAndInit(tstate, func, locals, (_PyStackRef const *)tagged_args_buffer, argcount, kwnames);
|
||||
_PyInterpreterFrame *res = _PyEvalFramePushAndInit(tstate, func, locals, (_PyStackRef const *)tagged_args_buffer, argcount, kwnames, previous);
|
||||
PyMem_Free(tagged_args_buffer);
|
||||
return res;
|
||||
#else
|
||||
return _PyEvalFramePushAndInit(tstate, func, locals, (_PyStackRef const *)args, argcount, kwnames);
|
||||
return _PyEvalFramePushAndInit(tstate, func, locals, (_PyStackRef const *)args, argcount, kwnames, previous);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1755,7 +1753,7 @@ _PyEvalFramePushAndInit_UnTagged(PyThreadState *tstate, PyFunctionObject *func,
|
|||
*/
|
||||
static _PyInterpreterFrame *
|
||||
_PyEvalFramePushAndInit_Ex(PyThreadState *tstate, PyFunctionObject *func,
|
||||
PyObject *locals, Py_ssize_t nargs, PyObject *callargs, PyObject *kwargs)
|
||||
PyObject *locals, Py_ssize_t nargs, PyObject *callargs, PyObject *kwargs, _PyInterpreterFrame *previous)
|
||||
{
|
||||
bool has_dict = (kwargs != NULL && PyDict_GET_SIZE(kwargs) > 0);
|
||||
PyObject *kwnames = NULL;
|
||||
|
@ -1776,7 +1774,7 @@ _PyEvalFramePushAndInit_Ex(PyThreadState *tstate, PyFunctionObject *func,
|
|||
}
|
||||
_PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit_UnTagged(
|
||||
tstate, (PyFunctionObject *)func, locals,
|
||||
newargs, nargs, kwnames
|
||||
newargs, nargs, kwnames, previous
|
||||
);
|
||||
if (has_dict) {
|
||||
_PyStack_UnpackDict_FreeNoDecRef(newargs, kwnames);
|
||||
|
@ -1813,7 +1811,7 @@ _PyEval_Vector(PyThreadState *tstate, PyFunctionObject *func,
|
|||
}
|
||||
}
|
||||
_PyInterpreterFrame *frame = _PyEvalFramePushAndInit_UnTagged(
|
||||
tstate, func, locals, args, argcount, kwnames);
|
||||
tstate, func, locals, args, argcount, kwnames, NULL);
|
||||
if (frame == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue