From 6eb24292d4cd371013c15e31e8d827bb38672acf Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 20 Apr 2012 09:12:47 +0400 Subject: [PATCH] Code refactoring of GC_check_tls_for/GC_check_fl_marks (Apply commit e67ab08 from 'master' branch) * alloc.c (GC_check_fl_marks): Change prototype (pass pointer to "freelist" element instead of value); do not define the function if THREAD_LOCAL_ALLOC undefined. * include/private/gc_priv.h (GC_check_fl_marks): Likewise. * alloc.c (GC_check_fl_marks): Skip check if the argument points to a special (non-pointer) value; update comment; rename "q" local variable to "list". * thread_local_alloc.c (GC_check_tls_for): Update code according to GC_check_fl_marks functionality change (remove checks for special value). --- alloc.c | 22 +++++++++++++--------- include/private/gc_priv.h | 4 ++-- thread_local_alloc.c | 12 ++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/alloc.c b/alloc.c index a41cb1db..7b52656c 100644 --- a/alloc.c +++ b/alloc.c @@ -716,20 +716,24 @@ GC_INNER void GC_set_fl_marks(ptr_t q) } } -#ifdef GC_ASSERTIONS - /* Check that all mark bits for the free list whose first entry is q */ - /* are set. */ - void GC_check_fl_marks(ptr_t q) +#if defined(GC_ASSERTIONS) && defined(THREADS) && defined(THREAD_LOCAL_ALLOC) + /* Check that all mark bits for the free list whose first entry is */ + /* (*pfreelist) are set. Check skipped if points to a special value. */ + void GC_check_fl_marks(void **pfreelist) { - ptr_t p; - for (p = q; p != 0; p = obj_link(p)) { + ptr_t list = *pfreelist; + ptr_t p; + + if ((word)list <= HBLKSIZE) return; + + for (p = list; p != 0; p = obj_link(p)) { if (!GC_is_marked(p)) { - GC_err_printf("Unmarked object %p on list %p\n", p, q); + GC_err_printf("Unmarked object %p on list %p\n", p, list); ABORT("Unmarked local free list entry"); } - } + } } -#endif +#endif /* GC_ASSERTIONS && THREAD_LOCAL_ALLOC */ /* Clear all mark bits for the free list whose first entry is q */ /* Decrement GC_bytes_found by number of bytes on free list. */ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 43e7f26e..8eefb70e 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1508,8 +1508,8 @@ GC_INNER void GC_set_hdr_marks(hdr * hhdr); GC_INNER void GC_set_fl_marks(ptr_t p); /* Set all mark bits associated with */ /* a free list. */ -#ifdef GC_ASSERTIONS - void GC_check_fl_marks(ptr_t p); +#if defined(GC_ASSERTIONS) && defined(THREADS) && defined(THREAD_LOCAL_ALLOC) + void GC_check_fl_marks(void **); /* Check that all mark bits */ /* associated with a free list are */ /* set. Abort if not. */ diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 0a49b94d..0a5029b9 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -291,18 +291,14 @@ GC_INNER void GC_mark_thread_local_fls_for(GC_tlfs p) /* Check that all thread-local free-lists in p are completely marked. */ void GC_check_tls_for(GC_tlfs p) { - ptr_t q; int j; for (j = 1; j < TINY_FREELISTS; ++j) { - q = p -> ptrfree_freelists[j]; - if ((word)q > HBLKSIZE) GC_check_fl_marks(q); - q = p -> normal_freelists[j]; - if ((word)q > HBLKSIZE) GC_check_fl_marks(q); + GC_check_fl_marks(&p->ptrfree_freelists[j]); + GC_check_fl_marks(&p->normal_freelists[j]); # ifdef GC_GCJ_SUPPORT - q = p -> gcj_freelists[j]; - if ((word)q > HBLKSIZE) GC_check_fl_marks(q); -# endif /* GC_GCJ_SUPPORT */ + GC_check_fl_marks(&p->gcj_freelists[j]); +# endif } } #endif /* GC_ASSERTIONS */ -- 2.40.0