summaryrefslogtreecommitdiff
path: root/gcc/ggc-page.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2003-01-30 18:14:06 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2003-01-30 18:14:06 +0000
commit598638e26a1ae9f210a9ed044ed8637b82f5fb9a (patch)
treeffe622bf1cea9eb96a1c15e2ecd46e025053bd39 /gcc/ggc-page.c
parentb68b5ffeb3d7b14dd83632db414dd72461914780 (diff)
downloadgcc-598638e26a1ae9f210a9ed044ed8637b82f5fb9a.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@62152 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r--gcc/ggc-page.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 4898f074ee1..e0064e7fdb2 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -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 ();