summaryrefslogtreecommitdiff
path: root/gcc/ggc-page.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-12 00:27:31 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-12 00:27:31 +0000
commit2a3edec56bee49d4a83483777cee1f99d73112f2 (patch)
tree81c813b5d55e959c7d6c49278a2c5c9c344cf7d5 /gcc/ggc-page.c
parent141c6b3e14e2778f6f9fe6c1974084f4e15f8688 (diff)
downloadgcc-2a3edec56bee49d4a83483777cee1f99d73112f2.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59034 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r--gcc/ggc-page.c49
1 files changed, 11 insertions, 38 deletions
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 9a2c03ef721..31c646349f3 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -28,6 +28,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "flags.h"
#include "ggc.h"
#include "timevar.h"
+#include "params.h"
/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
file open. Prefer either to valloc. */
@@ -88,23 +89,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
deallocated at the start of the next collection if they haven't
been recycled by then. */
-
-/* Define GGC_POISON to poison memory marked unused by the collector. */
-#undef GGC_POISON
-
-/* Define GGC_ALWAYS_COLLECT to 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
-
-#ifdef ENABLE_GC_CHECKING
-#define GGC_POISON
-#endif
-#ifdef ENABLE_GC_ALWAYS_COLLECT
-#define GGC_ALWAYS_COLLECT
-#endif
-
/* Define GGC_DEBUG_LEVEL to print debugging information.
0: No debugging output.
1: GC statistics only.
@@ -364,16 +348,6 @@ static struct globals
#define BITMAP_SIZE(Num_objects) \
(CEIL ((Num_objects), HOST_BITS_PER_LONG) * sizeof(long))
-/* 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)
-
/* Allocate pages in chunks of this size, to throttle calls to memory
allocation routines. The first page is used, the rest go onto the
free list. This cannot be larger than HOST_BITS_PER_INT for the
@@ -399,7 +373,7 @@ static void sweep_pages PARAMS ((void));
static void ggc_recalculate_in_use_p PARAMS ((page_entry *));
static void compute_inverse PARAMS ((unsigned));
-#ifdef GGC_POISON
+#ifdef ENABLE_GC_CHECKING
static void poison_pages PARAMS ((void));
#endif
@@ -968,7 +942,7 @@ ggc_alloc (size)
/* Calculate the object's address. */
result = entry->page + object_offset;
-#ifdef GGC_POISON
+#ifdef ENABLE_GC_CHECKING
/* `Poison' the entire allocated object, including any padding at
the end. */
memset (result, 0xaf, OBJECT_SIZE (order));
@@ -1129,8 +1103,6 @@ init_ggc ()
G.debug_file = stdout;
#endif
- G.allocated_last_gc = GGC_MIN_LAST_ALLOCATED;
-
#ifdef USING_MMAP
/* StunOS has an amazing off-by-one error for the first mmap allocation
after fiddling with RLIMIT_STACK. The result, as hard as it is to
@@ -1430,7 +1402,7 @@ sweep_pages ()
}
}
-#ifdef GGC_POISON
+#ifdef ENABLE_GC_CHECKING
/* Clobber all free objects. */
static inline void
@@ -1476,10 +1448,13 @@ ggc_collect ()
/* Avoid frequent unnecessary work by skipping collection if the
total allocations haven't expanded much since the last
collection. */
-#ifndef GGC_ALWAYS_COLLECT
- if (G.allocated < GGC_MIN_EXPAND_FOR_GC * G.allocated_last_gc)
+ 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
timevar_push (TV_GC);
if (!quiet_flag)
@@ -1496,15 +1471,13 @@ ggc_collect ()
clear_marks ();
ggc_mark_roots ();
-#ifdef GGC_POISON
+#ifdef ENABLE_GC_CHECKING
poison_pages ();
#endif
sweep_pages ();
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);