summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2024-05-01 01:26:34 (GMT)
committerGitHub <noreply@github.com>2024-05-01 01:26:34 (GMT)
commit7d83f7bcc484145596bae1ff015fed0762da345d (patch)
treef2f3cbb0cefaa920b319c77da00606fef1db48aa /Python/pystate.c
parent9c468e2c5dffb6fa9811fd16e70fa0463bdfce5f (diff)
downloadcpython-7d83f7bcc484145596bae1ff015fed0762da345d.zip
cpython-7d83f7bcc484145596bae1ff015fed0762da345d.tar.gz
cpython-7d83f7bcc484145596bae1ff015fed0762da345d.tar.bz2
gh-118335: Configure Tier 2 interpreter at build time (#118339)
The code for Tier 2 is now only compiled when configured with `--enable-experimental-jit[=yes|interpreter]`. We drop support for `PYTHON_UOPS` and -`Xuops`, but you can disable the interpreter or JIT at runtime by setting `PYTHON_JIT=0`. You can also build it without enabling it by default using `--enable-experimental-jit=yes-off`; enable with `PYTHON_JIT=1`. On Windows, the `build.bat` script supports `--experimental-jit`, `--experimental-jit-off`, `--experimental-interpreter`. In the C code, `_Py_JIT` is defined as before when the JIT is enabled; the new variable `_Py_TIER2` is defined when the JIT *or* the interpreter is enabled. It is actually a bitmask: 1: JIT; 2: default-off; 4: interpreter.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 9d7b73b..3d6e76e 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -653,8 +653,10 @@ init_interpreter(PyInterpreterState *interp,
}
interp->sys_profile_initialized = false;
interp->sys_trace_initialized = false;
+#ifdef _Py_TIER2
(void)_Py_SetOptimizer(interp, NULL);
interp->executor_list_head = NULL;
+#endif
if (interp != &runtime->_main_interpreter) {
/* Fix the self-referential, statically initialized fields. */
interp->dtoa = (struct _dtoa_state)_dtoa_state_INIT(interp);
@@ -806,9 +808,11 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
tstate->_status.cleared = 0;
}
+#ifdef _Py_TIER2
_PyOptimizerObject *old = _Py_SetOptimizer(interp, NULL);
assert(old != NULL);
Py_DECREF(old);
+#endif
/* It is possible that any of the objects below have a finalizer
that runs Python code or otherwise relies on a thread state
@@ -2821,9 +2825,11 @@ _PyInterpreterState_SetEvalFrameFunc(PyInterpreterState *interp,
if (eval_frame == interp->eval_frame) {
return;
}
+#ifdef _Py_TIER2
if (eval_frame != NULL) {
_Py_Executors_InvalidateAll(interp, 1);
}
+#endif
RARE_EVENT_INC(set_eval_frame_func);
interp->eval_frame = eval_frame;
}