Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 additions & 0 deletions Lib/test/test_perf_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,24 @@ def test_sys_api_get_status(self):
"""
assert_python_ok("-c", code, PYTHON_JIT="0")

def test_sys_api_perf_jit_backend(self):
code = """if 1:
import sys
sys.activate_stack_trampoline("perf_jit")
assert sys.is_stack_trampoline_active() is True
sys.deactivate_stack_trampoline()
assert sys.is_stack_trampoline_active() is False
"""
assert_python_ok("-c", code, PYTHON_JIT="0")

def test_sys_api_with_existing_perf_jit_trampoline(self):
code = """if 1:
import sys
sys.activate_stack_trampoline("perf_jit")
sys.activate_stack_trampoline("perf_jit")
"""
assert_python_ok("-c", code, PYTHON_JIT="0")


def is_unwinding_reliable_with_frame_pointers():
cflags = sysconfig.get_config_var("PY_CORE_CFLAGS")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :func:`sys.activate_stack_trampoline` to properly support the
``perf_jit`` backend. Patch by Pablo Galindo.
16 changes: 8 additions & 8 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2373,14 +2373,14 @@ sys_activate_stack_trampoline_impl(PyObject *module, const char *backend)
return NULL;
}
}
else if (strcmp(backend, "perf_jit") == 0) {
_PyPerf_Callbacks cur_cb;
_PyPerfTrampoline_GetCallbacks(&cur_cb);
if (cur_cb.write_state != _Py_perfmap_jit_callbacks.write_state) {
if (_PyPerfTrampoline_SetCallbacks(&_Py_perfmap_jit_callbacks) < 0 ) {
PyErr_SetString(PyExc_ValueError, "can't activate perf jit trampoline");
return NULL;
}
}
else if (strcmp(backend, "perf_jit") == 0) {
_PyPerf_Callbacks cur_cb;
_PyPerfTrampoline_GetCallbacks(&cur_cb);
if (cur_cb.write_state != _Py_perfmap_jit_callbacks.write_state) {
if (_PyPerfTrampoline_SetCallbacks(&_Py_perfmap_jit_callbacks) < 0 ) {
PyErr_SetString(PyExc_ValueError, "can't activate perf jit trampoline");
return NULL;
}
}
}
Expand Down
Loading