@@ -220,7 +220,7 @@ static void gc_sync_cache(jl_ptls_t ptls, jl_gc_mark_cache_t *gc_cache) JL_NOTSA
220220}
221221
222222// No other threads can be running marking at the same time 
223- static  void  gc_sync_all_caches (jl_ptls_t  ptls )
223+ static  void  gc_sync_all_caches (jl_ptls_t  ptls )  JL_NOTSAFEPOINT 
224224{
225225    assert (gc_n_threads );
226226    for  (int  t_i  =  0 ; t_i  <  gc_n_threads ; t_i ++ ) {
@@ -364,7 +364,7 @@ JL_DLLEXPORT jl_weakref_t *jl_gc_new_weakref_th(jl_ptls_t ptls, jl_value_t *valu
364364    return  wr ;
365365}
366366
367- static  void  clear_weak_refs (void )
367+ static  void  clear_weak_refs (void )  JL_NOTSAFEPOINT 
368368{
369369    assert (gc_n_threads );
370370    for  (int  i  =  0 ; i  <  gc_n_threads ; i ++ ) {
@@ -381,7 +381,7 @@ static void clear_weak_refs(void)
381381    }
382382}
383383
384- static  void  sweep_weak_refs (void )
384+ static  void  sweep_weak_refs (void )  JL_NOTSAFEPOINT 
385385{
386386    assert (gc_n_threads );
387387    for  (int  i  =  0 ; i  <  gc_n_threads ; i ++ ) {
@@ -1153,7 +1153,7 @@ static void gc_pool_sync_nfree(jl_gc_pagemeta_t *pg, jl_taggedvalue_t *last) JL_
11531153
11541154// pre-scan pages to check whether there are enough pages so that's worth parallelizing 
11551155// also sweeps pages that don't need to be linearly scanned 
1156- int  gc_sweep_prescan (jl_ptls_t  ptls , jl_gc_padded_page_stack_t  * new_gc_allocd_scratch )
1156+ int  gc_sweep_prescan (jl_ptls_t  ptls , jl_gc_padded_page_stack_t  * new_gc_allocd_scratch )  JL_NOTSAFEPOINT 
11571157{
11581158    // 4MB worth of pages is worth parallelizing 
11591159    const  int  n_pages_worth_parallel_sweep  =  (int )(4  *  (1  << 20 ) / GC_PAGE_SZ );
@@ -1210,7 +1210,7 @@ int gc_sweep_prescan(jl_ptls_t ptls, jl_gc_padded_page_stack_t *new_gc_allocd_sc
12101210}
12111211
12121212// wake up all threads to sweep the pages 
1213- void  gc_sweep_wake_all_pages (jl_ptls_t  ptls , jl_gc_padded_page_stack_t  * new_gc_allocd_scratch )
1213+ void  gc_sweep_wake_all_pages (jl_ptls_t  ptls , jl_gc_padded_page_stack_t  * new_gc_allocd_scratch )  JL_NOTSAFEPOINT 
12141214{
12151215    int  parallel_sweep_worthwhile  =  gc_sweep_prescan (ptls , new_gc_allocd_scratch );
12161216    if  (parallel_sweep_worthwhile  &&  !page_profile_enabled ) {
@@ -1246,7 +1246,7 @@ void gc_sweep_wake_all_pages(jl_ptls_t ptls, jl_gc_padded_page_stack_t *new_gc_a
12461246}
12471247
12481248// wait for all threads to finish sweeping 
1249- void  gc_sweep_wait_for_all_pages (void )
1249+ void  gc_sweep_wait_for_all_pages (void )  JL_NOTSAFEPOINT 
12501250{
12511251    jl_atomic_store (& gc_allocd_scratch , NULL );
12521252    while  (jl_atomic_load_acquire (& gc_n_threads_sweeping_pools ) !=  0 ) {
@@ -1255,7 +1255,7 @@ void gc_sweep_wait_for_all_pages(void)
12551255}
12561256
12571257// sweep all pools 
1258- void  gc_sweep_pool_parallel (jl_ptls_t  ptls )
1258+ void  gc_sweep_pool_parallel (jl_ptls_t  ptls )  JL_NOTSAFEPOINT 
12591259{
12601260    jl_atomic_fetch_add (& gc_n_threads_sweeping_pools , 1 );
12611261    jl_gc_padded_page_stack_t  * allocd_scratch  =  jl_atomic_load (& gc_allocd_scratch );
@@ -1306,7 +1306,7 @@ void gc_sweep_pool_parallel(jl_ptls_t ptls)
13061306}
13071307
13081308// free all pages (i.e. through `madvise` on Linux) that were lazily freed 
1309- void  gc_free_pages (void )
1309+ void  gc_free_pages (void )  JL_NOTSAFEPOINT 
13101310{
13111311    size_t  n_pages_seen  =  0 ;
13121312    jl_gc_page_stack_t  tmp ;
@@ -1344,7 +1344,7 @@ void gc_free_pages(void)
13441344}
13451345
13461346// setup the data-structures for a sweep over all memory pools 
1347- static  void  gc_sweep_pool (void )
1347+ static  void  gc_sweep_pool (void )  JL_NOTSAFEPOINT 
13481348{
13491349    gc_time_pool_start ();
13501350
@@ -1466,7 +1466,7 @@ static void gc_sweep_pool(void)
14661466    gc_time_pool_end (current_sweep_full );
14671467}
14681468
1469- static  void  gc_sweep_perm_alloc (void )
1469+ static  void  gc_sweep_perm_alloc (void )  JL_NOTSAFEPOINT 
14701470{
14711471    uint64_t  t0  =  jl_hrtime ();
14721472    gc_sweep_sysimg ();
@@ -2237,7 +2237,7 @@ JL_DLLEXPORT void jl_gc_mark_queue_objarray(jl_ptls_t ptls, jl_value_t *parent,
22372237
22382238// Enqueue and mark all outgoing references from `new_obj` which have not been marked yet. 
22392239// `_new_obj` has its lowest bit tagged if it's in the remset (in which case we shouldn't update page metadata) 
2240- FORCE_INLINE  void  gc_mark_outrefs (jl_ptls_t  ptls , jl_gc_markqueue_t  * mq , void  * _new_obj )
2240+ FORCE_INLINE  void  gc_mark_outrefs (jl_ptls_t  ptls , jl_gc_markqueue_t  * mq , void  * _new_obj )  JL_NOTSAFEPOINT 
22412241{
22422242    int  meta_updated  =  (uintptr_t )_new_obj  &  GC_REMSET_PTR_TAG ;
22432243    jl_value_t  * new_obj  =  (jl_value_t  * )((uintptr_t )_new_obj  &  ~(uintptr_t )GC_REMSET_PTR_TAG );
@@ -2513,7 +2513,7 @@ FORCE_INLINE void gc_mark_outrefs(jl_ptls_t ptls, jl_gc_markqueue_t *mq, void *_
25132513}
25142514
25152515// Used in gc-debug 
2516- void  gc_mark_loop_serial_ (jl_ptls_t  ptls , jl_gc_markqueue_t  * mq )
2516+ void  gc_mark_loop_serial_ (jl_ptls_t  ptls , jl_gc_markqueue_t  * mq )  JL_NOTSAFEPOINT 
25172517{
25182518    while  (1 ) {
25192519        void  * new_obj  =  (void  * )gc_ptr_queue_pop (& ptls -> gc_tls .mark_queue );
@@ -2526,7 +2526,7 @@ void gc_mark_loop_serial_(jl_ptls_t ptls, jl_gc_markqueue_t *mq)
25262526}
25272527
25282528// Drain items from worker's own chunkqueue 
2529- void  gc_drain_own_chunkqueue (jl_ptls_t  ptls , jl_gc_markqueue_t  * mq )
2529+ void  gc_drain_own_chunkqueue (jl_ptls_t  ptls , jl_gc_markqueue_t  * mq )  JL_NOTSAFEPOINT 
25302530{
25312531    jl_gc_chunk_t  c  =  {.cid  =  GC_empty_chunk };
25322532    do  {
@@ -2542,13 +2542,13 @@ void gc_drain_own_chunkqueue(jl_ptls_t ptls, jl_gc_markqueue_t *mq)
25422542// is used to keep track of processed items. Maintaining this stack (instead of 
25432543// native one) avoids stack overflow when marking deep objects and 
25442544// makes it easier to implement parallel marking via work-stealing 
2545- JL_EXTENSION  NOINLINE  void  gc_mark_loop_serial (jl_ptls_t  ptls )
2545+ JL_EXTENSION  NOINLINE  void  gc_mark_loop_serial (jl_ptls_t  ptls )  JL_NOTSAFEPOINT 
25462546{
25472547    gc_mark_loop_serial_ (ptls , & ptls -> gc_tls .mark_queue );
25482548    gc_drain_own_chunkqueue (ptls , & ptls -> gc_tls .mark_queue );
25492549}
25502550
2551- void  gc_mark_and_steal (jl_ptls_t  ptls )
2551+ void  gc_mark_and_steal (jl_ptls_t  ptls )  JL_NOTSAFEPOINT 
25522552{
25532553    int  master_tid  =  jl_atomic_load (& gc_master_tid );
25542554    assert (master_tid  !=  -1 );
@@ -2670,7 +2670,7 @@ size_t gc_count_work_in_queue(jl_ptls_t ptls) JL_NOTSAFEPOINT
26702670 * the mark-loop after `gc_n_threads_marking` reaches zero. 
26712671 */ 
26722672
2673- int  gc_should_mark (void )
2673+ int  gc_should_mark (void )  JL_NOTSAFEPOINT 
26742674{
26752675    int  should_mark  =  0 ;
26762676    uv_mutex_lock (& gc_queue_observer_lock );
@@ -2703,14 +2703,14 @@ int gc_should_mark(void)
27032703    return  should_mark ;
27042704}
27052705
2706- void  gc_wake_all_for_marking (jl_ptls_t  ptls )
2706+ void  gc_wake_all_for_marking (jl_ptls_t  ptls )  JL_NOTSAFEPOINT 
27072707{
27082708    uv_mutex_lock (& gc_threads_lock );
27092709    uv_cond_broadcast (& gc_threads_cond );
27102710    uv_mutex_unlock (& gc_threads_lock );
27112711}
27122712
2713- void  gc_mark_loop_parallel (jl_ptls_t  ptls , int  master )
2713+ void  gc_mark_loop_parallel (jl_ptls_t  ptls , int  master )  JL_NOTSAFEPOINT 
27142714{
27152715    if  (master ) {
27162716        jl_atomic_store (& gc_master_tid , ptls -> tid );
@@ -2729,7 +2729,7 @@ void gc_mark_loop_parallel(jl_ptls_t ptls, int master)
27292729    }
27302730}
27312731
2732- void  gc_mark_loop (jl_ptls_t  ptls )
2732+ void  gc_mark_loop (jl_ptls_t  ptls )  JL_NOTSAFEPOINT 
27332733{
27342734    if  (jl_n_markthreads  ==  0  ||  gc_heap_snapshot_enabled ) {
27352735        gc_mark_loop_serial (ptls );
@@ -2739,13 +2739,13 @@ void gc_mark_loop(jl_ptls_t ptls)
27392739    }
27402740}
27412741
2742- void  gc_mark_loop_barrier (void )
2742+ void  gc_mark_loop_barrier (void )  JL_NOTSAFEPOINT 
27432743{
27442744    assert (jl_atomic_load_relaxed (& gc_n_threads_marking ) ==  0 );
27452745    jl_atomic_store_relaxed (& gc_master_tid , -1 );
27462746}
27472747
2748- void  gc_mark_clean_reclaim_sets (void )
2748+ void  gc_mark_clean_reclaim_sets (void )  JL_NOTSAFEPOINT 
27492749{
27502750    // Clean up `reclaim-sets` 
27512751    for  (int  i  =  0 ; i  <  gc_n_threads ; i ++ ) {
@@ -2888,7 +2888,7 @@ static void gc_mark_roots(jl_gc_markqueue_t *mq) JL_NOTSAFEPOINT
28882888
28892889// find unmarked objects that need to be finalized from the finalizer list "list". 
28902890// this must happen last in the mark phase. 
2891- static  void  sweep_finalizer_list (arraylist_t  * list )
2891+ static  void  sweep_finalizer_list (arraylist_t  * list )  JL_NOTSAFEPOINT 
28922892{
28932893    void  * * items  =  list -> items ;
28942894    size_t  len  =  list -> len ;
@@ -2994,7 +2994,7 @@ JL_DLLEXPORT int64_t jl_gc_live_bytes(void)
29942994    return  live_bytes ;
29952995}
29962996
2997- uint64_t  jl_gc_smooth (uint64_t  old_val , uint64_t  new_val , double  factor )
2997+ uint64_t  jl_gc_smooth (uint64_t  old_val , uint64_t  new_val , double  factor )  JL_NOTSAFEPOINT 
29982998{
29992999    double  est  =  factor  *  old_val  +  (1  -  factor ) *  new_val ;
30003000    if  (est  <= 1 )
@@ -3006,7 +3006,7 @@ uint64_t jl_gc_smooth(uint64_t old_val, uint64_t new_val, double factor)
30063006
30073007// an overallocation curve inspired by array allocations 
30083008// grows very fast initially, then much slower at large heaps 
3009- static  uint64_t  overallocation (uint64_t  old_val , uint64_t  val , uint64_t  max_val )
3009+ static  uint64_t  overallocation (uint64_t  old_val , uint64_t  val , uint64_t  max_val )  JL_NOTSAFEPOINT 
30103010{
30113011    // compute maxsize = maxsize + 4*maxsize^(7/8) + maxsize/8 
30123012    // for small n, we grow much faster than O(n) 
@@ -3990,7 +3990,7 @@ JL_DLLEXPORT int jl_gc_enable_conservative_gc_support(void)
39903990    }
39913991}
39923992
3993- JL_DLLEXPORT  int  jl_gc_conservative_gc_support_enabled (void )
3993+ JL_DLLEXPORT  int  jl_gc_conservative_gc_support_enabled (void )  JL_NOTSAFEPOINT 
39943994{
39953995    return  jl_atomic_load (& support_conservative_marking );
39963996}
0 commit comments