summaryrefslogtreecommitdiffstats
path: root/Include/cpython/code.h
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-06-04 16:51:05 (GMT)
committerGitHub <noreply@github.com>2021-06-04 16:51:05 (GMT)
commit17c4edc4e0692fe55e185755ea8a2f5238f3ef08 (patch)
tree563807f4bbdebbf89b2065e4807cc291c44be2b1 /Include/cpython/code.h
parenta46c220edc5cf716d0b71eb80ac29ecdb4ebb430 (diff)
downloadcpython-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/cpython/code.h')
-rw-r--r--Include/cpython/code.h20
1 files changed, 5 insertions, 15 deletions
diff --git a/Include/cpython/code.h b/Include/cpython/code.h
index add34f3..5c0fae4 100644
--- a/Include/cpython/code.h
+++ b/Include/cpython/code.h
@@ -3,8 +3,6 @@
#endif
typedef uint16_t _Py_CODEUNIT;
-// Each oparg must fit in the second half of _Py_CODEUNIT, hence 8 bits.
-#define _Py_MAX_OPARG 255
#ifdef WORDS_BIGENDIAN
# define _Py_OPCODE(word) ((word) >> 8)
@@ -16,11 +14,6 @@ typedef uint16_t _Py_CODEUNIT;
typedef struct _PyOpcache _PyOpcache;
-
-// These are duplicated from pycore_code.h.
-typedef unsigned char _PyLocalsPlusKind;
-typedef _PyLocalsPlusKind *_PyLocalsPlusKinds;
-
/* Bytecode object */
struct PyCodeObject {
PyObject_HEAD
@@ -60,8 +53,9 @@ struct PyCodeObject {
int co_kwonlyargcount; /* #keyword only arguments */
int co_stacksize; /* #entries needed for evaluation stack */
int co_firstlineno; /* first source line number */
- PyObject *co_localsplusnames; /* tuple mapping offsets to names */
- _PyLocalsPlusKinds co_localspluskinds; /* array mapping to local kinds */
+ PyObject *co_varnames; /* tuple of strings (local variable names) */
+ PyObject *co_cellvars; /* tuple of strings (cell variable names) */
+ PyObject *co_freevars; /* tuple of strings (free variable names) */
PyObject *co_filename; /* unicode (where it was loaded from) */
PyObject *co_name; /* unicode (name, for reference) */
PyObject *co_linetable; /* string (encoding addr<->lineno mapping) See
@@ -71,15 +65,11 @@ struct PyCodeObject {
/* These fields are set with computed values on new code objects. */
int *co_cell2arg; /* Maps cell vars which are arguments. */
- // redundant values (derived from co_localsplusnames and co_localspluskinds)
+ // These are redundant but offer some performance benefit.
int co_nlocalsplus; /* number of local + cell + free variables */
int co_nlocals; /* number of local variables */
int co_ncellvars; /* number of cell variables */
int co_nfreevars; /* number of free variables */
- // lazily-computed values
- PyObject *co_varnames; /* tuple of strings (local variable names) */
- PyObject *co_cellvars; /* tuple of strings (cell variable names) */
- PyObject *co_freevars; /* tuple of strings (free variable names) */
/* The remaining fields are zeroed out on new code objects. */
@@ -153,7 +143,7 @@ struct PyCodeObject {
PyAPI_DATA(PyTypeObject) PyCode_Type;
#define PyCode_Check(op) Py_IS_TYPE(op, &PyCode_Type)
-#define PyCode_GetNumFree(op) ((op)->co_nfreevars)
+#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
/* Public interface */
PyAPI_FUNC(PyCodeObject *) PyCode_New(