ggc-page.c (G.context_depth_allocations): New.
authorRichard Henderson <rth@redhat.com>
Thu, 30 Jan 2003 18:14:06 +0000 (10:14 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 30 Jan 2003 18:14:06 +0000 (10:14 -0800)
        * ggc-page.c (G.context_depth_allocations): New.
        (G.context_depth_collections): New.
        (alloc_page): Set G.context_depth_allocations.
        (ggc_collect): Set G.context_depth_collections.
        (ggc_push_context): Limit to HOST_BITS_PER_LONG contexts.
        (ggc_pop_context): Early exit for no allocations or collections.

From-SVN: r62152

gcc/ChangeLog
gcc/ggc-page.c

index 6de454ae910f96753b74bedfb67d88c3ec72b40f..62d24ddda74413486f9f46e03f57e3152db94b42 100644 (file)
@@ -1,3 +1,12 @@
+2003-01-30  Richard Henderson  <rth@redhat.com>
+
+       * ggc-page.c (G.context_depth_allocations): New.
+       (G.context_depth_collections): New.
+       (alloc_page): Set G.context_depth_allocations.
+       (ggc_collect): Set G.context_depth_collections.
+       (ggc_push_context): Limit to HOST_BITS_PER_LONG contexts.
+       (ggc_pop_context): Early exit for no allocations or collections.
+
 2003-01-30  Richard Henderson  <rth@redhat.com>
 
        * tree-inline.c (walk_tree): Streamline duplicate hash table lookup.
index 4898f074ee1f6598a3208b9dc7aaec53965accb3..e0064e7fdb2a5e9e35e0190af860e7f7f8810cf9 100644 (file)
@@ -344,6 +344,12 @@ static struct globals
   /* Total amount of memory mapped.  */
   size_t bytes_mapped;
 
+  /* Bit N set if any allocations have been done at context depth N.  */
+  unsigned long context_depth_allocations;
+
+  /* Bit N set if any collections have been done at context depth N.  */
+  unsigned long context_depth_collections;
+
   /* The current depth in the context stack.  */
   unsigned short context_depth;
 
@@ -743,6 +749,8 @@ alloc_page (order)
   entry->num_free_objects = num_objects;
   entry->next_bit_hint = 1;
 
+  G.context_depth_allocations |= (unsigned long)1 << G.context_depth;
+
 #ifdef USING_MALLOC_PAGE_GROUPS
   entry->group = group;
   set_page_group_in_use (group, page);
@@ -1221,7 +1229,7 @@ ggc_push_context ()
   ++G.context_depth;
 
   /* Die on wrap.  */
-  if (G.context_depth == 0)
+  if (G.context_depth >= HOST_BITS_PER_LONG)
     abort ();
 }
 
@@ -1269,9 +1277,18 @@ ggc_recalculate_in_use_p (p)
 void
 ggc_pop_context ()
 {
+  unsigned long omask;
   unsigned order, depth;
 
   depth = --G.context_depth;
+  omask = (unsigned long)1 << (depth + 1);
+
+  if (!((G.context_depth_allocations | G.context_depth_collections) & omask))
+    return;
+
+  G.context_depth_allocations |= (G.context_depth_allocations & omask) >> 1;
+  G.context_depth_allocations &= omask - 1;
+  G.context_depth_collections &= omask - 1;
 
   /* Any remaining pages in the popped context are lowered to the new
      current context; i.e. objects allocated in the popped context and
@@ -1529,6 +1546,9 @@ ggc_collect ()
      reuse in the interim.  */
   release_pages ();
 
+  /* Indicate that we've seen collections at this context depth.  */
+  G.context_depth_collections = ((unsigned long)1 << (G.context_depth + 1)) - 1;
+
   clear_marks ();
   ggc_mark_roots ();