mirror of https://github.com/python/cpython
gh-124855: Don't allow the JIT and perf support to be active at the same time (#124856)
This commit is contained in:
parent
2d9d10179f
commit
2d37c719ed
|
@ -1757,6 +1757,8 @@ always available.
|
||||||
Activate the stack profiler trampoline *backend*.
|
Activate the stack profiler trampoline *backend*.
|
||||||
The only supported backend is ``"perf"``.
|
The only supported backend is ``"perf"``.
|
||||||
|
|
||||||
|
Stack trampolines cannot be activated if the JIT is active.
|
||||||
|
|
||||||
.. availability:: Linux.
|
.. availability:: Linux.
|
||||||
|
|
||||||
.. versionadded:: 3.12
|
.. versionadded:: 3.12
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Don't allow the JIT and perf support to be active at the same time. Patch by
|
||||||
|
Pablo Galindo
|
|
@ -1310,14 +1310,21 @@ init_interp_main(PyThreadState *tstate)
|
||||||
enabled = *env != '0';
|
enabled = *env != '0';
|
||||||
}
|
}
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
PyObject *opt = _PyOptimizer_NewUOpOptimizer();
|
if (config->perf_profiling > 0) {
|
||||||
if (opt == NULL) {
|
(void)PyErr_WarnEx(
|
||||||
return _PyStatus_ERR("can't initialize optimizer");
|
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
|
#endif
|
||||||
|
|
|
@ -2287,6 +2287,14 @@ sys_activate_stack_trampoline_impl(PyObject *module, const char *backend)
|
||||||
/*[clinic end generated code: output=5783cdeb51874b43 input=a12df928758a82b4]*/
|
/*[clinic end generated code: output=5783cdeb51874b43 input=a12df928758a82b4]*/
|
||||||
{
|
{
|
||||||
#ifdef PY_HAVE_PERF_TRAMPOLINE
|
#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) {
|
if (strcmp(backend, "perf") == 0) {
|
||||||
_PyPerf_Callbacks cur_cb;
|
_PyPerf_Callbacks cur_cb;
|
||||||
_PyPerfTrampoline_GetCallbacks(&cur_cb);
|
_PyPerfTrampoline_GetCallbacks(&cur_cb);
|
||||||
|
|
Loading…
Reference in New Issue