Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Unity-Technologies/bdwgc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Peterson <joshuap@unity3d.com>2019-11-25 23:30:48 +0300
committerGitHub <noreply@github.com>2019-11-25 23:30:48 +0300
commit262b828243c203cc41b6408e21ba35056ce35466 (patch)
tree8de402e432ee20e2d793f8067ffeca6c1d4df4a0
parent35a51fcbf1e64457e46f9655cec7ccc586a13135 (diff)
parent81f0b5a699f9a1e1e55b5c925cd256c3dcf369cf (diff)
Merge pull request #48 from Unity-Technologies/unload-reload-tests
Allow BDWGC to uninitialize and re-initialize
-rw-r--r--allchblk.c6
-rw-r--r--finalize.c7
-rw-r--r--headers.c17
-rw-r--r--include/gc.h3
-rw-r--r--mark.c11
-rw-r--r--mark_rts.c5
-rw-r--r--misc.c12
-rw-r--r--os_dep.c9
8 files changed, 66 insertions, 4 deletions
diff --git a/allchblk.c b/allchblk.c
index 7dfa6c59..4684ca9f 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -64,6 +64,12 @@
word GC_free_bytes[N_HBLK_FLS+1] = { 0 };
/* Number of free bytes on each list. Remains visible to GCJ. */
+void GC_clear_freelist(void)
+{
+ memset(GC_hblkfreelist, 0, sizeof(GC_hblkfreelist));
+ memset(GC_free_bytes, 0, sizeof(GC_free_bytes));
+}
+
/* Return the largest n such that the number of free bytes on lists */
/* n .. N_HBLK_FLS is greater or equal to GC_max_large_allocd_bytes */
/* minus GC_large_allocd_bytes. If there is no such n, return 0. */
diff --git a/finalize.c b/finalize.c
index 9248a23e..8790a5b9 100644
--- a/finalize.c
+++ b/finalize.c
@@ -78,6 +78,13 @@ STATIC struct fnlz_roots_s {
struct finalizable_object *finalize_now;
} GC_fnlz_roots = { NULL, NULL };
+void GC_clear_finalizable_object_table()
+{
+ log_fo_table_size = -1;
+ GC_fnlz_roots.fo_head = NULL;
+ GC_fnlz_roots.finalize_now = NULL;
+}
+
#ifdef AO_HAVE_store
/* Update finalize_now atomically as GC_should_invoke_finalizers does */
/* not acquire the allocation lock. */
diff --git a/headers.c b/headers.c
index d2c283c5..9d967839 100644
--- a/headers.c
+++ b/headers.c
@@ -32,6 +32,12 @@ STATIC bottom_index * GC_all_bottom_indices_end = 0;
/* Pointer to the last (highest address) */
/* bottom_index. Assumes the lock is held. */
+void GC_clear_bottom_indices()
+{
+ GC_all_bottom_indices = 0;
+ GC_all_bottom_indices_end = 0;
+}
+
/* Non-macro version of header location routine */
GC_INNER hdr * GC_find_header(ptr_t h)
{
@@ -194,10 +200,13 @@ GC_INNER void GC_init_headers(void)
{
unsigned i;
- GC_all_nils = (bottom_index *)GC_scratch_alloc(sizeof(bottom_index));
- if (GC_all_nils == NULL) {
- GC_err_printf("Insufficient memory for GC_all_nils\n");
- EXIT();
+ if (GC_all_nils == NULL)
+ {
+ GC_all_nils = (bottom_index *)GC_scratch_alloc(sizeof(bottom_index));
+ if (GC_all_nils == NULL) {
+ GC_err_printf("Insufficient memory for GC_all_nils\n");
+ EXIT();
+ }
}
BZERO(GC_all_nils, sizeof(bottom_index));
for (i = 0; i < TOP_SZ; i++) {
diff --git a/include/gc.h b/include/gc.h
index 13c7c2a9..3540b13f 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -598,6 +598,9 @@ GC_API void GC_CALL GC_set_max_heap_size(GC_word /* n */);
GC_API void GC_CALL GC_exclude_static_roots(void * /* low_address */,
void * /* high_address_plus_1 */);
+/* Clear the number of entries in the exclustion table. Wizards only. */
+GC_API void GC_CALL GC_clear_exclusion_table(void);
+
/* Clear the set of root segments. Wizards only. */
GC_API void GC_CALL GC_clear_roots(void);
diff --git a/mark.c b/mark.c
index 06f95ab3..06a1a53e 100644
--- a/mark.c
+++ b/mark.c
@@ -122,6 +122,17 @@ static struct hblk * scan_ptr;
STATIC GC_bool GC_objects_are_marked = FALSE;
/* Are there collectible marked objects in the heap? */
+void GC_reset_mark_statics()
+{
+ GC_n_mark_procs = GC_RESERVED_MARK_PROCS;
+ GC_n_kinds = GC_N_KINDS_INITIAL_VALUE;
+ GC_mark_stack_size = 0;
+ GC_mark_state = MS_NONE;
+ GC_mark_stack_too_small = FALSE;
+ scan_ptr = NULL;
+ GC_objects_are_marked = FALSE;
+}
+
/* Is a collection in progress? Note that this can return true in the */
/* nonincremental case, if a collection has been abandoned and the */
/* mark state is now MS_INVALID. */
diff --git a/mark_rts.c b/mark_rts.c
index 0e610aa0..20d9996e 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -512,6 +512,11 @@ struct exclusion GC_excl_table[MAX_EXCLUSIONS];
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;
+}
+
/* Return the first exclusion range that includes an address >= start_addr */
/* Assumes the exclusion table contains at least one entry (namely the */
/* GC data structures). */
diff --git a/misc.c b/misc.c
index dc2fbe81..1bd3e7f9 100644
--- a/misc.c
+++ b/misc.c
@@ -1419,6 +1419,8 @@ GC_API void GC_CALL GC_enable_incremental(void)
}
#endif
+ extern void GC_reset_default_push_other_roots(void);
+
GC_API void GC_CALL GC_deinit(void)
{
if (GC_is_initialized) {
@@ -1428,6 +1430,16 @@ GC_API void GC_CALL GC_enable_incremental(void)
DeleteCriticalSection(&GC_write_cs);
DeleteCriticalSection(&GC_allocate_ml);
# endif
+ GC_clear_exclusion_table();
+ memset(&GC_arrays, 0, sizeof(GC_arrays));
+# if (defined(MSWIN32) || defined(MSWINCE)) && !defined(MSWIN_XBOX1)
+ GC_win32_free_heap();
+# endif
+ GC_clear_freelist();
+ GC_clear_bottom_indices();
+ GC_clear_finalizable_object_table();
+ GC_reset_mark_statics();
+ GC_reset_default_push_other_roots();
}
}
diff --git a/os_dep.c b/os_dep.c
index 7bee84c1..0158990b 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -2789,6 +2789,15 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
return GC_push_other_roots;
}
+void GC_reset_default_push_other_roots(void)
+{
+#ifdef THREADS
+ GC_push_other_roots = GC_default_push_other_roots;
+#else
+ GC_push_other_roots = 0;
+#endif
+}
+
/*
* Routines for accessing dirty bits on virtual pages.
* There are six ways to maintain this information: