@@ -220,25 +220,25 @@ static void free_code_arenas(void);
220220static int _PyPerfTrampoline_Fini_Locked (void );
221221
222222static void
223- perf_trampoline_clear_code_watcher (void )
223+ perf_trampoline_clear_code_watcher (void )
224224{
225- if (code_watcher_id >= 0 ) {
226- PyCode_ClearWatcher (code_watcher_id );
227- code_watcher_id = -1 ;
228- }
229- _Py_atomic_store_ssize_relaxed (& extra_code_index , -1 );
225+ if (code_watcher_id >= 0 ) {
226+ PyCode_ClearWatcher (code_watcher_id );
227+ code_watcher_id = -1 ;
228+ }
229+ _Py_atomic_store_ssize_relaxed (& extra_code_index , -1 );
230230}
231231
232232static void
233233perf_trampoline_reset_state (void )
234234{
235- free_code_arenas ();
236- // We do NOT clear code_watcher_id here. PyCode_ClearWatcher is not
237- // thread-safe in free-threading mode against concurrent code deallocation.
238- // Leaving the watcher active is safe. We MUST reset extra_code_index to -1
239- // so that next activation gets a new index, because the old index's
240- // co_extra array still contains dangling pointers to the freed arenas.
241- _Py_atomic_store_ssize_relaxed (& extra_code_index , -1 );
235+ free_code_arenas ();
236+ // We do NOT clear code_watcher_id here. PyCode_ClearWatcher is not
237+ // thread-safe in free-threading mode against concurrent code deallocation.
238+ // Leaving the watcher active is safe. We MUST reset extra_code_index to -1
239+ // so that next activation gets a new index, because the old index's
240+ // co_extra array still contains dangling pointers to the freed arenas.
241+ _Py_atomic_store_ssize_relaxed (& extra_code_index , -1 );
242242}
243243
244244static int
@@ -282,7 +282,7 @@ perf_map_write_entry(void *state, const void *code_addr,
282282 filename = PyUnicode_AsUTF8 (co -> co_filename );
283283 }
284284 size_t perf_map_entry_size = snprintf (NULL , 0 , "py::%s:%s" , entry , filename ) + 1 ;
285- char * perf_map_entry = (char * )PyMem_RawMalloc (perf_map_entry_size );
285+ char * perf_map_entry = (char * ) PyMem_RawMalloc (perf_map_entry_size );
286286 if (perf_map_entry == NULL ) {
287287 return ;
288288 }
@@ -360,7 +360,7 @@ new_code_arena(void)
360360 void * end = & _Py_trampoline_func_end ;
361361 size_t code_size = end - start ;
362362 size_t unaligned_size = code_size + trampoline_api .code_padding ;
363- size_t chunk_size = round_up (unaligned_size , trampoline_api .code_alignment );
363+ size_t chunk_size = round_up (unaligned_size , trampoline_api .code_alignment );
364364 assert (chunk_size % trampoline_api .code_alignment == 0 );
365365 // TODO: Check the effect of alignment of the code chunks. Initial investigation
366366 // showed that this has no effect on performance in x86-64 or aarch64 and the current
@@ -426,8 +426,8 @@ static inline py_trampoline
426426code_arena_new_code (code_arena_t * code_arena )
427427{
428428 py_trampoline trampoline = (py_trampoline )code_arena -> current_addr ;
429- size_t total_code_size = round_up (code_arena -> code_size + trampoline_api .code_padding ,
430- trampoline_api .code_alignment );
429+ size_t total_code_size = round_up (code_arena -> code_size + trampoline_api .code_padding ,
430+ trampoline_api .code_alignment );
431431 assert (total_code_size % trampoline_api .code_alignment == 0 );
432432 code_arena -> size_left -= total_code_size ;
433433 code_arena -> current_addr += total_code_size ;
0 commit comments