diff options
author | Joshua Peterson <joshuap@unity3d.com> | 2019-11-25 23:30:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-25 23:30:48 +0300 |
commit | 262b828243c203cc41b6408e21ba35056ce35466 (patch) | |
tree | 8de402e432ee20e2d793f8067ffeca6c1d4df4a0 | |
parent | 35a51fcbf1e64457e46f9655cec7ccc586a13135 (diff) | |
parent | 81f0b5a699f9a1e1e55b5c925cd256c3dcf369cf (diff) |
Merge pull request #48 from Unity-Technologies/unload-reload-tests
Allow BDWGC to uninitialize and re-initialize
-rw-r--r-- | allchblk.c | 6 | ||||
-rw-r--r-- | finalize.c | 7 | ||||
-rw-r--r-- | headers.c | 17 | ||||
-rw-r--r-- | include/gc.h | 3 | ||||
-rw-r--r-- | mark.c | 11 | ||||
-rw-r--r-- | mark_rts.c | 5 | ||||
-rw-r--r-- | misc.c | 12 | ||||
-rw-r--r-- | os_dep.c | 9 |
8 files changed, 66 insertions, 4 deletions
@@ -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. */ @@ -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. */ @@ -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); @@ -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. */ @@ -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). */ @@ -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(); } } @@ -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: |