summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2020-07-10 14:11:18 +0300
committerIvan Maidanski <ivmai@mail.ru>2020-07-10 14:11:18 +0300
commit6ec159286f3f604c0b5fd394b0b94e49795d91c0 (patch)
treeb5d8844dfa7e9e0f30f596bb4a8a30e6be19337b
parent8e7f53e423b8048764ddaf8b02f941041b049ae1 (diff)
downloadbdwgc-6ec159286f3f604c0b5fd394b0b94e49795d91c0.tar.gz
Move GC state non-pointer variables into GC_arrays
(code refactoring) This commit is intended to simplify GC reinitialization. * alloc.c (GC_n_heap_sects, GC_fo_entries): Remove variable definition. * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_n_memory): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_log_fo_table_size): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_toggleref_array_size, GC_toggleref_array_capacity): Likewise. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_kind): Likewise. * mark.c (GC_mark_stack_size, GC_mark_state, GC_mark_stack_too_small, GC_objects_are_marked): Likewise. * mark.c [PARALLEL_MARK] (GC_first_nonempty): Likewise. * mark.c [TRACE_BUF] (GC_trace_buf_ptr): Likewise. * mark_rts.c (n_root_sets, GC_roots_were_cleared, GC_excl_table_entries): Likewise. * os_dep.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_n_heap_bases): Likewise. * typd_mlc.c (GC_ed_size, GC_avail_descr, GC_explicit_typing_initialized): Likewise. * extra/MacOS.c (GC_fo_entries): Remove variable declaration. * include/private/gc_pmark.h (GC_mark_stack_size, GC_mark_stack_too_small, GC_mark_state): Likewise. * include/private/gc_priv.h (GC_n_heap_sects, GC_fo_entries): Likewise. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (GC_n_memory): Likewise. * include/private/gc_pmark.h (mark_state_t): Move typedef to gc_priv.h. * include/private/gc_priv.h (_GC_arrays._scratch_end_ptr, _GC_arrays._scratch_last_end_ptr): Document. * include/private/gc_priv.h [PARALLEL_MARK] (_GC_arrays): Add _first_nonempty field. * include/private/gc_priv.h (_GC_arrays): Add _mark_stack_size, _mark_state, _mark_stack_too_small, _objects_are_marked, _n_heap_sects, _n_memory, _fo_entries, _n_root_sets, _excl_table_entries, _roots_were_cleared, _explicit_typing_initialized, _ed_size, _avail_descr fields. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (_GC_arrays): Add _n_memory field. * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32] (_GC_arrays): Add _n_heap_bases field. * include/private/gc_priv.h [!GC_NO_FINALIZATION] (_GC_arrays): Add _log_fo_table_size field. * include/private/gc_priv.h [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (_GC_arrays): Add _toggleref_array_size, _toggleref_array_capacity fields. * include/private/gc_priv.h [TRACE_BUF] (_GC_arrays): Add _trace_buf_ptr field. * include/private/gc_priv.h [ENABLE_DISCLAIM] (_GC_arrays): Add _finalized_kind field. * include/private/gc_priv.h (GC_first_nonempty, GC_mark_stack_size, GC_mark_state, GC_mark_stack_too_small, GC_objects_are_marked, GC_n_heap_sects, GC_n_memory, GC_n_heap_bases, GC_fo_entries, GC_log_fo_table_size, GC_toggleref_array_size, GC_toggleref_array_capacity, GC_trace_buf_ptr, GC_finalized_kind, n_root_sets, GC_excl_table_entries, GC_roots_were_cleared, GC_explicit_typing_initialized, GC_ed_size, GC_avail_descr): Define macro.
-rw-r--r--alloc.c10
-rw-r--r--extra/MacOS.c2
-rw-r--r--finalize.c4
-rw-r--r--fnlz_mlc.c2
-rw-r--r--include/private/gc_pmark.h12
-rw-r--r--include/private/gc_priv.h83
-rw-r--r--mark.c17
-rw-r--r--mark_rts.c7
-rw-r--r--os_dep.c2
-rw-r--r--typd_mlc.c9
10 files changed, 72 insertions, 76 deletions
diff --git a/alloc.c b/alloc.c
index 99eb9be3..8a2a07d9 100644
--- a/alloc.c
+++ b/alloc.c
@@ -1280,14 +1280,6 @@ GC_API void GC_CALL GC_gcollect_and_unmap(void)
(void)GC_try_to_collect_general(GC_never_stop_func, TRUE);
}
-GC_INNER word GC_n_heap_sects = 0;
- /* Number of sections currently in heap. */
-
-#ifdef USE_PROC_FOR_LIBRARIES
- GC_INNER word GC_n_memory = 0;
- /* Number of GET_MEM allocated memory sections. */
-#endif
-
#ifdef USE_PROC_FOR_LIBRARIES
/* Add HBLKSIZE aligned, GET_MEM-generated block to GC_our_memory. */
/* Defined to do nothing if USE_PROC_FOR_LIBRARIES not set. */
@@ -1494,8 +1486,6 @@ GC_API int GC_CALL GC_expand_hp(size_t bytes)
return(result);
}
-word GC_fo_entries = 0; /* used also in extra/MacOS.c */
-
GC_INNER unsigned GC_fail_count = 0;
/* How many consecutive GC/expansion failures? */
/* Reset by GC_allochblk. */
diff --git a/extra/MacOS.c b/extra/MacOS.c
index 363b40ec..86557a90 100644
--- a/extra/MacOS.c
+++ b/extra/MacOS.c
@@ -95,8 +95,6 @@ Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory)
return tempPtr;
}
-extern word GC_fo_entries;
-
static void perform_final_collection(void)
{
unsigned i;
diff --git a/finalize.c b/finalize.c
index 4bab8908..ee6c793d 100644
--- a/finalize.c
+++ b/finalize.c
@@ -70,8 +70,6 @@ struct finalizable_object {
finalization_mark_proc fo_mark_proc; /* Mark-through procedure */
};
-STATIC unsigned GC_log_fo_table_size = 0;
-
STATIC struct fnlz_roots_s {
struct finalizable_object **fo_head;
/* List of objects that should be finalized now: */
@@ -316,8 +314,6 @@ GC_API int GC_CALL GC_unregister_disappearing_link(void * * link)
STATIC GC_toggleref_func GC_toggleref_callback = 0;
STATIC GCToggleRef *GC_toggleref_arr = NULL;
- STATIC size_t GC_toggleref_array_size = 0;
- STATIC size_t GC_toggleref_array_capacity = 0;
GC_INNER void GC_process_togglerefs(void)
{
diff --git a/fnlz_mlc.c b/fnlz_mlc.c
index 283566ee..2c213bc0 100644
--- a/fnlz_mlc.c
+++ b/fnlz_mlc.c
@@ -20,8 +20,6 @@
#include "gc_inline.h" /* for GC_malloc_kind */
#include "private/dbg_mlc.h" /* for oh type */
-STATIC int GC_finalized_kind = 0;
-
#if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH)
/* The first bit is already used for a debug purpose. */
# define FINALIZER_CLOSURE_FLAG 0x2
diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h
index 47827d8f..094a9ec1 100644
--- a/include/private/gc_pmark.h
+++ b/include/private/gc_pmark.h
@@ -74,8 +74,6 @@ GC_EXTERN unsigned GC_n_mark_procs;
/* Number of mark stack entries to discard on overflow. */
#define GC_MARK_STACK_DISCARDS (INITIAL_MARK_STACK_SIZE/8)
-GC_EXTERN size_t GC_mark_stack_size;
-
#ifdef PARALLEL_MARK
/*
* Allow multiple threads to participate in the marking process.
@@ -442,14 +440,6 @@ GC_INNER mse * GC_mark_from(mse * top, mse * bottom, mse *limit);
} \
} while (0)
-GC_EXTERN GC_bool GC_mark_stack_too_small;
- /* We need a larger mark stack. May be */
- /* set by client supplied mark routines.*/
-
-typedef int mark_state_t; /* Current state of marking, as follows:*/
- /* Used to remember where we are during */
- /* concurrent marking. */
-
/* We say something is dirty if it was */
/* written since the last time we */
/* retrieved dirty bits. We say it's */
@@ -487,8 +477,6 @@ typedef int mark_state_t; /* Current state of marking, as follows:*/
#define MS_INVALID 5 /* "I" may not hold. */
-GC_EXTERN mark_state_t GC_mark_state;
-
EXTERN_C_END
#endif /* GC_PMARK_H */
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 05230581..6a9528fe 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -1284,6 +1284,10 @@ typedef struct GC_ms_entry {
/* as described in gc_mark.h. */
} mse;
+typedef int mark_state_t; /* Current state of marking, as follows: */
+ /* Used to remember where we are during */
+ /* concurrent marking. */
+
/* Lists of all heap blocks and free lists */
/* as well as other random data structures */
/* that should not be scanned by the */
@@ -1345,7 +1349,10 @@ struct _GC_arrays {
/* finalizers were running. Used to approximate memory */
/* explicitly deallocated by finalizers. */
ptr_t _scratch_end_ptr;
+ /* GC_scratch_end_ptr is end point of the current scratch area. */
ptr_t _scratch_last_end_ptr;
+ /* GC_scratch_last_end_ptr is the end point of the last */
+ /* obtained scratch area. */
/* Used by headers.c, and can easily appear to point to */
/* heap. Also used by GC_register_dynamic_libraries(). */
mse *_mark_stack;
@@ -1371,10 +1378,74 @@ struct _GC_arrays {
# define GC_unmapped_bytes 0
# endif
bottom_index * _all_nils;
+# ifdef PARALLEL_MARK
+# define GC_first_nonempty GC_arrays._first_nonempty
+ volatile AO_t _first_nonempty;
+ /* Lowest entry on mark stack that may be */
+ /* nonempty. Updated only by initiating thread. */
+# endif
+# define GC_mark_stack_size GC_arrays._mark_stack_size
+ size_t _mark_stack_size;
+# define GC_mark_state GC_arrays._mark_state
+ mark_state_t _mark_state; /* Initialized to MS_NONE (0). */
+# define GC_mark_stack_too_small GC_arrays._mark_stack_too_small
+ GC_bool _mark_stack_too_small;
+ /* We need a larger mark stack. May be set by */
+ /* client supplied mark routines. */
+# define GC_objects_are_marked GC_arrays._objects_are_marked
+ GC_bool _objects_are_marked;
+ /* Are there collectible marked objects in the heap? */
# ifdef ENABLE_TRACE
# define GC_trace_addr GC_arrays._trace_addr
ptr_t _trace_addr;
# endif
+# define GC_n_heap_sects GC_arrays._n_heap_sects
+ word _n_heap_sects; /* Number of separately added heap sections. */
+# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
+# define GC_n_heap_bases GC_arrays._n_heap_bases
+ word _n_heap_bases; /* See GC_heap_bases. */
+# endif
+# ifdef USE_PROC_FOR_LIBRARIES
+# define GC_n_memory GC_arrays._n_memory
+ word _n_memory; /* Number of GET_MEM allocated memory sections. */
+# endif
+# define GC_fo_entries GC_arrays._fo_entries
+ word _fo_entries;
+# ifndef GC_NO_FINALIZATION
+# define GC_log_fo_table_size GC_arrays._log_fo_table_size
+ unsigned _log_fo_table_size;
+# ifndef GC_TOGGLE_REFS_NOT_NEEDED
+# define GC_toggleref_array_size GC_arrays._toggleref_array_size
+# define GC_toggleref_array_capacity GC_arrays._toggleref_array_capacity
+ size_t _toggleref_array_size;
+ size_t _toggleref_array_capacity;
+# endif
+# endif
+# ifdef TRACE_BUF
+# define GC_trace_buf_ptr GC_arrays._trace_buf_ptr
+ int _trace_buf_ptr;
+# endif
+# ifdef ENABLE_DISCLAIM
+# define GC_finalized_kind GC_arrays._finalized_kind
+ int _finalized_kind;
+# endif
+# define n_root_sets GC_arrays._n_root_sets
+# define GC_excl_table_entries GC_arrays._excl_table_entries
+# define GC_roots_were_cleared GC_arrays._roots_were_cleared
+ int _n_root_sets; /* GC_static_roots[0..n_root_sets) contains the */
+ /* valid root sets. */
+ size_t _excl_table_entries; /* Number of entries in use. */
+ GC_bool _roots_were_cleared;
+# define GC_explicit_typing_initialized GC_arrays._explicit_typing_initialized
+# define GC_ed_size GC_arrays._ed_size
+# define GC_avail_descr GC_arrays._avail_descr
+# ifdef AO_HAVE_load_acquire
+ volatile AO_t _explicit_typing_initialized;
+# else
+ GC_bool _explicit_typing_initialized;
+# endif
+ size_t _ed_size; /* Current size of above arrays. */
+ size_t _avail_descr; /* Next available slot. */
GC_mark_proc _mark_procs[MAX_MARK_PROCS];
/* Table of user-defined mark procedures. There is */
/* a small number of these, which can be referenced */
@@ -1583,14 +1654,6 @@ GC_EXTERN struct obj_kind {
GC_EXTERN unsigned GC_n_kinds;
-GC_EXTERN word GC_n_heap_sects; /* Number of separately added heap */
- /* sections. */
-
-#ifdef USE_PROC_FOR_LIBRARIES
- GC_EXTERN word GC_n_memory; /* Number of GET_MEM allocated memory */
- /* sections. */
-#endif
-
GC_EXTERN size_t GC_page_size;
/* Round up allocation size to a multiple of a page size. */
@@ -1976,7 +2039,7 @@ GC_INNER void GC_freehblk(struct hblk * p);
/* Deallocate a heap block and mark it */
/* as invalid. */
-/* Misc GC: */
+/* Miscellaneous GC routines. */
GC_INNER GC_bool GC_expand_hp_inner(word n);
GC_INNER void GC_start_reclaim(GC_bool abort_if_found);
/* Restore unmarked objects to free */
@@ -2281,8 +2344,6 @@ void GC_print_hblkfreelist(void);
void GC_print_heap_sects(void);
void GC_print_static_roots(void);
-extern word GC_fo_entries; /* should be visible in extra/MacOS.c */
-
#ifdef KEEP_BACK_PTRS
GC_INNER void GC_store_back_pointer(ptr_t source, ptr_t dest);
GC_INNER void GC_marked_for_finalization(ptr_t dest);
diff --git a/mark.c b/mark.c
index f27d7c7f..84527221 100644
--- a/mark.c
+++ b/mark.c
@@ -97,27 +97,12 @@ GC_INNER struct obj_kind GC_obj_kinds[MAXOBJKINDS] = {
/* Used for logging only. */
#endif
-GC_INNER size_t GC_mark_stack_size = 0;
-
#ifdef PARALLEL_MARK
- STATIC volatile AO_t GC_first_nonempty = 0;
- /* Lowest entry on mark stack */
- /* that may be nonempty. */
- /* Updated only by initiating */
- /* thread. */
-
GC_INNER GC_bool GC_parallel_mark_disabled = FALSE;
#endif
-GC_INNER mark_state_t GC_mark_state = MS_NONE;
-
-GC_INNER GC_bool GC_mark_stack_too_small = FALSE;
-
STATIC struct hblk * GC_scan_ptr;
-STATIC GC_bool GC_objects_are_marked = FALSE;
- /* Are there collectible marked objects in the heap? */
-
/* Is a collection in progress? Note that this can return true in the */
/* non-incremental case, if a collection has been abandoned and the */
/* mark state is now MS_INVALID. */
@@ -1522,8 +1507,6 @@ struct trace_entry {
word arg2;
} GC_trace_buf[TRACE_ENTRIES] = { { NULL, 0, 0, 0, 0 } };
-int GC_trace_buf_ptr = 0;
-
void GC_add_trace_entry(char *kind, word arg1, word arg2)
{
GC_trace_buf[GC_trace_buf_ptr].kind = kind;
diff --git a/mark_rts.c b/mark_rts.c
index 8b190014..e88f8a72 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -36,9 +36,6 @@ struct roots GC_static_roots[MAX_ROOT_SETS];
int GC_no_dls = 0; /* Register dynamic library data segments. */
-static int n_root_sets = 0;
- /* GC_static_roots[0..n_root_sets) contains the valid root sets. */
-
#if !defined(NO_DEBUGGING) || defined(GC_ASSERTIONS)
/* Should return the same value as GC_root_size. */
GC_INNER word GC_compute_root_size(void)
@@ -271,8 +268,6 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp)
n_root_sets++;
}
-STATIC GC_bool GC_roots_were_cleared = FALSE;
-
GC_API void GC_CALL GC_clear_roots(void)
{
DCL_LOCK_STATE;
@@ -532,8 +527,6 @@ struct exclusion GC_excl_table[MAX_EXCLUSIONS];
-- address order.
*/
-STATIC size_t GC_excl_table_entries = 0;/* Number of entries in use. */
-
GC_API void GC_CALL GC_clear_exclusion_table(void)
{
GC_excl_table_entries = 0;
diff --git a/os_dep.c b/os_dep.c
index a74155e0..9b644261 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -1879,8 +1879,6 @@ void GC_register_data_segments(void)
}
# endif /* USE_WINALLOC && !REDIRECT_MALLOC */
- STATIC word GC_n_heap_bases = 0; /* See GC_heap_bases. */
-
/* Is p the start of either the malloc heap, or of one of our */
/* heap sections? */
GC_INNER GC_bool GC_is_heap_base(void *p)
diff --git a/typd_mlc.c b/typd_mlc.c
index f43e3fe3..cf50ab19 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -98,20 +98,11 @@ STATIC typed_ext_descr_t * GC_ext_descriptors = NULL;
/* Points to array of extended */
/* descriptors. */
-STATIC size_t GC_ed_size = 0; /* Current size of above arrays. */
#define ED_INITIAL_SIZE 100
-STATIC size_t GC_avail_descr = 0; /* Next available slot. */
-
STATIC int GC_typed_mark_proc_index = 0; /* Indices of my mark */
STATIC int GC_array_mark_proc_index = 0; /* procedures. */
-#ifdef AO_HAVE_load_acquire
- STATIC volatile AO_t GC_explicit_typing_initialized = FALSE;
-#else
- STATIC GC_bool GC_explicit_typing_initialized = FALSE;
-#endif
-
STATIC void GC_push_typed_structures_proc(void)
{
GC_PUSH_ALL_SYM(GC_ext_descriptors);