diff options
| author | Pablo Galindo <Pablogsal@gmail.com> | 2021-06-04 16:51:05 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-04 16:51:05 (GMT) |
| commit | 17c4edc4e0692fe55e185755ea8a2f5238f3ef08 (patch) | |
| tree | 563807f4bbdebbf89b2065e4807cc291c44be2b1 /Include/internal/pycore_code.h | |
| parent | a46c220edc5cf716d0b71eb80ac29ecdb4ebb430 (diff) | |
| download | cpython-17c4edc4e0692fe55e185755ea8a2f5238f3ef08.zip cpython-17c4edc4e0692fe55e185755ea8a2f5238f3ef08.tar.gz cpython-17c4edc4e0692fe55e185755ea8a2f5238f3ef08.tar.bz2 | |
bpo-43693: Revert commits 2c1e2583fdc4db6b43d163239ea42b0e8394171f and b2bf2bc1ece673d387341e06c8d3c2bc6e259747 (GH-26530)
* Revert "bpo-43693: Compute deref offsets in compiler (gh-25152)"
This reverts commit b2bf2bc1ece673d387341e06c8d3c2bc6e259747.
* Revert "bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)"
This reverts commit 2c1e2583fdc4db6b43d163239ea42b0e8394171f.
These two commits are breaking the refleak buildbots.
Diffstat (limited to 'Include/internal/pycore_code.h')
| -rw-r--r-- | Include/internal/pycore_code.h | 62 |
1 files changed, 3 insertions, 59 deletions
diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h index 95b4730..dab6c34 100644 --- a/Include/internal/pycore_code.h +++ b/Include/internal/pycore_code.h @@ -26,57 +26,6 @@ struct _PyOpcache { }; -/* "Locals plus" for a code object is the set of locals + cell vars + - * free vars. This relates to variable names as well as offsets into - * the "fast locals" storage array of execution frames. The compiler - * builds the list of names, their offsets, and the corresponding - * kind of local. - * - * Those kinds represent the source of the initial value and the - * variable's scope (as related to closures). A "local" is an - * argument or other variable defined in the current scope. A "free" - * variable is one that is defined in an outer scope and comes from - * the function's closure. A "cell" variable is a local that escapes - * into an inner function as part of a closure, and thus must be - * wrapped in a cell. Any "local" can also be a "cell", but the - * "free" kind is mutually exclusive with both. - */ - -// We would use an enum if C let us specify the storage type. -typedef unsigned char _PyLocalsPlusKind; -/* Note that these all fit within _PyLocalsPlusKind, as do combinations. */ -// Later, we will use the smaller numbers to differentiate the different -// kinds of locals (e.g. pos-only arg, varkwargs, local-only). -#define CO_FAST_LOCAL 0x20 -#define CO_FAST_CELL 0x40 -#define CO_FAST_FREE 0x80 - -typedef _PyLocalsPlusKind *_PyLocalsPlusKinds; - -static inline int -_PyCode_InitLocalsPlusKinds(int num, _PyLocalsPlusKinds *pkinds) -{ - if (num == 0) { - *pkinds = NULL; - return 0; - } - _PyLocalsPlusKinds kinds = PyMem_NEW(_PyLocalsPlusKind, num); - if (kinds == NULL) { - PyErr_NoMemory(); - return -1; - } - *pkinds = kinds; - return 0; -} - -static inline void -_PyCode_ClearLocalsPlusKinds(_PyLocalsPlusKinds kinds) -{ - if (kinds != NULL) { - PyMem_Free(kinds); - } -} - struct _PyCodeConstructor { /* metadata */ PyObject *filename; @@ -93,13 +42,13 @@ struct _PyCodeConstructor { PyObject *names; /* mapping frame offsets to information */ - PyObject *localsplusnames; - _PyLocalsPlusKinds localspluskinds; + PyObject *varnames; + PyObject *cellvars; + PyObject *freevars; /* args (within varnames) */ int argcount; int posonlyargcount; - // XXX Replace argcount with posorkwargcount (argcount - posonlyargcount). int kwonlyargcount; /* needed to create the frame */ @@ -126,11 +75,6 @@ PyAPI_FUNC(PyCodeObject *) _PyCode_New(struct _PyCodeConstructor *); int _PyCode_InitOpcache(PyCodeObject *co); -/* Getters for internal PyCodeObject data. */ -PyAPI_FUNC(PyObject *) _PyCode_GetVarnames(PyCodeObject *); -PyAPI_FUNC(PyObject *) _PyCode_GetCellvars(PyCodeObject *); -PyAPI_FUNC(PyObject *) _PyCode_GetFreevars(PyCodeObject *); - #ifdef __cplusplus } |
