diff options
author | Mark Shannon <mark@hotpy.org> | 2021-06-07 17:38:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-07 17:38:06 (GMT) |
commit | 001eb520b5757294dc455c900d94b7b153de6cdd (patch) | |
tree | c9d3a3d36e860a9a0591ce6d7d758201e72c2230 /Objects | |
parent | 89e50ab36fac6a0e7f1998501f36fcd2872a6604 (diff) | |
download | cpython-001eb520b5757294dc455c900d94b7b153de6cdd.zip cpython-001eb520b5757294dc455c900d94b7b153de6cdd.tar.gz cpython-001eb520b5757294dc455c900d94b7b153de6cdd.tar.bz2 |
bpo-44187: Quickening infrastructure (GH-26264)
* Add co_firstinstr field to code object.
* Implement barebones quickening.
* Use non-quickened bytecode when tracing.
* Add NEWS item
* Add new file to Windows build.
* Don't specialize instructions with EXTENDED_ARG.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/codeobject.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 75e8182..768f5d1 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -211,6 +211,7 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con) Py_INCREF(con->code); co->co_code = con->code; + co->co_firstinstr = (_Py_CODEUNIT *)PyBytes_AS_STRING(con->code); co->co_firstlineno = con->firstlineno; Py_INCREF(con->linetable); co->co_linetable = con->linetable; @@ -250,6 +251,8 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con) co->co_opcache = NULL; co->co_opcache_flag = 0; co->co_opcache_size = 0; + co->co_warmup = QUICKENING_INITIAL_WARMUP_VALUE; + co->co_quickened = NULL; } /* The caller is responsible for ensuring that the given data is valid. */ @@ -376,7 +379,8 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, if (_PyCode_Validate(&con) < 0) { return NULL; } - + assert(PyBytes_GET_SIZE(code) % sizeof(_Py_CODEUNIT) == 0); + assert(_Py_IS_ALIGNED(PyBytes_AS_STRING(code), sizeof(_Py_CODEUNIT))); if (nlocals != PyTuple_GET_SIZE(varnames)) { PyErr_SetString(PyExc_ValueError, "code: co_nlocals != len(co_varnames)"); @@ -1039,6 +1043,10 @@ code_dealloc(PyCodeObject *co) PyMem_Free(co->co_cell2arg); if (co->co_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject*)co); + if (co->co_quickened) { + PyMem_Free(co->co_quickened); + _Py_QuickenedCount--; + } PyObject_Free(co); } |