From: Richard Henderson Date: Thu, 30 Jan 2003 18:14:06 +0000 (-0800) Subject: ggc-page.c (G.context_depth_allocations): New. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=52895e1a46c720b4869414b60051d9b77793064a;p=gcc.git ggc-page.c (G.context_depth_allocations): New. * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6de454ae910..62d24ddda74 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2003-01-30 Richard Henderson + + * 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 * tree-inline.c (walk_tree): Streamline duplicate hash table lookup. 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 ();