Commit 08cee789 by Daniel Jacobowitz Committed by Daniel Jacobowitz

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
parent 69229b81
2005-03-13 Daniel Jacobowitz <dan@codesourcery.com> 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> Joseph S. Myers <joseph@codesourcery.com>
* configure.ac: Check for MIPS TLS. * configure.ac: Check for MIPS TLS.
......
...@@ -333,6 +333,9 @@ void dump_alloc_pool_statistics (void) ...@@ -333,6 +333,9 @@ void dump_alloc_pool_statistics (void)
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
struct output_info info; struct output_info info;
if (!alloc_pool_hash)
return;
fprintf (stderr, "\nAlloc-pool Kind Pools Allocated Peak Leak\n"); fprintf (stderr, "\nAlloc-pool Kind Pools Allocated Peak Leak\n");
fprintf (stderr, "-------------------------------------------------------------\n"); fprintf (stderr, "-------------------------------------------------------------\n");
info.count = 0; info.count = 0;
......
...@@ -79,6 +79,9 @@ ...@@ -79,6 +79,9 @@
this is either `int' or `gid_t'. */ this is either `int' or `gid_t'. */
#undef GETGROUPS_T #undef GETGROUPS_T
/* Define if the zone collector is in use */
#undef GGC_ZONE
/* Define to 1 if you have the `alphasort' function. */ /* Define to 1 if you have the `alphasort' function. */
#undef HAVE_ALPHASORT #undef HAVE_ALPHASORT
......
...@@ -14959,9 +14959,17 @@ fi ...@@ -14959,9 +14959,17 @@ fi
if test "${with_gc+set}" = set; then if test "${with_gc+set}" = set; then
withval="$with_gc" withval="$with_gc"
case "$withval" in case "$withval" in
page | zone) page)
GGC=ggc-$withval 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 { { echo "$as_me:$LINENO: error: $withval is an invalid option to --with-gc" >&5
echo "$as_me: error: $withval is an invalid option to --with-gc" >&2;} echo "$as_me: error: $withval is an invalid option to --with-gc" >&2;}
......
...@@ -3027,9 +3027,13 @@ AC_ARG_WITH(gc, ...@@ -3027,9 +3027,13 @@ AC_ARG_WITH(gc,
[ --with-gc={page,zone} choose the garbage collection mechanism to use [ --with-gc={page,zone} choose the garbage collection mechanism to use
with the compiler], with the compiler],
[case "$withval" in [case "$withval" in
page | zone) page)
GGC=ggc-$withval 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]) AC_MSG_ERROR([$withval is an invalid option to --with-gc])
;; ;;
......
...@@ -1928,6 +1928,21 @@ write_types_process_field (type_p f, const struct walk_type_data *d) ...@@ -1928,6 +1928,21 @@ write_types_process_field (type_p f, const struct walk_type_data *d)
} }
else else
oprintf (d->of, ", gt_%sa_%s", wtd->param_prefix, d->prev_val[0]); 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"); oprintf (d->of, ");\n");
if (d->reorder_fn && wtd->reorder_note_routine) 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, ...@@ -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); oprintf (d.of, ", x, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s); 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");
} }
...@@ -2045,6 +2075,21 @@ write_func_for_structure (type_p orig_s, type_p s, type_p *param, ...@@ -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); oprintf (d.of, ", xlimit, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s); 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");
oprintf (d.of, " xlimit = ("); oprintf (d.of, " xlimit = (");
...@@ -2070,6 +2115,21 @@ write_func_for_structure (type_p orig_s, type_p s, type_p *param, ...@@ -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); oprintf (d.of, ", xprev, gt_%s_", wtd->param_prefix);
output_mangled_typename (d.of, orig_s); 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");
oprintf (d.of, " }\n"); oprintf (d.of, " }\n");
......
...@@ -244,6 +244,7 @@ struct ptr_data ...@@ -244,6 +244,7 @@ struct ptr_data
gt_handle_reorder reorder_fn; gt_handle_reorder reorder_fn;
size_t size; size_t size;
void *new_addr; void *new_addr;
enum gt_types_enum type;
}; };
#define POINTER_HASH(x) (hashval_t)((long)x >> 3) #define POINTER_HASH(x) (hashval_t)((long)x >> 3)
...@@ -252,7 +253,8 @@ struct ptr_data ...@@ -252,7 +253,8 @@ struct ptr_data
int int
gt_pch_note_object (void *obj, void *note_ptr_cookie, 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; struct ptr_data **slot;
...@@ -277,6 +279,7 @@ gt_pch_note_object (void *obj, void *note_ptr_cookie, ...@@ -277,6 +279,7 @@ gt_pch_note_object (void *obj, void *note_ptr_cookie,
(*slot)->size = strlen (obj) + 1; (*slot)->size = strlen (obj) + 1;
else else
(*slot)->size = ggc_get_size (obj); (*slot)->size = ggc_get_size (obj);
(*slot)->type = type;
return 1; return 1;
} }
...@@ -330,7 +333,9 @@ call_count (void **slot, void *state_p) ...@@ -330,7 +333,9 @@ call_count (void **slot, void *state_p)
struct ptr_data *d = (struct ptr_data *)*slot; struct ptr_data *d = (struct ptr_data *)*slot;
struct traversal_state *state = (struct traversal_state *)state_p; 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++; state->count++;
return 1; return 1;
} }
...@@ -341,7 +346,9 @@ call_alloc (void **slot, void *state_p) ...@@ -341,7 +346,9 @@ call_alloc (void **slot, void *state_p)
struct ptr_data *d = (struct ptr_data *)*slot; struct ptr_data *d = (struct ptr_data *)*slot;
struct traversal_state *state = (struct traversal_state *)state_p; 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; state->ptrs[state->ptrs_i++] = d;
return 1; return 1;
} }
...@@ -476,8 +483,6 @@ gt_pch_save (FILE *f) ...@@ -476,8 +483,6 @@ gt_pch_save (FILE *f)
write_pch_globals (gt_ggc_rtab, &state); write_pch_globals (gt_ggc_rtab, &state);
write_pch_globals (gt_pch_cache_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 /* Pad the PCH file so that the mmapped area starts on an allocation
granularity (usually page) boundary. */ granularity (usually page) boundary. */
{ {
...@@ -496,6 +501,8 @@ gt_pch_save (FILE *f) ...@@ -496,6 +501,8 @@ gt_pch_save (FILE *f)
&& fseek (state.f, mmi.offset, SEEK_SET) != 0) && fseek (state.f, mmi.offset, SEEK_SET) != 0)
fatal_error ("can't write padding to PCH file: %m"); fatal_error ("can't write padding to PCH file: %m");
ggc_pch_prepare_write (state.d, state.f);
/* Actually write out the objects. */ /* Actually write out the objects. */
for (i = 0; i < state.count; i++) for (i = 0; i < state.count; i++)
{ {
......
...@@ -33,9 +33,6 @@ ...@@ -33,9 +33,6 @@
#include "coretypes.h" #include "coretypes.h"
#include "ggc.h" #include "ggc.h"
struct alloc_zone *rtl_zone = NULL;
struct alloc_zone *garbage_zone = NULL;
void * void *
ggc_alloc_typed_stat (enum gt_types_enum ARG_UNUSED (gte), size_t size ggc_alloc_typed_stat (enum gt_types_enum ARG_UNUSED (gte), size_t size
MEM_STAT_DECL) MEM_STAT_DECL)
...@@ -50,13 +47,6 @@ ggc_alloc_stat (size_t size MEM_STAT_DECL) ...@@ -50,13 +47,6 @@ ggc_alloc_stat (size_t size MEM_STAT_DECL)
} }
void * 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) ggc_alloc_cleared_stat (size_t size MEM_STAT_DECL)
{ {
return xcalloc (size, 1); return xcalloc (size, 1);
......
...@@ -495,9 +495,6 @@ static void move_ptes_to_front (int, int); ...@@ -495,9 +495,6 @@ static void move_ptes_to_front (int, int);
void debug_print_page_list (int); void debug_print_page_list (int);
static void push_depth (unsigned int); static void push_depth (unsigned int);
static void push_by_depth (page_entry *, unsigned long *); 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. */ /* Push an entry onto G.depth. */
...@@ -1052,15 +1049,6 @@ ggc_alloc_typed_stat (enum gt_types_enum type ATTRIBUTE_UNUSED, size_t size ...@@ -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); 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. */ /* Allocate a chunk of memory of SIZE bytes. Its contents are undefined. */
void * void *
...@@ -2119,7 +2107,8 @@ init_ggc_pch (void) ...@@ -2119,7 +2107,8 @@ init_ggc_pch (void)
void void
ggc_pch_count_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED, 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; unsigned order;
...@@ -2162,7 +2151,8 @@ ggc_pch_this_base (struct ggc_pch_data *d, void *base) ...@@ -2162,7 +2151,8 @@ ggc_pch_this_base (struct ggc_pch_data *d, void *base)
char * char *
ggc_pch_alloc_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED, 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; unsigned order;
char *result; char *result;
......
...@@ -54,7 +54,8 @@ typedef void (*gt_handle_reorder) (void *, void *, gt_pointer_operator, ...@@ -54,7 +54,8 @@ typedef void (*gt_handle_reorder) (void *, void *, gt_pointer_operator,
void *); void *);
/* Used by the gt_pch_n_* routines. Register an object in the hash table. */ /* 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 /* Used by the gt_pch_n_* routines. Register that an object has a reorder
function. */ function. */
...@@ -169,9 +170,10 @@ extern struct ggc_pch_data *init_ggc_pch (void); ...@@ -169,9 +170,10 @@ extern struct ggc_pch_data *init_ggc_pch (void);
/* The second parameter and third parameters give the address and size /* The second parameter and third parameters give the address and size
of an object. Update the ggc_pch_data structure with as much of 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. */ 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 /* Return the total size of the data to be written to hold all
the objects previously passed to ggc_pch_count_object. */ the objects previously passed to ggc_pch_count_object. */
...@@ -183,8 +185,9 @@ extern void ggc_pch_this_base (struct ggc_pch_data *, void *); ...@@ -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 /* Assuming that the objects really do end up at the address
passed to ggc_pch_this_base, return the address of this object. passed to ggc_pch_this_base, return the address of this object.
The last argument should be true if the object is a string. */ 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); extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool,
enum gt_types_enum);
/* Write out any initial information required. */ /* Write out any initial information required. */
extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *); extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
...@@ -203,30 +206,18 @@ extern void ggc_pch_read (FILE *, void *); ...@@ -203,30 +206,18 @@ extern void ggc_pch_read (FILE *, void *);
/* Allocation. */ /* 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. */ /* When set, ggc_collect will do collection. */
extern bool ggc_force_collect; extern bool ggc_force_collect;
/* The internal primitive. */ /* The internal primitive. */
extern void *ggc_alloc_stat (size_t MEM_STAT_DECL); extern void *ggc_alloc_stat (size_t MEM_STAT_DECL);
#define ggc_alloc(s) ggc_alloc_stat (s MEM_STAT_INFO) #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. */ /* Allocate an object of the specified type and size. */
extern void *ggc_alloc_typed_stat (enum gt_types_enum, size_t MEM_STAT_DECL); 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) #define ggc_alloc_typed(s,z) ggc_alloc_typed_stat (s,z MEM_STAT_INFO)
/* Like ggc_alloc, but allocates cleared memory. */ /* Like ggc_alloc, but allocates cleared memory. */
extern void *ggc_alloc_cleared_stat (size_t MEM_STAT_DECL); extern void *ggc_alloc_cleared_stat (size_t MEM_STAT_DECL);
#define ggc_alloc_cleared(s) ggc_alloc_cleared_stat (s MEM_STAT_INFO) #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. */ /* Resize a block. */
extern void *ggc_realloc_stat (void *, size_t MEM_STAT_DECL); extern void *ggc_realloc_stat (void *, size_t MEM_STAT_DECL);
#define ggc_realloc(s,z) ggc_realloc_stat (s,z MEM_STAT_INFO) #define ggc_realloc(s,z) ggc_realloc_stat (s,z MEM_STAT_INFO)
...@@ -249,11 +240,11 @@ extern void dump_ggc_loc_statistics (void); ...@@ -249,11 +240,11 @@ extern void dump_ggc_loc_statistics (void);
#define GGC_NEWVAR(T, S) ((T *) ggc_alloc ((S))) #define GGC_NEWVAR(T, S) ((T *) ggc_alloc ((S)))
#define GGC_CNEWVAR(T, S) ((T *) ggc_alloc_cleared ((S))) #define GGC_CNEWVAR(T, S) ((T *) ggc_alloc_cleared ((S)))
#define ggc_alloc_rtvec(NELT) \ #define ggc_alloc_rtvec(NELT) \
((rtvec) ggc_alloc_typed (gt_ggc_e_9rtvec_def, sizeof (struct rtvec_def) \ ((rtvec) ggc_alloc_zone (sizeof (struct rtvec_def) + ((NELT) - 1) \
+ ((NELT) - 1) * sizeof (rtx))) * 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) \ #define htab_create_ggc(SIZE, HASH, EQ, DEL) \
htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_calloc, NULL) htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_calloc, NULL)
...@@ -309,4 +300,29 @@ extern int ggc_min_expand_heuristic (void); ...@@ -309,4 +300,29 @@ extern int ggc_min_expand_heuristic (void);
extern int ggc_min_heapsize_heuristic (void); extern int ggc_min_heapsize_heuristic (void);
extern void init_ggc_heuristics (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 #endif
...@@ -174,8 +174,7 @@ rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL) ...@@ -174,8 +174,7 @@ rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL)
{ {
rtx rt; rtx rt;
rt = (rtx) ggc_alloc_typed_stat (gt_ggc_e_7rtx_def, rt = (rtx) ggc_alloc_zone_stat (RTX_SIZE (code), &rtl_zone PASS_MEM_STAT);
RTX_SIZE (code) PASS_MEM_STAT);
/* We want to clear everything up to the FLD array. Normally, this /* 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 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) ...@@ -309,8 +308,8 @@ shallow_copy_rtx_stat (rtx orig MEM_STAT_DECL)
{ {
rtx copy; rtx copy;
copy = (rtx) ggc_alloc_typed_stat (gt_ggc_e_7rtx_def, copy = (rtx) ggc_alloc_zone_stat (RTX_SIZE (GET_CODE (orig)),
RTX_SIZE (GET_CODE (orig)) PASS_MEM_STAT); &rtl_zone PASS_MEM_STAT);
memcpy (copy, orig, RTX_SIZE (GET_CODE (orig))); memcpy (copy, orig, RTX_SIZE (GET_CODE (orig)));
return copy; return copy;
} }
......
...@@ -197,7 +197,8 @@ gt_pch_p_S (void *obj ATTRIBUTE_UNUSED, void *x ATTRIBUTE_UNUSED, ...@@ -197,7 +197,8 @@ gt_pch_p_S (void *obj ATTRIBUTE_UNUSED, void *x ATTRIBUTE_UNUSED,
void void
gt_pch_n_S (const void *x) 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. */ /* Handle saving and restoring the string pool for PCH. */
......
...@@ -341,7 +341,10 @@ make_node_stat (enum tree_code code MEM_STAT_DECL) ...@@ -341,7 +341,10 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
tree_node_sizes[(int) kind] += length; tree_node_sizes[(int) kind] += length;
#endif #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); memset (t, 0, length);
...@@ -425,7 +428,7 @@ copy_node_stat (tree node MEM_STAT_DECL) ...@@ -425,7 +428,7 @@ copy_node_stat (tree node MEM_STAT_DECL)
gcc_assert (code != STATEMENT_LIST); gcc_assert (code != STATEMENT_LIST);
length = tree_size (node); 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); memcpy (t, node, length);
TREE_CHAIN (t) = 0; TREE_CHAIN (t) = 0;
...@@ -910,7 +913,7 @@ make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL) ...@@ -910,7 +913,7 @@ make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL)
tree_node_sizes[(int) binfo_kind] += length; tree_node_sizes[(int) binfo_kind] += length;
#endif #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)); memset (t, 0, offsetof (struct tree_binfo, base_binfos));
...@@ -935,7 +938,7 @@ make_tree_vec_stat (int len MEM_STAT_DECL) ...@@ -935,7 +938,7 @@ make_tree_vec_stat (int len MEM_STAT_DECL)
tree_node_sizes[(int) vec_kind] += length; tree_node_sizes[(int) vec_kind] += length;
#endif #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); memset (t, 0, length);
...@@ -1408,7 +1411,7 @@ tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL) ...@@ -1408,7 +1411,7 @@ tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL)
tree node; tree node;
node = ggc_alloc_zone_stat (sizeof (struct tree_list), 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)); memset (node, 0, sizeof (struct tree_common));
...@@ -2502,7 +2505,7 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL) ...@@ -2502,7 +2505,7 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
gcc_assert (TREE_CODE_LENGTH (code) == 1); 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)); memset (t, 0, sizeof (struct tree_common));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment