From 5b60a26d2b01e1e00c3d32cd9875d1d342c77774 Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Thu, 30 Sep 1999 05:15:24 +0000 Subject: [PATCH] added GC_remove_roots() git-svn-id: svn://10.0.0.236/trunk@49404 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gc/boehm/mark_rts.c | 38 ++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/mozilla/gc/boehm/mark_rts.c b/mozilla/gc/boehm/mark_rts.c index 2f21ed324dd..6ec43b33cc9 100644 --- a/mozilla/gc/boehm/mark_rts.c +++ b/mozilla/gc/boehm/mark_rts.c @@ -160,7 +160,6 @@ char * b; char * e; ENABLE_SIGNALS(); } - /* Add [b,e) to the root set. Adding the same interval a second time */ /* is a moderately fast noop, and hence benign. We do not handle */ /* different but overlapping intervals efficiently. (We do handle */ @@ -250,6 +249,43 @@ GC_bool tmp; n_root_sets++; } +void GC_remove_roots(b, e) +char * b; char * e; +{ + DCL_LOCK_STATE; + + DISABLE_SIGNALS(); + LOCK(); + GC_remove_roots_inner(b, e); + UNLOCK(); + ENABLE_SIGNALS(); +} + +void GC_remove_roots_inner(b, e) +char * b; char * e; +{ + register int i; + + for (i = 0; i < n_root_sets; ) { + if (GC_static_roots[i].r_start == (ptr_t)b && GC_static_roots[i].r_end == (ptr_t)e) { + GC_root_size -= + (GC_static_roots[i].r_end - GC_static_roots[i].r_start); + GC_static_roots[i].r_start = GC_static_roots[n_root_sets-1].r_start; + GC_static_roots[i].r_end = GC_static_roots[n_root_sets-1].r_end; + GC_static_roots[i].r_tmp = GC_static_roots[n_root_sets-1].r_tmp; + n_root_sets--; + } else { + i++; + } + } +# ifndef MSWIN32 + /* rehash the root table. */ + for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0; + for (i = 0; i < n_root_sets; i++) + add_roots_to_index(GC_static_roots + i); +# endif +} + void GC_clear_roots GC_PROTO((void)) { DCL_LOCK_STATE;