2008-08-21 Hans Boehm <Hans.Boehm@hp.com>
authorhboehm <hboehm>
Thu, 21 Aug 2008 21:06:56 +0000 (21:06 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:43 +0000 (21:06 +0400)
* 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 <Hans.Boehm@hp.com>
* alloc.c, include/gc_mark.h, Makefile.direct: Improve comments.

ChangeLog
Makefile.direct
alloc.c
headers.c
include/gc_mark.h
include/private/gc_hdrs.h
include/private/gc_pmark.h
mark.c
pthread_support.c

index 46799ad..d8a1d76 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-08-21  Hans Boehm <Hans.Boehm@hp.com>
+       * 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 <Hans.Boehm@hp.com>
+       * alloc.c, include/gc_mark.h, Makefile.direct: Improve comments.
+
 2008-08-01  Hans Boehm <Hans.Boehm@hp.com> (Really Klaus Treichel)
        * configure.ac: Set win32_threads on MinGW.
        * configure: Regenerate.
index 0441ecb..a9327a6 100644 (file)
@@ -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 0ae9420..a70c4d4 100644 (file)
--- 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)) {
index 9735d4b..774cf8d 100644 (file)
--- 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
index 8ee50b5..74c84ae 100644 (file)
@@ -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.    */
index 559556c..0e4c927 100644 (file)
@@ -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
index 33249d8..a72bf16 100644 (file)
@@ -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 3fb2f9d..37c76a5 100644 (file)
--- 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);
index b92c231..02e144c 100644 (file)
@@ -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 {