mirror of
https://github.com/python/cpython.git
synced 2025-09-02 15:07:53 +00:00
Revert "bpo-43693: Add the MAKE_CELL opcode and interleave fast locals offsets. (gh-26396)" (GH-26597)
This reverts commit 631f9938b1
.
This commit is contained in:
parent
781dc76577
commit
3fe921cd49
16 changed files with 4238 additions and 4473 deletions
|
@ -3076,34 +3076,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
|
|||
goto error;
|
||||
}
|
||||
|
||||
case TARGET(MAKE_CELL): {
|
||||
PyObject *initial = GETLOCAL(oparg);
|
||||
// Normally initial would be NULL. However, it
|
||||
// might have been set to an initial value during
|
||||
// a call to PyFrame_LocalsToFast().
|
||||
PyObject *cell = PyCell_New(initial);
|
||||
if (cell == NULL) {
|
||||
goto error;
|
||||
}
|
||||
/* If it is an arg then copy the arg into the cell. */
|
||||
if (initial == NULL && co->co_cell2arg != NULL) {
|
||||
int argoffset = co->co_cell2arg[oparg - co->co_nlocals];
|
||||
if (argoffset != CO_CELL_NOT_AN_ARG) {
|
||||
PyObject *arg = GETLOCAL(argoffset);
|
||||
// It will have been set in initialize_locals() but
|
||||
// may have been deleted PyFrame_LocalsToFast().
|
||||
if (arg != NULL) {;
|
||||
Py_INCREF(arg);
|
||||
PyCell_SET(cell, arg);
|
||||
/* Clear the local copy. */
|
||||
SETLOCAL(argoffset, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
SETLOCAL(oparg, cell);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
case TARGET(DELETE_DEREF): {
|
||||
PyObject *cell = GETLOCAL(oparg);
|
||||
PyObject *oldobj = PyCell_GET(cell);
|
||||
|
@ -5095,6 +5067,27 @@ initialize_locals(PyThreadState *tstate, PyFrameConstructor *con,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Allocate and initialize storage for cell vars, and copy free
|
||||
vars into frame. */
|
||||
for (i = 0; i < co->co_ncellvars; ++i) {
|
||||
PyObject *c;
|
||||
Py_ssize_t arg;
|
||||
/* Possibly account for the cell variable being an argument. */
|
||||
if (co->co_cell2arg != NULL &&
|
||||
(arg = co->co_cell2arg[i]) != CO_CELL_NOT_AN_ARG) {
|
||||
c = PyCell_New(GETLOCAL(arg));
|
||||
/* Clear the local copy. */
|
||||
SETLOCAL(arg, NULL);
|
||||
}
|
||||
else {
|
||||
c = PyCell_New(NULL);
|
||||
}
|
||||
if (c == NULL)
|
||||
goto fail;
|
||||
SETLOCAL(co->co_nlocals + i, c);
|
||||
}
|
||||
|
||||
/* Copy closure variables to free variables */
|
||||
for (i = 0; i < co->co_nfreevars; ++i) {
|
||||
PyObject *o = PyTuple_GET_ITEM(con->fc_closure, i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue