File tree Expand file tree Collapse file tree 2 files changed +25
-25
lines changed
Expand file tree Collapse file tree 2 files changed +25
-25
lines changed Original file line number Diff line number Diff line change @@ -601,6 +601,31 @@ JL_DLLEXPORT int jl_gc_enable(int on)
601601 return prev ;
602602}
603603
604+ void jl_gc_wait_for_the_world (jl_ptls_t * gc_all_tls_states , int gc_n_threads )
605+ {
606+ JL_TIMING (GC , GC_Stop );
607+ #ifdef USE_TRACY
608+ TracyCZoneCtx ctx = JL_TIMING_DEFAULT_BLOCK -> tracy_ctx ;
609+ TracyCZoneColor (ctx , 0x696969 );
610+ #endif
611+ assert (gc_n_threads );
612+ if (gc_n_threads > 1 )
613+ jl_wake_libuv ();
614+ for (int i = 0 ; i < gc_n_threads ; i ++ ) {
615+ jl_ptls_t ptls2 = gc_all_tls_states [i ];
616+ if (ptls2 != NULL ) {
617+ // This acquire load pairs with the release stores
618+ // in the signal handler of safepoint so we are sure that
619+ // all the stores on those threads are visible.
620+ // We're currently also using atomic store release in mutator threads
621+ // (in jl_gc_state_set), but we may want to use signals to flush the
622+ // memory operations on those threads lazily instead.
623+ while (!jl_atomic_load_relaxed (& ptls2 -> gc_state ) || !jl_atomic_load_acquire (& ptls2 -> gc_state ))
624+ jl_cpu_pause (); // yield?
625+ }
626+ }
627+ }
628+
604629JL_DLLEXPORT int jl_gc_is_enabled (void )
605630{
606631 jl_ptls_t ptls = jl_current_task -> ptls ;
Original file line number Diff line number Diff line change @@ -344,31 +344,6 @@ NOINLINE uintptr_t gc_get_stack_ptr(void)
344344
345345#define should_timeout () 0
346346
347- void jl_gc_wait_for_the_world (jl_ptls_t * gc_all_tls_states , int gc_n_threads )
348- {
349- JL_TIMING (GC , GC_Stop );
350- #ifdef USE_TRACY
351- TracyCZoneCtx ctx = JL_TIMING_DEFAULT_BLOCK -> tracy_ctx ;
352- TracyCZoneColor (ctx , 0x696969 );
353- #endif
354- assert (gc_n_threads );
355- if (gc_n_threads > 1 )
356- jl_wake_libuv ();
357- for (int i = 0 ; i < gc_n_threads ; i ++ ) {
358- jl_ptls_t ptls2 = gc_all_tls_states [i ];
359- if (ptls2 != NULL ) {
360- // This acquire load pairs with the release stores
361- // in the signal handler of safepoint so we are sure that
362- // all the stores on those threads are visible.
363- // We're currently also using atomic store release in mutator threads
364- // (in jl_gc_state_set), but we may want to use signals to flush the
365- // memory operations on those threads lazily instead.
366- while (!jl_atomic_load_relaxed (& ptls2 -> gc_state ) || !jl_atomic_load_acquire (& ptls2 -> gc_state ))
367- jl_cpu_pause (); // yield?
368- }
369- }
370- }
371-
372347// malloc wrappers, aligned allocation
373348
374349#if defined(_OS_WINDOWS_ )
You can’t perform that action at this time.
0 commit comments