From: hboehm Date: Thu, 21 Aug 2008 21:06:56 +0000 (+0000) Subject: 2008-08-21 Hans Boehm X-Git-Tag: gc7_2alpha2~68 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1c47cb7d70756e93a1f43b7ac9593d4425f8e9a;p=gc 2008-08-21 Hans Boehm * mark.c: (GC_push_next_marked, GC_push_next_marked_dirty, GC_push_next_marked_uncollectable): Never invoke GC_push_marked on free hblk. * headers.c: Test COUNT_HDR_CACHE_HITS not USE_HDR_CACHE. (GC_header_cache_miss): Always blacklist pointers for free hblks. Add assertion and comment. * pthread_support.c (GC_register_my_thread): Fix #if indentation. * include/private/gc_hdrs.h: USE_HDR_CACHE is no longer tested. Delete it. * include/private/gc_pmark.h: (PUSH_OBJ): Add assertion. 2008-08-21 Hans Boehm * alloc.c, include/gc_mark.h, Makefile.direct: Improve comments. --- diff --git a/ChangeLog b/ChangeLog index 46799adf..d8a1d766 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-08-21 Hans Boehm + * mark.c: (GC_push_next_marked, GC_push_next_marked_dirty, + GC_push_next_marked_uncollectable): Never invoke GC_push_marked + on free hblk. + * headers.c: Test COUNT_HDR_CACHE_HITS not USE_HDR_CACHE. + (GC_header_cache_miss): Always blacklist pointers for free + hblks. Add assertion and comment. + * pthread_support.c (GC_register_my_thread): Fix #if indentation. + * include/private/gc_hdrs.h: USE_HDR_CACHE is no longer tested. + Delete it. + * include/private/gc_pmark.h: (PUSH_OBJ): Add assertion. + +2008-08-21 Hans Boehm + * alloc.c, include/gc_mark.h, Makefile.direct: Improve comments. + 2008-08-01 Hans Boehm (Really Klaus Treichel) * configure.ac: Set win32_threads on MinGW. * configure: Regenerate. diff --git a/Makefile.direct b/Makefile.direct index 0441ecb6..a9327a60 100644 --- a/Makefile.direct +++ b/Makefile.direct @@ -264,8 +264,8 @@ HOSTCFLAGS=$(CFLAGS) # may help performance on recent Linux installations. (It failed for # me on RedHat 8, but appears to work on RedHat 9.) # -DPARALLEL_MARK allows the marker to run in multiple threads. Recommended -# for multiprocessors. Currently requires Linux on X86 or IA64, though -# support for other Posix platforms should be fairly easy to add, +# for multiprocessors. Currently works only on some pthreads platforms, +# though support for other platforms should be fairly easy to add, # if the thread implementation is otherwise supported. # -DNO_GETENV prevents the collector from looking at environment variables. # These may otherwise alter its configuration, or turn off GC altogether. diff --git a/alloc.c b/alloc.c index 0ae94206..a70c4d44 100644 --- a/alloc.c +++ b/alloc.c @@ -961,7 +961,8 @@ GC_bool GC_expand_hp_inner(word n) (unsigned long)GC_bytes_allocd); } /* Adjust heap limits generously for blacklisting to work better. */ - /* GC_add_to_heap performs minimal adjustment need for correctness. */ + /* GC_add_to_heap performs minimal adjustment needed for */ + /* correctness. */ expansion_slop = min_bytes_allocd() + 4*MAXHINCR*HBLKSIZE; if ((GC_last_heap_addr == 0 && !((word)space & SIGNB)) || (GC_last_heap_addr != 0 && GC_last_heap_addr < (ptr_t)space)) { diff --git a/headers.c b/headers.c index 9735d4b0..774cf8d4 100644 --- a/headers.c +++ b/headers.c @@ -50,6 +50,7 @@ hdr * GC_find_header(ptr_t h) /* GUARANTEED to return 0 for a pointer past the first page */ /* of an object unless both GC_all_interior_pointers is set */ /* and p is in fact a valid object pointer. */ +/* Never returns a pointer to a free hblk. */ #ifdef PRINT_BLACK_LIST hdr * GC_header_cache_miss(ptr_t p, hdr_cache_entry *hce, ptr_t source) #else @@ -70,17 +71,19 @@ hdr * GC_find_header(ptr_t h) hhdr = HDR(current); } while(IS_FORWARDING_ADDR_OR_NIL(hhdr)); /* current points to near the start of the large object */ - if (hhdr -> hb_flags & IGNORE_OFF_PAGE - || HBLK_IS_FREE(hhdr)) + if (hhdr -> hb_flags & IGNORE_OFF_PAGE) return 0; - if (p - current >= (ptrdiff_t)(hhdr->hb_sz)) { + if (HBLK_IS_FREE(hhdr) + || p - current >= (ptrdiff_t)(hhdr->hb_sz)) { GC_ADD_TO_BLACK_LIST_NORMAL(p, source); /* Pointer past the end of the block */ return 0; } } else { GC_ADD_TO_BLACK_LIST_NORMAL(p, source); + /* And return zero: */ } + GC_ASSERT(hhdr == 0 || !HBLK_IS_FREE(hhdr)); return hhdr; /* Pointers past the first page are probably too rare */ /* to add them to the cache. We don't. */ @@ -181,7 +184,7 @@ static void free_hdr(hdr * hhdr) hdr_free_list = hhdr; } -#ifdef USE_HDR_CACHE +#ifdef COUNT_HDR_CACHE_HITS word GC_hdr_cache_hits = 0; word GC_hdr_cache_misses = 0; #endif diff --git a/include/gc_mark.h b/include/gc_mark.h index 8ee50b5d..74c84aeb 100644 --- a/include/gc_mark.h +++ b/include/gc_mark.h @@ -110,6 +110,8 @@ extern void * GC_least_plausible_heap_addr; extern void * GC_greatest_plausible_heap_addr; /* Bounds on the heap. Guaranteed valid */ /* Likely to include future heap expansion. */ + /* Hence usually includes not-yet-mapped */ + /* memory. */ /* Handle nested references in a custom mark procedure. */ /* Check if obj is a valid object. If so, ensure that it is marked. */ diff --git a/include/private/gc_hdrs.h b/include/private/gc_hdrs.h index 559556ca..0e4c927d 100644 --- a/include/private/gc_hdrs.h +++ b/include/private/gc_hdrs.h @@ -54,10 +54,6 @@ typedef struct hblkhdr hdr; # define TOP_SZ (1 << LOG_TOP_SZ) # define BOTTOM_SZ (1 << LOG_BOTTOM_SZ) -#ifndef SMALL_CONFIG -# define USE_HDR_CACHE -#endif - /* #define COUNT_HDR_CACHE_HITS */ # ifdef COUNT_HDR_CACHE_HITS diff --git a/include/private/gc_pmark.h b/include/private/gc_pmark.h index 33249d89..a72bf169 100644 --- a/include/private/gc_pmark.h +++ b/include/private/gc_pmark.h @@ -138,6 +138,7 @@ mse * GC_signal_mark_stack_overflow(mse *msp); { \ register word _descr = (hhdr) -> hb_descr; \ \ + GC_ASSERT(!HBLK_IS_FREE(hhdr)); \ if (_descr != 0) { \ mark_stack_top++; \ if (mark_stack_top >= mark_stack_limit) { \ diff --git a/mark.c b/mark.c index 3fb2f9d5..37c76a53 100644 --- a/mark.c +++ b/mark.c @@ -1802,7 +1802,7 @@ struct hblk * GC_push_next_marked(struct hblk *h) { hdr * hhdr = HDR(h); - if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr), FALSE)) { + if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr) || HBLK_IS_FREE(hhdr), FALSE)) { h = GC_next_used_block(h); if (h == 0) return(0); hhdr = GC_find_header((ptr_t)h); @@ -1819,7 +1819,8 @@ struct hblk * GC_push_next_marked_dirty(struct hblk *h) if (!GC_dirty_maintained) { ABORT("dirty bits not set up"); } for (;;) { - if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr), FALSE)) { + if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr) + || HBLK_IS_FREE(hhdr), FALSE)) { h = GC_next_used_block(h); if (h == 0) return(0); hhdr = GC_find_header((ptr_t)h); @@ -1850,7 +1851,8 @@ struct hblk * GC_push_next_marked_uncollectable(struct hblk *h) hdr * hhdr = HDR(h); for (;;) { - if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr), FALSE)) { + if (EXPECT(IS_FORWARDING_ADDR_OR_NIL(hhdr) + || HBLK_IS_FREE(hhdr), FALSE)) { h = GC_next_used_block(h); if (h == 0) return(0); hhdr = GC_find_header((ptr_t)h); diff --git a/pthread_support.c b/pthread_support.c index b92c2312..02e144c7 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1036,9 +1036,9 @@ GC_API int GC_register_my_thread(struct GC_stack_base *sb) me -> flags |= DETACHED; /* Treat as detached, since we do not need to worry about */ /* pointer results. */ -# if defined(THREAD_LOCAL_ALLOC) - GC_init_thread_local(&(me->tlfs)); -# endif +# if defined(THREAD_LOCAL_ALLOC) + GC_init_thread_local(&(me->tlfs)); +# endif UNLOCK(); return GC_SUCCESS; } else {