diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2024-01-28 18:48:48 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-28 18:48:48 -0800 |
commit | f6d9e5926b6138994eaa60d1c36462e36105733d (patch) | |
tree | 53362fa9918ab65519ccf9a343cfcdfcfa9c4f6f /Python/optimizer.c | |
parent | f7c05d7ad3075a1dbeed86b6b12903032e4afba6 (diff) | |
download | cpython-f6d9e5926b6138994eaa60d1c36462e36105733d.tar.gz cpython-f6d9e5926b6138994eaa60d1c36462e36105733d.zip |
GH-113464: Add a JIT backend for tier 2 (GH-113465)
Add an option (--enable-experimental-jit for configure-based builds
or --experimental-jit for PCbuild-based ones) to build an
*experimental* just-in-time compiler, based on copy-and-patch (https://fredrikbk.com/publications/copy-and-patch.pdf).
See Tools/jit/README.md for more information on how to install the required build-time tooling.
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r-- | Python/optimizer.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index db615068ff5..0d04b09fef1 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -7,6 +7,7 @@ #include "pycore_optimizer.h" // _Py_uop_analyze_and_optimize() #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_uop_ids.h" +#include "pycore_jit.h" #include "cpython/optimizer.h" #include <stdbool.h> #include <stdint.h> @@ -227,6 +228,9 @@ static PyMethodDef executor_methods[] = { static void uop_dealloc(_PyExecutorObject *self) { _Py_ExecutorClear(self); +#ifdef _Py_JIT + _PyJIT_Free(self); +#endif PyObject_Free(self); } @@ -790,6 +794,14 @@ make_executor_from_uops(_PyUOpInstruction *buffer, _PyBloomFilter *dependencies) } } #endif +#ifdef _Py_JIT + executor->jit_code = NULL; + executor->jit_size = 0; + if (_PyJIT_Compile(executor, executor->trace, Py_SIZE(executor))) { + Py_DECREF(executor); + return NULL; + } +#endif return executor; } |