|
15 | 15 | #include "pycore_interpframe.h" |
16 | 16 | #include "pycore_interpolation.h" |
17 | 17 | #include "pycore_intrinsics.h" |
| 18 | +#include "pycore_jit_unwind.h" |
18 | 19 | #include "pycore_lazyimportobject.h" |
19 | 20 | #include "pycore_list.h" |
20 | 21 | #include "pycore_long.h" |
@@ -60,6 +61,28 @@ jit_error(const char *message) |
60 | 61 | PyErr_Format(PyExc_RuntimeWarning, "JIT %s (%d)", message, hint); |
61 | 62 | } |
62 | 63 |
|
| 64 | +static void |
| 65 | +jit_record_code(const void *code_addr, size_t code_size, |
| 66 | + const char *entry, const char *filename) |
| 67 | +{ |
| 68 | +#ifdef PY_HAVE_PERF_TRAMPOLINE |
| 69 | + _PyPerf_Callbacks callbacks; |
| 70 | + _PyPerfTrampoline_GetCallbacks(&callbacks); |
| 71 | + if (callbacks.write_state == _Py_perfmap_jit_callbacks.write_state) { |
| 72 | + _PyPerfJit_WriteNamedCode( |
| 73 | + code_addr, (unsigned int)code_size, entry, filename); |
| 74 | + return; |
| 75 | + } |
| 76 | + _PyJitUnwind_GdbRegisterCode( |
| 77 | + code_addr, (unsigned int)code_size, entry, filename); |
| 78 | +#else |
| 79 | + (void)code_addr; |
| 80 | + (void)code_size; |
| 81 | + (void)entry; |
| 82 | + (void)filename; |
| 83 | +#endif |
| 84 | +} |
| 85 | + |
63 | 86 | static size_t _Py_jit_shim_size = 0; |
64 | 87 |
|
65 | 88 | static int |
@@ -731,6 +754,10 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz |
731 | 754 | } |
732 | 755 | executor->jit_code = memory; |
733 | 756 | executor->jit_size = total_size; |
| 757 | + jit_record_code(memory, |
| 758 | + code_size + state.trampolines.size, |
| 759 | + "jit_executor", |
| 760 | + "<jit>"); |
734 | 761 | return 0; |
735 | 762 | } |
736 | 763 |
|
@@ -781,6 +808,10 @@ compile_shim(void) |
781 | 808 | return NULL; |
782 | 809 | } |
783 | 810 | _Py_jit_shim_size = total_size; |
| 811 | + jit_record_code(memory, |
| 812 | + code_size + state.trampolines.size, |
| 813 | + "jit_shim", |
| 814 | + "<jit>"); |
784 | 815 | return (_PyJitEntryFuncPtr)memory; |
785 | 816 | } |
786 | 817 |
|
|
0 commit comments