Hi, This patch does three things: 1) Fix broken --with-gc=page. Now it is possible to build GCC with these two collectors from exactly same sources.
2) Boehms's GC makes GCC print collector warnings time from time about very large blocks being allocated. These warnings are meaningless, so they are suppressed normally, but allowed with -v. It fixes some of the spurious testsuite "regressions", I don't know how many yet, as testsuite takes more than 24 hours here on Cygwin, 1.8GHz Turion. I can run it much faster inside in VMWare on Linux on the same machine. Is there any way to speed it up on Cygwin? 3) Adjusted decision when to collect to match more closely other collectors. More specifically, only used bytes in the heap instead of overall heap size are considered. Commited to the boehms-gc branch, thanks in advance for any comments, -- Laurynas Index: gcc/ggc-boehm.c =================================================================== --- gcc/ggc-boehm.c (revision 114910) +++ gcc/ggc-boehm.c (working copy) @@ -4,16 +4,22 @@ #include "params.h" #include "timevar.h" #include "ggc.h" +#include "symtab.h" -#define GC_DEBUG +/* #define GC_DEBUG */ #include <gc.h> +extern struct ht *ident_hash; + static size_t get_used_heap_size(void); static void register_gty_roots(void); +static void gc_warning_filter(char * msg, GC_word arg); static size_t last_allocated = 0; static ggc_stringpool_roots stringpool_roots; +static GC_warn_proc default_warn_proc; + void init_ggc (void) { @@ -23,6 +29,8 @@ stringpool_roots.start = NULL; stringpool_roots.one_after_finish = NULL; + + default_warn_proc = GC_set_warn_proc(gc_warning_filter); } void * @@ -50,7 +58,7 @@ float min_expand = allocated_last_gc * PARAM_VALUE (GGC_MIN_EXPAND) / 100; - if (GC_get_heap_size() < allocated_last_gc + min_expand + if (get_used_heap_size() < allocated_last_gc + min_expand && !ggc_force_collect) return; @@ -73,7 +81,7 @@ if (!quiet_flag) fprintf (stderr, "%luk}", (unsigned long) get_used_heap_size() / 1024); - last_allocated = GC_get_heap_size(); + last_allocated = get_used_heap_size(); timevar_pop (TV_GC); } @@ -171,7 +179,11 @@ fprintf (stderr, "Total heap size: %lu\n", (unsigned long)GC_get_heap_size()); fprintf (stderr, - "Free bytes in the heap: %lu\n", (unsigned long)GC_get_free_bytes()); + "Free bytes in the heap: %lu\n", + (unsigned long)GC_get_free_bytes()); + fprintf (stderr, + "Used bytes in the heap: %lu\n", + (unsigned long)get_used_heap_size()); } int @@ -205,3 +217,38 @@ /* TODO: it might be required to process gt_ggc_cache_rtab here */ } + +/* Register the stringpool entries as GGC roots. In contrast to all other + roots, that are static, stringpool may increase and move around in memory. + So it's handled specially. */ +ggc_stringpool_roots +ggc_register_stringpool_roots (void) +{ + ggc_stringpool_roots result; + result.start = ident_hash->entries; + result.one_after_finish = ident_hash->entries + ident_hash->nslots; + + GC_add_roots (result.start, result.one_after_finish); + + return result; +} + +void +ggc_unregister_stringpool_roots (ggc_stringpool_roots roots) +{ + GC_remove_roots (roots.start, roots.one_after_finish); +} + +int +ggc_stringpool_moved_p (ggc_stringpool_roots roots) +{ + return (roots.start != ident_hash->entries) + || (roots.one_after_finish != ident_hash->entries + ident_hash->nslots); +} + +void +gc_warning_filter(char * msg, GC_word arg) +{ + if (!quiet_flag) + (*default_warn_proc)(msg, arg); +} Index: gcc/stringpool.c =================================================================== --- gcc/stringpool.c (revision 114910) +++ gcc/stringpool.c (working copy) @@ -37,8 +37,6 @@ #include "symtab.h" #include "cpplib.h" -#include <gc.h> - /* The stringpool contains 2^ORDER entries. */ #define ORDER 14 @@ -74,8 +72,6 @@ ident_hash->alloc_node = alloc_node; ident_hash->alloc_subobject = stringpool_ggc_alloc; gcc_obstack_init (&string_stack); - - ggc_register_stringpool_roots(); } /* Allocate a hash node. */ @@ -182,34 +178,6 @@ ht_forall (ident_hash, mark_ident, NULL); } -/* Register the stringpool entries as GGC roots. In contrast to all other - roots, that are static, stringpool may increase and move around in memory. - So it's handled specially. */ -ggc_stringpool_roots -ggc_register_stringpool_roots (void) -{ - ggc_stringpool_roots result; - result.start = ident_hash->entries; - result.one_after_finish = ident_hash->entries + ident_hash->nslots; - - GC_add_roots (result.start, result.one_after_finish); - - return result; -} - -void -ggc_unregister_stringpool_roots (ggc_stringpool_roots roots) -{ - GC_remove_roots (roots.start, roots.one_after_finish); -} - -int -ggc_stringpool_moved_p (ggc_stringpool_roots roots) -{ - return (roots.start != ident_hash->entries) - || (roots.one_after_finish != ident_hash->entries + ident_hash->nslots); -} - /* Strings are _not_ GCed, but this routine exists so that a separate roots table isn't needed for the few global variables that refer to strings. */