From 802e47d5e8dcbddd2e80cd4587eacc5f4ffbc745 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 19 Jul 2020 10:15:42 +0300 Subject: Move GC state pointer variables into GC_arrays This commit is intended to simplify GC reinitialization. GC_push_finalizer_structures() and GC_push_typed_structures() are called now regardless of GC_no_dls and GC_roots_were_cleared values. * finalize.c (dl_hashtbl_s, fnlz_roots_s): Move struct to gc_priv.h. * typd_mlc.c (typed_ext_descr_t): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_dl_hashtbl, GC_fnlz_roots): Remove static variable. * finalize.c [!GC_NO_FINALIZATION && !GC_LONG_REFS_NOT_NEEDED] (GC_ll_hashtbl): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_toggleref_arr): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcjobjfreelist): Likewise. * headers.c (GC_all_bottom_indices, GC_all_bottom_indices_end, GC_scratch_free_ptr, GC_hdr_free_list): Likewise. * mark.c (GC_scan_ptr): Likewise. * mark.c [PARALLEL_MARK] (GC_main_local_mark_stack): Likewise. * typd_mlc.c (GC_ext_descriptors): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GCToggleRef): Define type as an alias to union toggle_ref_u. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_mark_togglerefs): Remove TODO item. * include/private/gc_priv.h (disappearing_link, finalizable_object): Declare struct. * include/private/gc_priv.h (GC_arrays): Add _all_bottom_indices, _all_bottom_indices_end, _scratch_free_ptr, _hdr_free_list, _scan_ptr, _ext_descriptors fields. * include/private/gc_priv.h [PARALLEL_MARK] (GC_arrays): Add _main_local_mark_stack field. * include/private/gc_priv.h [GC_GCJ_SUPPORT] (GC_arrays): Add _gcjobjfreelist field. * include/private/gc_priv.h [!GC_NO_FINALIZATION && GC_LONG_REFS_NOT_NEEDED] (GC_arrays): Add _ll_hashtbl field. * include/private/gc_priv.h [!GC_NO_FINALIZATION] (GC_arrays): Add _dl_hashtbl, _fnlz_roots fields. * include/private/gc_priv.h [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_arrays): Add _toggleref_arr field. * include/private/gc_priv.h (GC_arrays._roots_were_cleared): Define field only if THREADS. * mark_rts.c (GC_clear_roots): Set GC_roots_were_cleared only if THREADS. * mark_rts.c (GC_push_gc_structures): Remove static function. * mark_rts.c (GC_push_roots): Do not call GC_push_gc_structures. * mark_rts.c [!GC_NO_FINALIZATION] (GC_push_roots): Call GC_push_finalizer_structures (regardless of GC_no_dls and GC_roots_were_cleared). * mark_rts.c [THREADS] (GC_push_roots): If GC_no_dls or GC_roots_were_cleared then call GC_push_thread_structures. * mark_rts.c (GC_push_roots): If GC_push_typed_structures is non-null then call GC_push_typed_structures (regardless of GC_no_dls and GC_roots_were_cleared). --- mark_rts.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'mark_rts.c') diff --git a/mark_rts.c b/mark_rts.c index e88f8a72..6a576681 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -274,7 +274,9 @@ GC_API void GC_CALL GC_clear_roots(void) if (!EXPECT(GC_is_initialized, TRUE)) GC_init(); LOCK(); - GC_roots_were_cleared = TRUE; +# ifdef THREADS + GC_roots_were_cleared = TRUE; +# endif n_root_sets = 0; GC_root_size = 0; # if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) @@ -833,27 +835,6 @@ STATIC void GC_push_current_stack(ptr_t cold_gc_frame, GC_INNER void (*GC_push_typed_structures)(void) = 0; - /* Push GC internal roots. These are normally */ - /* included in the static data segment, and */ - /* Thus implicitly pushed. But we must do this */ - /* explicitly if normal root processing is */ - /* disabled. */ -/* - * Push GC internal roots. Only called if there is some reason to believe - * these would not otherwise get registered. - */ -STATIC void GC_push_gc_structures(void) -{ -# ifndef GC_NO_FINALIZATION - GC_push_finalizer_structures(); -# endif -# if defined(THREADS) - GC_push_thread_structures(); -# endif - if( GC_push_typed_structures ) - GC_push_typed_structures(); -} - GC_INNER void GC_cond_register_dynamic_libraries(void) { # if (defined(DYNAMIC_LOADING) && !defined(MSWIN_XBOX1)) \ @@ -919,9 +900,15 @@ GC_INNER void GC_push_roots(GC_bool all, ptr_t cold_gc_frame GC_ATTR_UNUSED) /* Mark from GC internal roots if those might otherwise have */ /* been excluded. */ - if (GC_no_dls || GC_roots_were_cleared) { - GC_push_gc_structures(); - } +# ifndef GC_NO_FINALIZATION + GC_push_finalizer_structures(); +# endif +# ifdef THREADS + if (GC_no_dls || GC_roots_were_cleared) + GC_push_thread_structures(); +# endif + if (GC_push_typed_structures) + GC_push_typed_structures(); /* Mark thread local free lists, even if their mark */ /* descriptor excludes the link field. */ -- cgit v1.2.1