diff options
author | Guido van Rossum <guido@python.org> | 2023-06-26 19:02:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-26 19:02:57 -0700 |
commit | 51fc72511733353de15bc633a3d7b6da366842e4 (patch) | |
tree | 13c7075d57530adf90f82ba0025649f163b51abb /Python/pylifecycle.c | |
parent | d3af83b9342457d8b24476baeb799f7506ff04f3 (diff) | |
download | cpython-51fc72511733353de15bc633a3d7b6da366842e4.tar.gz cpython-51fc72511733353de15bc633a3d7b6da366842e4.zip |
gh-104584: Baby steps towards generating and executing traces (#105924)
Added a new, experimental, tracing optimizer and interpreter (a.k.a. "tier 2"). This currently pessimizes, so don't use yet -- this is infrastructure so we can experiment with optimizing passes. To enable it, pass ``-Xuops`` or set ``PYTHONUOPS=1``. To get debug output, set ``PYTHONUOPSDEBUG=N`` where ``N`` is a debug level (0-4, where 0 is no debug output and 4 is excessively verbose).
All of this code is likely to change dramatically before the 3.13 feature freeze. But this is a first step.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 5a5b14fbb03..6117f3a19a5 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1181,6 +1181,19 @@ init_interp_main(PyThreadState *tstate) #endif } + // Turn on experimental tier 2 (uops-based) optimizer + if (is_main_interp) { + char *envvar = Py_GETENV("PYTHONUOPS"); + int enabled = envvar != NULL && *envvar > '0'; + if (_Py_get_xoption(&config->xoptions, L"uops") != NULL) { + enabled = 1; + } + if (enabled) { + PyObject *opt = PyUnstable_Optimizer_NewUOpOptimizer(); + PyUnstable_SetOptimizer((_PyOptimizerObject *)opt); + } + } + assert(!_PyErr_Occurred(tstate)); return _PyStatus_OK(); |