GH-126910: add test for manual frame unwinding (#144137)

This commit is contained in:
Diego Russo 2026-01-27 13:17:40 +00:00 committed by GitHub
parent 197e4c0628
commit 66055d0650
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 539 additions and 2 deletions

View file

@ -58,6 +58,49 @@ jit_error(const char *message)
PyErr_Format(PyExc_RuntimeWarning, "JIT %s (%d)", message, hint);
}
static size_t _Py_jit_shim_size = 0;
static int
address_in_executor_list(_PyExecutorObject *head, uintptr_t addr)
{
for (_PyExecutorObject *exec = head;
exec != NULL;
exec = exec->vm_data.links.next)
{
if (exec->jit_code == NULL || exec->jit_size == 0) {
continue;
}
uintptr_t start = (uintptr_t)exec->jit_code;
uintptr_t end = start + exec->jit_size;
if (addr >= start && addr < end) {
return 1;
}
}
return 0;
}
PyAPI_FUNC(int)
_PyJIT_AddressInJitCode(PyInterpreterState *interp, uintptr_t addr)
{
if (interp == NULL) {
return 0;
}
if (_Py_jit_entry != _Py_LazyJitShim && _Py_jit_shim_size != 0) {
uintptr_t start = (uintptr_t)_Py_jit_entry;
uintptr_t end = start + _Py_jit_shim_size;
if (addr >= start && addr < end) {
return 1;
}
}
if (address_in_executor_list(interp->executor_list_head, addr)) {
return 1;
}
if (address_in_executor_list(interp->executor_deletion_list_head, addr)) {
return 1;
}
return 0;
}
static unsigned char *
jit_alloc(size_t size)
{
@ -151,8 +194,6 @@ typedef struct {
uintptr_t instruction_starts[UOP_MAX_TRACE_LENGTH];
} jit_state;
static size_t _Py_jit_shim_size = 0;
// Warning! AArch64 requires you to get your hands dirty. These are your gloves:
// value[value_start : value_start + len]