ggc-zone.c: Rewritten.

* ggc-zone.c: Rewritten.

	* alloc-pool.c (dump_alloc_pool_statistics): Don't print statistics
	if there are none.
	* configure.ac: Define GGC_ZONE for --with-gc=zone.
	* config.in: Regenerated.
	* configure: Regenerated.
	* gentype.c (write_types_process_field, write_func_for_structure):
	Pass new argument to gt_pch_note_object.
	* ggc-common.c (struct ptr_data): Add TYPE.
	(gt_pch_note_object): Take TYPE argument and save it.
	(call_count): Update call to ggc_pch_count_object.
	(call_alloc): Update call to ggc_pch_alloc_object.
	(gt_pch_save): Call ggc_pch_prepare_write after paddng the PCH
	file.
	* ggc-none.c (rtl_zone, garbage_zone, ggc_alloc_zone_stat): Delete.
	* ggc-page.c (rtl_zone, tree_zone, garbage_zone)
	(ggc_alloc_zone_stat): Delete.
	(ggc_pch_count_object, ggc_pch_alloc_object): Add TYPE argument.
	* ggc.h (gt_pch_note_object, ggc_pch_count_object)
	(ggc_pch_alloc_object): Update prototypes.
	(garbage_zone): Delete.
	(tree_zone, rtl_zone, ggc_alloc_zone_stat, ggc_alloc_zone): Move to
	GGC_ZONE conditional.  Update.  Change tree_zone and rtl_zone into
	pointers.
	(tree_id_zone): New variable.
	(ggc_alloc_cleared_zone): Remove unused.
	(ggc_alloc_zone): Define.
	(ggc_alloc_rtvec, ggc_alloc_tree): Update to use ggc_alloc_zone.
	* rtl.c (rtx_alloc_stat, shallow_copy_rtx_stat): Use
	ggc_alloc_zone_stat.
	* stringpool.c (gt_pch_n_S): Update call to gt_pch_note_object.
	* tree.c (copy_node_stat, make_tree_binfo_stat, make_tree_vec_stat)
	(tree_cons_stat, build1_stat): Update call to ggc_alloc_zone_stat.
	(make_node_stat): Likewise.  Use tree_id_zone.

From-SVN: r96381
This commit is contained in:
Daniel Jacobowitz 2005-03-13 18:09:55 +00:00 committed by Daniel Jacobowitz
parent 69229b8198
commit 08cee789cd
14 changed files with 1605 additions and 722 deletions

View File

@ -1,3 +1,41 @@
2005-03-13 Daniel Jacobowitz <dan@codesourcery.com>
* ggc-zone.c: Rewritten.
* alloc-pool.c (dump_alloc_pool_statistics): Don't print statistics
if there are none.
* configure.ac: Define GGC_ZONE for --with-gc=zone.
* config.in: Regenerated.
* configure: Regenerated.
* gentype.c (write_types_process_field, write_func_for_structure):
Pass new argument to gt_pch_note_object.
* ggc-common.c (struct ptr_data): Add TYPE.
(gt_pch_note_object): Take TYPE argument and save it.
(call_count): Update call to ggc_pch_count_object.
(call_alloc): Update call to ggc_pch_alloc_object.
(gt_pch_save): Call ggc_pch_prepare_write after paddng the PCH
file.
* ggc-none.c (rtl_zone, garbage_zone, ggc_alloc_zone_stat): Delete.
* ggc-page.c (rtl_zone, tree_zone, garbage_zone)
(ggc_alloc_zone_stat): Delete.
(ggc_pch_count_object, ggc_pch_alloc_object): Add TYPE argument.
* ggc.h (gt_pch_note_object, ggc_pch_count_object)
(ggc_pch_alloc_object): Update prototypes.
(garbage_zone): Delete.
(tree_zone, rtl_zone, ggc_alloc_zone_stat, ggc_alloc_zone): Move to
GGC_ZONE conditional. Update. Change tree_zone and rtl_zone into
pointers.
(tree_id_zone): New variable.
(ggc_alloc_cleared_zone): Remove unused.
(ggc_alloc_zone): Define.
(ggc_alloc_rtvec, ggc_alloc_tree): Update to use ggc_alloc_zone.
* rtl.c (rtx_alloc_stat, shallow_copy_rtx_stat): Use
ggc_alloc_zone_stat.
* stringpool.c (gt_pch_n_S): Update call to gt_pch_note_object.
* tree.c (copy_node_stat, make_tree_binfo_stat, make_tree_vec_stat)
(tree_cons_stat, build1_stat): Update call to ggc_alloc_zone_stat.
(make_node_stat): Likewise. Use tree_id_zone.
2005-03-13 Daniel Jacobowitz <dan@codesourcery.com>
Joseph S. Myers <joseph@codesourcery.com>

View File

@ -333,6 +333,9 @@ void dump_alloc_pool_statistics (void)
#ifdef GATHER_STATISTICS
struct output_info info;
if (!alloc_pool_hash)
return;
fprintf (stderr, "\nAlloc-pool Kind Pools Allocated Peak Leak\n");
fprintf (stderr, "-------------------------------------------------------------\n");
info.count = 0;

View File

@ -79,6 +79,9 @@
this is either `int' or `gid_t'. */
#undef GETGROUPS_T
/* Define if the zone collector is in use */
#undef GGC_ZONE
/* Define to 1 if you have the `alphasort' function. */
#undef HAVE_ALPHASORT

10
gcc/configure vendored
View File

@ -14959,8 +14959,16 @@ fi
if test "${with_gc+set}" = set; then
withval="$with_gc"
case "$withval" in
page | zone)
page)
GGC=ggc-$withval
;;
zone)
GGC=ggc-$withval
cat >>confdefs.h <<\_ACEOF
#define GGC_ZONE 1
_ACEOF
;;
*)
{ { echo "$as_me:$LINENO: error: $withval is an invalid option to --with-gc" >&5

View File

@ -3027,9 +3027,13 @@ AC_ARG_WITH(gc,
[ --with-gc={page,zone} choose the garbage collection mechanism to use
with the compiler],
[case "$withval" in
page | zone)
page)
GGC=ggc-$withval
;;
zone)
GGC=ggc-$withval
AC_DEFINE(GGC_ZONE, 1, [Define if the zone collector is in use])
;;
*)
AC_MSG_ERROR([$withval is an invalid option to --with-gc])
;;

View File

@ -1928,6 +1928,21 @@ write_types_process_field (type_p f, const struct walk_type_data *d)
}
else
oprintf (d->of, ", gt_%sa_%s", wtd->param_prefix, d->prev_val[0]);
if (f->u.p->kind == TYPE_PARAM_STRUCT
&& f->u.p->u.s.line.file != NULL)
{
oprintf (d->of, ", gt_e_");
output_mangled_typename (d->of, f);
}
else if (UNION_OR_STRUCT_P (f)
&& f->u.p->u.s.line.file != NULL)
{
oprintf (d->of, ", gt_ggc_e_");
output_mangled_typename (d->of, f);
}
else
oprintf (d->of, ", gt_types_enum_last");
}
oprintf (d->of, ");\n");
if (d->reorder_fn && wtd->reorder_note_routine)
@ -2035,6 +2050,21 @@ write_func_for_structure (type_p orig_s, type_p s, type_p *param,
{
oprintf (d.of, ", x, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s);
if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
&& orig_s->u.p->u.s.line.file != NULL)
{
oprintf (d.of, ", gt_e_");
output_mangled_typename (d.of, orig_s);
}
else if (UNION_OR_STRUCT_P (orig_s)
&& orig_s->u.s.line.file != NULL)
{
oprintf (d.of, ", gt_ggc_e_");
output_mangled_typename (d.of, orig_s);
}
else
oprintf (d.of, ", gt_types_enum_last");
}
oprintf (d.of, "))\n");
}
@ -2045,6 +2075,21 @@ write_func_for_structure (type_p orig_s, type_p s, type_p *param,
{
oprintf (d.of, ", xlimit, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s);
if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
&& orig_s->u.p->u.s.line.file != NULL)
{
oprintf (d.of, ", gt_e_");
output_mangled_typename (d.of, orig_s);
}
else if (UNION_OR_STRUCT_P (orig_s)
&& orig_s->u.s.line.file != NULL)
{
oprintf (d.of, ", gt_ggc_e_");
output_mangled_typename (d.of, orig_s);
}
else
oprintf (d.of, ", gt_types_enum_last");
}
oprintf (d.of, "))\n");
oprintf (d.of, " xlimit = (");
@ -2070,6 +2115,21 @@ write_func_for_structure (type_p orig_s, type_p s, type_p *param,
{
oprintf (d.of, ", xprev, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s);
if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
&& orig_s->u.p->u.s.line.file != NULL)
{
oprintf (d.of, ", gt_e_");
output_mangled_typename (d.of, orig_s);
}
else if (UNION_OR_STRUCT_P (orig_s)
&& orig_s->u.s.line.file != NULL)
{
oprintf (d.of, ", gt_ggc_e_");
output_mangled_typename (d.of, orig_s);
}
else
oprintf (d.of, ", gt_types_enum_last");
}
oprintf (d.of, ");\n");
oprintf (d.of, " }\n");

View File

@ -244,6 +244,7 @@ struct ptr_data
gt_handle_reorder reorder_fn;
size_t size;
void *new_addr;
enum gt_types_enum type;
};
#define POINTER_HASH(x) (hashval_t)((long)x >> 3)
@ -252,7 +253,8 @@ struct ptr_data
int
gt_pch_note_object (void *obj, void *note_ptr_cookie,
gt_note_pointers note_ptr_fn)
gt_note_pointers note_ptr_fn,
enum gt_types_enum type)
{
struct ptr_data **slot;
@ -277,6 +279,7 @@ gt_pch_note_object (void *obj, void *note_ptr_cookie,
(*slot)->size = strlen (obj) + 1;
else
(*slot)->size = ggc_get_size (obj);
(*slot)->type = type;
return 1;
}
@ -330,7 +333,9 @@ call_count (void **slot, void *state_p)
struct ptr_data *d = (struct ptr_data *)*slot;
struct traversal_state *state = (struct traversal_state *)state_p;
ggc_pch_count_object (state->d, d->obj, d->size, d->note_ptr_fn == gt_pch_p_S);
ggc_pch_count_object (state->d, d->obj, d->size,
d->note_ptr_fn == gt_pch_p_S,
d->type);
state->count++;
return 1;
}
@ -341,7 +346,9 @@ call_alloc (void **slot, void *state_p)
struct ptr_data *d = (struct ptr_data *)*slot;
struct traversal_state *state = (struct traversal_state *)state_p;
d->new_addr = ggc_pch_alloc_object (state->d, d->obj, d->size, d->note_ptr_fn == gt_pch_p_S);
d->new_addr = ggc_pch_alloc_object (state->d, d->obj, d->size,
d->note_ptr_fn == gt_pch_p_S,
d->type);
state->ptrs[state->ptrs_i++] = d;
return 1;
}
@ -476,8 +483,6 @@ gt_pch_save (FILE *f)
write_pch_globals (gt_ggc_rtab, &state);
write_pch_globals (gt_pch_cache_rtab, &state);
ggc_pch_prepare_write (state.d, state.f);
/* Pad the PCH file so that the mmapped area starts on an allocation
granularity (usually page) boundary. */
{
@ -496,6 +501,8 @@ gt_pch_save (FILE *f)
&& fseek (state.f, mmi.offset, SEEK_SET) != 0)
fatal_error ("can't write padding to PCH file: %m");
ggc_pch_prepare_write (state.d, state.f);
/* Actually write out the objects. */
for (i = 0; i < state.count; i++)
{

View File

@ -33,9 +33,6 @@
#include "coretypes.h"
#include "ggc.h"
struct alloc_zone *rtl_zone = NULL;
struct alloc_zone *garbage_zone = NULL;
void *
ggc_alloc_typed_stat (enum gt_types_enum ARG_UNUSED (gte), size_t size
MEM_STAT_DECL)
@ -49,13 +46,6 @@ ggc_alloc_stat (size_t size MEM_STAT_DECL)
return xmalloc (size);
}
void *
ggc_alloc_zone_stat (size_t size, struct alloc_zone * ARG_UNUSED (zone)
MEM_STAT_DECL)
{
return xmalloc (size);
}
void *
ggc_alloc_cleared_stat (size_t size MEM_STAT_DECL)
{

View File

@ -495,9 +495,6 @@ static void move_ptes_to_front (int, int);
void debug_print_page_list (int);
static void push_depth (unsigned int);
static void push_by_depth (page_entry *, unsigned long *);
struct alloc_zone *rtl_zone = NULL;
struct alloc_zone *tree_zone = NULL;
struct alloc_zone *garbage_zone = NULL;
/* Push an entry onto G.depth. */
@ -1052,15 +1049,6 @@ ggc_alloc_typed_stat (enum gt_types_enum type ATTRIBUTE_UNUSED, size_t size
return ggc_alloc_stat (size PASS_MEM_STAT);
}
/* Zone allocation function. Does nothing special in this collector. */
void *
ggc_alloc_zone_stat (size_t size, struct alloc_zone *zone ATTRIBUTE_UNUSED
MEM_STAT_DECL)
{
return ggc_alloc_stat (size PASS_MEM_STAT);
}
/* Allocate a chunk of memory of SIZE bytes. Its contents are undefined. */
void *
@ -2119,7 +2107,8 @@ init_ggc_pch (void)
void
ggc_pch_count_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED,
size_t size, bool is_string ATTRIBUTE_UNUSED)
size_t size, bool is_string ATTRIBUTE_UNUSED,
enum gt_types_enum type ATTRIBUTE_UNUSED)
{
unsigned order;
@ -2162,7 +2151,8 @@ ggc_pch_this_base (struct ggc_pch_data *d, void *base)
char *
ggc_pch_alloc_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED,
size_t size, bool is_string ATTRIBUTE_UNUSED)
size_t size, bool is_string ATTRIBUTE_UNUSED,
enum gt_types_enum type ATTRIBUTE_UNUSED)
{
unsigned order;
char *result;

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,8 @@ typedef void (*gt_handle_reorder) (void *, void *, gt_pointer_operator,
void *);
/* Used by the gt_pch_n_* routines. Register an object in the hash table. */
extern int gt_pch_note_object (void *, void *, gt_note_pointers);
extern int gt_pch_note_object (void *, void *, gt_note_pointers,
enum gt_types_enum);
/* Used by the gt_pch_n_* routines. Register that an object has a reorder
function. */
@ -169,9 +170,10 @@ extern struct ggc_pch_data *init_ggc_pch (void);
/* The second parameter and third parameters give the address and size
of an object. Update the ggc_pch_data structure with as much of
that information as is necessary. The last argument should be true
that information as is necessary. The bool argument should be true
if the object is a string. */
extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool);
extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool,
enum gt_types_enum);
/* Return the total size of the data to be written to hold all
the objects previously passed to ggc_pch_count_object. */
@ -183,8 +185,9 @@ extern void ggc_pch_this_base (struct ggc_pch_data *, void *);
/* Assuming that the objects really do end up at the address
passed to ggc_pch_this_base, return the address of this object.
The last argument should be true if the object is a string. */
extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool);
The bool argument should be true if the object is a string. */
extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool,
enum gt_types_enum);
/* Write out any initial information required. */
extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
@ -203,30 +206,18 @@ extern void ggc_pch_read (FILE *, void *);
/* Allocation. */
/* For single pass garbage. */
extern struct alloc_zone *garbage_zone;
/* For regular rtl allocations. */
extern struct alloc_zone *rtl_zone;
/* For regular tree allocations. */
extern struct alloc_zone *tree_zone;
/* When set, ggc_collect will do collection. */
extern bool ggc_force_collect;
/* The internal primitive. */
extern void *ggc_alloc_stat (size_t MEM_STAT_DECL);
#define ggc_alloc(s) ggc_alloc_stat (s MEM_STAT_INFO)
/* Allocate an object into the specified allocation zone. */
extern void *ggc_alloc_zone_stat (size_t, struct alloc_zone * MEM_STAT_DECL);
#define ggc_alloc_zone(s,z) ggc_alloc_zone_stat (s,z MEM_STAT_INFO)
/* Allocate an object of the specified type and size. */
extern void *ggc_alloc_typed_stat (enum gt_types_enum, size_t MEM_STAT_DECL);
#define ggc_alloc_typed(s,z) ggc_alloc_typed_stat (s,z MEM_STAT_INFO)
/* Like ggc_alloc, but allocates cleared memory. */
extern void *ggc_alloc_cleared_stat (size_t MEM_STAT_DECL);
#define ggc_alloc_cleared(s) ggc_alloc_cleared_stat (s MEM_STAT_INFO)
/* Like ggc_alloc_zone, but allocates cleared memory. */
extern void *ggc_alloc_cleared_zone (size_t, struct alloc_zone * MEM_STAT_DECL);
#define ggc_alloc_cleared_zone(s,z) ggc_alloc_cleared_stat (s,z MEM_STAT_INFO)
/* Resize a block. */
extern void *ggc_realloc_stat (void *, size_t MEM_STAT_DECL);
#define ggc_realloc(s,z) ggc_realloc_stat (s,z MEM_STAT_INFO)
@ -249,11 +240,11 @@ extern void dump_ggc_loc_statistics (void);
#define GGC_NEWVAR(T, S) ((T *) ggc_alloc ((S)))
#define GGC_CNEWVAR(T, S) ((T *) ggc_alloc_cleared ((S)))
#define ggc_alloc_rtvec(NELT) \
((rtvec) ggc_alloc_typed (gt_ggc_e_9rtvec_def, sizeof (struct rtvec_def) \
+ ((NELT) - 1) * sizeof (rtx)))
#define ggc_alloc_rtvec(NELT) \
((rtvec) ggc_alloc_zone (sizeof (struct rtvec_def) + ((NELT) - 1) \
* sizeof (rtx), &rtl_zone))
#define ggc_alloc_tree(LENGTH) ((tree) ggc_alloc_zone (LENGTH, tree_zone))
#define ggc_alloc_tree(LENGTH) ((tree) ggc_alloc_zone (LENGTH, &tree_zone))
#define htab_create_ggc(SIZE, HASH, EQ, DEL) \
htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_calloc, NULL)
@ -309,4 +300,29 @@ extern int ggc_min_expand_heuristic (void);
extern int ggc_min_heapsize_heuristic (void);
extern void init_ggc_heuristics (void);
/* Zone collection. */
#if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
/* For regular rtl allocations. */
extern struct alloc_zone rtl_zone;
/* For regular tree allocations. */
extern struct alloc_zone tree_zone;
/* For IDENTIFIER_NODE allocations. */
extern struct alloc_zone tree_id_zone;
/* Allocate an object into the specified allocation zone. */
extern void *ggc_alloc_zone_stat (size_t, struct alloc_zone * MEM_STAT_DECL);
# define ggc_alloc_zone(s,z) ggc_alloc_zone_stat (s,z MEM_STAT_INFO)
#else
# define ggc_alloc_zone(s, z) ggc_alloc (s)
# ifdef GATHER_STATISTICS
# define ggc_alloc_zone_stat(s, z, n, l, f) ggc_alloc_stat (s, n, l, f)
# else
# define ggc_alloc_zone_stat(s, z) ggc_alloc_stat (s)
# endif
#endif
#endif

View File

@ -174,8 +174,7 @@ rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL)
{
rtx rt;
rt = (rtx) ggc_alloc_typed_stat (gt_ggc_e_7rtx_def,
RTX_SIZE (code) PASS_MEM_STAT);
rt = (rtx) ggc_alloc_zone_stat (RTX_SIZE (code), &rtl_zone PASS_MEM_STAT);
/* We want to clear everything up to the FLD array. Normally, this
is one int, but we don't want to assume that and it isn't very
@ -309,8 +308,8 @@ shallow_copy_rtx_stat (rtx orig MEM_STAT_DECL)
{
rtx copy;
copy = (rtx) ggc_alloc_typed_stat (gt_ggc_e_7rtx_def,
RTX_SIZE (GET_CODE (orig)) PASS_MEM_STAT);
copy = (rtx) ggc_alloc_zone_stat (RTX_SIZE (GET_CODE (orig)),
&rtl_zone PASS_MEM_STAT);
memcpy (copy, orig, RTX_SIZE (GET_CODE (orig)));
return copy;
}

View File

@ -197,7 +197,8 @@ gt_pch_p_S (void *obj ATTRIBUTE_UNUSED, void *x ATTRIBUTE_UNUSED,
void
gt_pch_n_S (const void *x)
{
gt_pch_note_object ((void *)x, (void *)x, &gt_pch_p_S);
gt_pch_note_object ((void *)x, (void *)x, &gt_pch_p_S,
gt_types_enum_last);
}
/* Handle saving and restoring the string pool for PCH. */

View File

@ -341,7 +341,10 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
tree_node_sizes[(int) kind] += length;
#endif
t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
if (code == IDENTIFIER_NODE)
t = ggc_alloc_zone_stat (length, &tree_id_zone PASS_MEM_STAT);
else
t = ggc_alloc_zone_stat (length, &tree_zone PASS_MEM_STAT);
memset (t, 0, length);
@ -425,7 +428,7 @@ copy_node_stat (tree node MEM_STAT_DECL)
gcc_assert (code != STATEMENT_LIST);
length = tree_size (node);
t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
t = ggc_alloc_zone_stat (length, &tree_zone PASS_MEM_STAT);
memcpy (t, node, length);
TREE_CHAIN (t) = 0;
@ -910,7 +913,7 @@ make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL)
tree_node_sizes[(int) binfo_kind] += length;
#endif
t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
t = ggc_alloc_zone_stat (length, &tree_zone PASS_MEM_STAT);
memset (t, 0, offsetof (struct tree_binfo, base_binfos));
@ -935,7 +938,7 @@ make_tree_vec_stat (int len MEM_STAT_DECL)
tree_node_sizes[(int) vec_kind] += length;
#endif
t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
t = ggc_alloc_zone_stat (length, &tree_zone PASS_MEM_STAT);
memset (t, 0, length);
@ -1408,7 +1411,7 @@ tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL)
tree node;
node = ggc_alloc_zone_stat (sizeof (struct tree_list),
tree_zone PASS_MEM_STAT);
&tree_zone PASS_MEM_STAT);
memset (node, 0, sizeof (struct tree_common));
@ -2502,7 +2505,7 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
gcc_assert (TREE_CODE_LENGTH (code) == 1);
t = ggc_alloc_zone_stat (length, tree_zone PASS_MEM_STAT);
t = ggc_alloc_zone_stat (length, &tree_zone PASS_MEM_STAT);
memset (t, 0, sizeof (struct tree_common));