diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-10-11 02:11:21 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-10-11 02:11:21 +0000 |
commit | 74c937ca61c1872ce7ff653c2d7fda6d4b38db30 (patch) | |
tree | 5036f98758c484314588bc1a1893a4651f5f4190 /gcc/ggc-page.c | |
parent | f9562f27ffae26afb22f320d27eca41f36de95a2 (diff) | |
download | gcc-74c937ca61c1872ce7ff653c2d7fda6d4b38db30.tar.gz |
ggc.h (ggc_push_context): Fix comment.
* ggc.h (ggc_push_context): Fix comment.
(ggc_pop_context): Likewise.
(mark_string_if_gcable): Likewise.
* ggc-common.c (ggc_mark_rtx_children): Use
ggc_mark_string_if_gcable.
* ggc-page.c (ggc_lookup_page_table): New function.
(ggc_allocated_p): Likewise.
(mark_obj): Fix formatting.
(ggc_mark_string_if_gcable): New function.
* ggc-simple.c (ggc_allocated_strings): New variable.
(ggc_strings_used): Likewise.
(ggc_compare_addresses): New function.
(ggc_pop_context): Pop the `any' memory too.
(ggc_mark_string_if_gcable): New function.
(ggc_collect): Initialize and tear down ggc_allocated_strings.
From-SVN: r29897
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r-- | gcc/ggc-page.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index 6b8e4684664..1b643e6fa03 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -258,6 +258,8 @@ static struct globals #define GGC_MIN_LAST_ALLOCATED (4 * 1024 * 1024) +static page_entry *** ggc_lookup_page_table PROTO ((void)); +static int ggc_allocated_p PROTO ((const void *)); static page_entry *lookup_page_table_entry PROTO ((void *)); static void set_page_table_entry PROTO ((void *, page_entry *)); static char *alloc_anon PROTO ((char *, size_t)); @@ -276,15 +278,12 @@ static void poison_pages PROTO ((void)); void debug_print_page_list PROTO ((int)); -/* Traverse the page table and find the entry for a page. - Die (probably) if the object wasn't allocated via GC. */ +/* Returns the lookup table appropriate for looking up P. */ -static inline page_entry * -lookup_page_table_entry(p) - void *p; +static inline page_entry *** +ggc_lookup_page_table () { page_entry ***base; - size_t L1, L2; #if HOST_BITS_PER_PTR <= 32 base = &G.lookup[0]; @@ -296,6 +295,39 @@ lookup_page_table_entry(p) base = &table->table[0]; #endif + return base; +} + +/* Returns non-zero if P was allocated in GC'able memory. */ + +static inline int +ggc_allocated_p (p) + const void *p; +{ + page_entry ***base; + size_t L1, L2; + + base = ggc_lookup_page_table (); + + /* Extract the level 1 and 2 indicies. */ + L1 = LOOKUP_L1 (p); + L2 = LOOKUP_L2 (p); + + return base[L1] && base[L1][L2]; +} + +/* Traverse the page table and find the entry for a page. + Die (probably) if the object wasn't allocated via GC. */ + +static inline page_entry * +lookup_page_table_entry(p) + void *p; +{ + page_entry ***base; + size_t L1, L2; + + base = ggc_lookup_page_table (); + /* Extract the level 1 and 2 indicies. */ L1 = LOOKUP_L1 (p); L2 = LOOKUP_L2 (p); @@ -678,7 +710,7 @@ mark_obj (p) /* Look up the page on which the object is alloced. If the object wasn't allocated by the collector, we'll probably die. */ - entry = lookup_page_table_entry(p); + entry = lookup_page_table_entry (p); #ifdef ENABLE_CHECKING if (entry == NULL) abort (); @@ -1076,6 +1108,14 @@ ggc_mark_string (s) mark_obj (s); } +void +ggc_mark_string_if_gcable (s) + char *s; +{ + if (s && ggc_allocated_p (s)) + mark_obj (s); +} + void ggc_mark (p) void *p; |