diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2024-10-30 00:12:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-30 00:12:45 (GMT) |
commit | 2d37c719ed7c54430257028be6b48a1e2d065973 (patch) | |
tree | 772e7edbb2170fae1cccb2c016d2747ee87ad9a8 /Python | |
parent | 2d9d10179ff3f13029bf4430e62c455a839987ca (diff) | |
download | cpython-2d37c719ed7c54430257028be6b48a1e2d065973.zip cpython-2d37c719ed7c54430257028be6b48a1e2d065973.tar.gz cpython-2d37c719ed7c54430257028be6b48a1e2d065973.tar.bz2 |
gh-124855: Don't allow the JIT and perf support to be active at the same time (#124856)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pylifecycle.c | 21 | ||||
-rw-r--r-- | Python/sysmodule.c | 8 |
2 files changed, 22 insertions, 7 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 8f38fbe..2efaa9d 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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 (_Py_SetTier2Optimizer((_PyOptimizerObject *)opt)) { - return _PyStatus_ERR("can't install 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); } - Py_DECREF(opt); } } #endif diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 24af479..cbb7397 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -2287,6 +2287,14 @@ sys_activate_stack_trampoline_impl(PyObject *module, const char *backend) /*[clinic end generated code: output=5783cdeb51874b43 input=a12df928758a82b4]*/ { #ifdef PY_HAVE_PERF_TRAMPOLINE +#ifdef _Py_JIT + _PyOptimizerObject* optimizer = _Py_GetOptimizer(); + if (optimizer != NULL) { + PyErr_SetString(PyExc_ValueError, "Cannot activate the perf trampoline if the JIT is active"); + return NULL; + } +#endif + if (strcmp(backend, "perf") == 0) { _PyPerf_Callbacks cur_cb; _PyPerfTrampoline_GetCallbacks(&cur_cb); |