diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-06-08 12:17:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-08 12:17:55 (GMT) |
commit | 3fe921cd49959181163671364c8b84faa88f7895 (patch) | |
tree | 939bcd1d318405affab0df79ffe650c1565565af /Python/ceval.c | |
parent | 781dc76577b1810666f4ce04d8fc20d8b43fb374 (diff) | |
download | cpython-3fe921cd49959181163671364c8b84faa88f7895.zip cpython-3fe921cd49959181163671364c8b84faa88f7895.tar.gz cpython-3fe921cd49959181163671364c8b84faa88f7895.tar.bz2 |
Revert "bpo-43693: Add the MAKE_CELL opcode and interleave fast locals offsets. (gh-26396)" (GH-26597)
This reverts commit 631f9938b1604d4f893417ec339b9e0fa9196fb1.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index a8abead..032bc0c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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); |