aboutsummaryrefslogtreecommitdiff
path: root/gcc/ggc-simple.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@codesourcery.com>2002-11-12 00:27:31 +0000
committerZack Weinberg <zack@gcc.gnu.org>2002-11-12 00:27:31 +0000
commit3788cc1761ef491333f243e4e846c7246a3cc5bb (patch)
tree81c813b5d55e959c7d6c49278a2c5c9c344cf7d5 /gcc/ggc-simple.c
parentdd697f8c1dfd5244373ade9fd67df3e35fa807f5 (diff)
downloadgcc-3788cc1761ef491333f243e4e846c7246a3cc5bb.zip
gcc-3788cc1761ef491333f243e4e846c7246a3cc5bb.tar.gz
gcc-3788cc1761ef491333f243e4e846c7246a3cc5bb.tar.bz2
params.def (ggc-min-expand, [...]): New parameters.
* params.def (ggc-min-expand, ggc-min-heapsize): New parameters. * doc/invoke.texi: Document them. * ggc-page.c: Include params.h. Remove definitions of GGC_MIN_EXPAND_FOR_GC, GGC_MIN_LAST_ALLOCATED. Replace GGC_POISON with ENABLE_GC_CHECKING in ifdefs, delete #define. (init_gcc): Don't set G.allocated_last_gc here. (ggc_collect): Use PARAM_VALUE (GGC_MIN_HEAPSIZE) and PARAM_VALUE (GGC_MIN_EXPAND) to decide whether or not to perform collection. * ggc-simple.c: Similarly. * Makefile.in (ggc-common.o, ggc-simple.o): Add $(PARAMS_H) to dependencies. From-SVN: r59034
Diffstat (limited to 'gcc/ggc-simple.c')
-rw-r--r--gcc/ggc-simple.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/gcc/ggc-simple.c b/gcc/ggc-simple.c
index d3b5327..30b8725 100644
--- a/gcc/ggc-simple.c
+++ b/gcc/ggc-simple.c
@@ -27,20 +27,16 @@
#include "varray.h"
#include "ggc.h"
#include "timevar.h"
+#include "params.h"
/* Debugging flags. */
/* Zap memory before freeing to catch dangling pointers. */
-#define GGC_POISON
+#undef GGC_POISON
/* Collect statistics on how bushy the search tree is. */
#undef GGC_BALANCE
-/* Perform collection every time ggc_collect is invoked. Otherwise,
- collection is performed only when a significant amount of memory
- has been allocated since the last collection. */
-#undef GGC_ALWAYS_COLLECT
-
/* Always verify that the to-be-marked memory is collectable. */
#undef GGC_ALWAYS_VERIFY
@@ -48,9 +44,6 @@
#define GGC_POISON
#define GGC_ALWAYS_VERIFY
#endif
-#ifdef ENABLE_GC_ALWAYS_COLLECT
-#define GGC_ALWAYS_COLLECT
-#endif
#ifndef HOST_BITS_PER_PTR
#define HOST_BITS_PER_PTR HOST_BITS_PER_LONG
@@ -115,16 +108,6 @@ static struct globals
int context;
} G;
-/* Skip garbage collection if the current allocation is not at least
- this factor times the allocation at the end of the last collection.
- In other words, total allocation must expand by (this factor minus
- one) before collection is performed. */
-#define GGC_MIN_EXPAND_FOR_GC (1.3)
-
-/* Bound `allocated_last_gc' to 4MB, to prevent the memory expansion
- test from triggering too often when the heap is small. */
-#define GGC_MIN_LAST_ALLOCATED (4 * 1024 * 1024)
-
/* Local function prototypes. */
static void tree_insert PARAMS ((struct ggc_mem *));
@@ -324,10 +307,16 @@ sweep_objs (root)
void
ggc_collect ()
{
-#ifndef GGC_ALWAYS_COLLECT
- if (G.allocated < GGC_MIN_EXPAND_FOR_GC * G.allocated_last_gc)
+ /* Avoid frequent unnecessary work by skipping collection if the
+ total allocations haven't expanded much since the last
+ collection. */
+ size_t allocated_last_gc =
+ MAX (G.allocated_last_gc, (size_t)PARAM_VALUE (GGC_MIN_HEAPSIZE) * 1024);
+
+ size_t min_expand = allocated_last_gc * PARAM_VALUE (GGC_MIN_EXPAND) / 100;
+
+ if (G.allocated < allocated_last_gc + min_expand)
return;
-#endif
#ifdef GGC_BALANCE
debug_ggc_balance ();
@@ -345,8 +334,6 @@ ggc_collect ()
sweep_objs (&G.root);
G.allocated_last_gc = G.allocated;
- if (G.allocated_last_gc < GGC_MIN_LAST_ALLOCATED)
- G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
timevar_pop (TV_GC);
@@ -363,7 +350,6 @@ ggc_collect ()
void
init_ggc ()
{
- G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
}
/* Start a new GGC context. Memory allocated in previous contexts