bpo-43693: Compute deref offsets in compiler (gh-25152)

Merges locals and cells into a single array.
Saves a pointer in the interpreter and means that we don't need the LOAD_CLOSURE opcode any more

https://bugs.python.org/issue43693
This commit is contained in:
Mark Shannon 2021-06-04 01:03:54 +01:00 committed by GitHub
parent 35002aa8f6
commit b2bf2bc1ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 222 additions and 209 deletions

View file

@ -1547,8 +1547,6 @@ error:
code._varname_from_oparg
oparg: int
*
cell: bool = False
(internal-only) Return the local variable name for the given oparg.
@ -1556,12 +1554,9 @@ WARNING: this method is for internal use only and may change or go away.
[clinic start generated code]*/
static PyObject *
code__varname_from_oparg_impl(PyCodeObject *self, int oparg, int cell)
/*[clinic end generated code: output=c7d39c9723692c8f input=2945bb291d3a3118]*/
code__varname_from_oparg_impl(PyCodeObject *self, int oparg)
/*[clinic end generated code: output=1fd1130413184206 input=c5fa3ee9bac7d4ca]*/
{
if (cell) {
oparg += self->co_nlocals;
}
PyObject *name = PyTuple_GetItem(self->co_localsplusnames, oparg);
if (name == NULL) {
return NULL;