|
5 | 5 | #include "internal/pycore_pystate.h" |
6 | 6 |
|
7 | 7 | #include "cinderx/CachedProperties/cached_properties.h" |
8 | | -#include "cinderx/Common/dict.h" |
9 | | -#include "cinderx/Common/func.h" |
10 | 8 | #include "cinderx/Common/log.h" |
11 | 9 | #include "cinderx/Common/py-portability.h" |
12 | 10 | #include "cinderx/Common/util.h" |
|
19 | 17 | #include "cinderx/Jit/global_cache.h" |
20 | 18 | #include "cinderx/Jit/perf_jitdump.h" |
21 | 19 | #include "cinderx/Jit/pyjit.h" |
22 | | -#include "cinderx/Jit/pyjit_result.h" |
23 | 20 | #include "cinderx/Jit/runtime.h" |
24 | 21 | #include "cinderx/Jit/symbolizer.h" |
25 | 22 | #include "cinderx/Shadowcode/shadowcode.h" |
|
32 | 29 | #include "cinderx/StaticPython/methodobject_vectorcall.h" |
33 | 30 | #include "cinderx/StaticPython/objectkey.h" |
34 | 31 | #include "cinderx/StaticPython/strictmoduleobject.h" |
35 | | -#include "cinderx/StaticPython/vtable_builder.h" |
36 | 32 | #include "cinderx/UpstreamBorrow/borrowed.h" |
37 | 33 | #include "cinderx/async_lazy_value.h" |
38 | 34 | #include "cinderx/module_state.h" |
|
58 | 54 |
|
59 | 55 | namespace { |
60 | 56 |
|
61 | | -// Function objects registered for pre-fork perf-trampoline compilation. |
62 | | -std::unordered_set<BorrowedRef<PyFunctionObject>> perf_trampoline_worklist; |
63 | | - |
64 | 57 | /* |
65 | 58 | * Misc. Python-facing utility functions. |
66 | 59 | */ |
@@ -287,6 +280,9 @@ PyObject* compile_perf_trampoline_pre_fork(PyObject*, PyObject*) { |
287 | 280 |
|
288 | 281 | PyUnstable_PerfTrampoline_SetPersistAfterFork(1); |
289 | 282 |
|
| 283 | + auto& perf_trampoline_worklist = |
| 284 | + cinderx::getModuleState()->perfTrampolineWorklist(); |
| 285 | + |
290 | 286 | for (BorrowedRef<PyFunctionObject> func : perf_trampoline_worklist) { |
291 | 287 | BorrowedRef<PyCodeObject> code = func->func_code; |
292 | 288 | if (PyUnstable_PerfTrampoline_CompileCode(code) == -1) { |
@@ -439,6 +435,8 @@ PyObject* get_entire_call_stack_as_qualnames_with_lineno_and_frame( |
439 | 435 | void scheduleCompile(BorrowedRef<PyFunctionObject> func) { |
440 | 436 | bool scheduled = jit::scheduleJitCompile(func); |
441 | 437 | if (!scheduled && jit::perf::isPreforkCompilationEnabled()) { |
| 438 | + auto& perf_trampoline_worklist = |
| 439 | + cinderx::getModuleState()->perfTrampolineWorklist(); |
442 | 440 | perf_trampoline_worklist.emplace(func); |
443 | 441 | } |
444 | 442 | } |
@@ -756,6 +754,8 @@ int cinderx_func_watcher( |
756 | 754 | #endif |
757 | 755 | case PyFunction_EVENT_DESTROY: |
758 | 756 | if (jit::perf::isPreforkCompilationEnabled()) { |
| 757 | + auto& perf_trampoline_worklist = |
| 758 | + cinderx::getModuleState()->perfTrampolineWorklist(); |
759 | 759 | perf_trampoline_worklist.erase(func); |
760 | 760 | } |
761 | 761 | jit::funcDestroyed(func); |
|
0 commit comments