Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-124855: Don't allow the JIT and perf support to be active at the s…
…ame time

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
pablogsal committed Oct 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 398e38f951b9c0bf4cca56c07b13261afb3d68f2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Don't allow the JIT and perf support to be active at the same time. Patch by
Pablo Galindo
21 changes: 14 additions & 7 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
@@ -1300,14 +1300,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
8 changes: 8 additions & 0 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
@@ -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_TIER2
_PyOptimizerObject* optimizer = _Py_GetOptimizer();
if (optimizer != NULL) {
PyErr_SetString(PyExc_ValueError, "Cannot activate the perf trampiline if the JIT is active");
return NULL;
}
#endif

if (strcmp(backend, "perf") == 0) {
_PyPerf_Callbacks cur_cb;
_PyPerfTrampoline_GetCallbacks(&cur_cb);
Loading
Oops, something went wrong.