diff options
-rw-r--r-- | include/gc/gc.h | 4 | ||||
-rw-r--r-- | mark_rts.c | 27 |
2 files changed, 16 insertions, 15 deletions
diff --git a/include/gc/gc.h b/include/gc/gc.h index d72013b1..cea646e5 100644 --- a/include/gc/gc.h +++ b/include/gc/gc.h @@ -655,13 +655,13 @@ GC_API void GC_CALL GC_clear_exclusion_table(void); GC_API void GC_CALL GC_clear_roots(void); /* Add a root segment. Wizards only. */ +/* May merge adjacent or overlapping segments if appropriate. */ /* Both segment start and end are not needed to be pointer-aligned. */ /* low_address must not be greater than high_address_plus_1. */ GC_API void GC_CALL GC_add_roots(void * /* low_address */, void * /* high_address_plus_1 */); -/* Remove a root segment. Wizards only. */ -/* May be unimplemented on some platforms. */ +/* Remove root segments located fully in the region. Wizards only. */ GC_API void GC_CALL GC_remove_roots(void * /* low_address */, void * /* high_address_plus_1 */); @@ -338,11 +338,10 @@ STATIC void GC_remove_tmp_roots(void) } #endif -#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) - STATIC void GC_remove_roots_inner(ptr_t b, ptr_t e); +STATIC void GC_remove_roots_inner(ptr_t b, ptr_t e); - GC_API void GC_CALL GC_remove_roots(void *b, void *e) - { +GC_API void GC_CALL GC_remove_roots(void *b, void *e) +{ DCL_LOCK_STATE; /* Quick check whether has nothing to do */ @@ -353,27 +352,29 @@ STATIC void GC_remove_tmp_roots(void) LOCK(); GC_remove_roots_inner((ptr_t)b, (ptr_t)e); UNLOCK(); - } +} - /* Should only be called when the lock is held */ - STATIC void GC_remove_roots_inner(ptr_t b, ptr_t e) - { +/* Should only be called when the lock is held */ +STATIC void GC_remove_roots_inner(ptr_t b, ptr_t e) +{ int i; - GC_bool rebuild = FALSE; +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) + int old_n_roots = n_root_sets; +# endif for (i = 0; i < n_root_sets; ) { if ((word)GC_static_roots[i].r_start >= (word)b && (word)GC_static_roots[i].r_end <= (word)e) { GC_remove_root_at_pos(i); - rebuild = TRUE; } else { i++; } } - if (rebuild) +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) + if (n_root_sets < old_n_roots) GC_rebuild_root_index(); - } -#endif /* !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) */ +# endif +} #ifdef USE_PROC_FOR_LIBRARIES /* Exchange the elements of the roots table. Requires rebuild of */ |