gh-124855: Don't allow the JIT and perf support to be active at the same time (#124856)

This commit is contained in:
Pablo Galindo Salgado
2024-10-30 00:12:45 +00:00
committed by GitHub
parent 2d9d10179f
commit 2d37c719ed
4 changed files with 26 additions and 7 deletions

View File

@@ -1310,14 +1310,21 @@ init_interp_main(PyThreadState *tstate)
enabled = *env != '0';
}
if (enabled) {
PyObject *opt = _PyOptimizer_NewUOpOptimizer();
if (opt == NULL) {
return _PyStatus_ERR("can't initialize optimizer");
if (config->perf_profiling > 0) {
(void)PyErr_WarnEx(
PyExc_RuntimeWarning,
"JIT deactivated as perf profiling support is active",
0);
} else {
PyObject *opt = _PyOptimizer_NewUOpOptimizer();
if (opt == NULL) {
return _PyStatus_ERR("can't initialize optimizer");
}
if (_Py_SetTier2Optimizer((_PyOptimizerObject *)opt)) {
return _PyStatus_ERR("can't install optimizer");
}
Py_DECREF(opt);
}
if (_Py_SetTier2Optimizer((_PyOptimizerObject *)opt)) {
return _PyStatus_ERR("can't install optimizer");
}
Py_DECREF(opt);
}
}
#endif