@@ -345,41 +345,3 @@ bool mi_abandoned_visit_blocks(mi_subproc_id_t subproc_id, int heap_tag, bool vi
345345 return ok ;
346346}
347347
348-
349- /* -----------------------------------------------------------
350- CPython: visit all abandoned segments of a sub-process without
351- taking any locks or claiming the segments.
352-
353- Unlike `mi_abandoned_visit_blocks`, this does not require
354- `mi_option_visit_abandoned` to be enabled. The caller must
355- guarantee that no other thread abandons or reclaims segments
356- concurrently (in CPython: a stop-the-world pause), and the
357- visitor must not allocate or free mimalloc managed memory.
358- ----------------------------------------------------------- */
359-
360- bool _mi_abandoned_visit_blocks_unlocked (mi_subproc_t * subproc , int heap_tag , bool visit_blocks , mi_block_visit_fun * visitor , void * arg ) {
361- // segments in arenas are tracked in the `blocks_abandoned` bitmaps
362- const size_t max_arena = mi_arena_get_count ();
363- for (size_t arena_idx = 0 ; arena_idx < max_arena ; arena_idx ++ ) {
364- mi_arena_t * arena = mi_arena_from_index (arena_idx );
365- if (arena == NULL ) continue ;
366- for (size_t field_idx = 0 ; field_idx < arena -> field_count ; field_idx ++ ) {
367- size_t field = mi_atomic_load_relaxed (& arena -> blocks_abandoned [field_idx ]);
368- while (field != 0 ) {
369- const size_t bit_idx = mi_ctz (field );
370- field &= ~((size_t )1 << bit_idx );
371- const mi_bitmap_index_t bitmap_idx = mi_bitmap_index_create (field_idx , bit_idx );
372- mi_segment_t * const segment = (mi_segment_t * )mi_arena_block_start (arena , bitmap_idx );
373- mi_assert_internal (mi_atomic_load_relaxed (& segment -> thread_id ) == 0 );
374- if (segment -> subproc != subproc ) continue ;
375- if (!_mi_segment_visit_blocks (segment , heap_tag , visit_blocks , visitor , arg )) return false;
376- }
377- }
378- }
379- // segments outside arenas (OS allocated) are kept in a per sub-process list
380- for (mi_segment_t * segment = subproc -> abandoned_os_list ; segment != NULL ; segment = segment -> abandoned_os_next ) {
381- mi_assert_internal (segment -> subproc == subproc );
382- if (!_mi_segment_visit_blocks (segment , heap_tag , visit_blocks , visitor , arg )) return false;
383- }
384- return true;
385- }
0 commit comments