Commit b6f61163 by Daniel Berlin Committed by Daniel Berlin

ggc-zone.c: New file, zone allocating collector.

2003-10-26  Daniel Berlin  <dberlin@dberlin.org>

	* ggc-zone.c:  New file, zone allocating collector.
	* configure: Accept zone option for --with-gc
	* configure.in: Ditto.
	* ggc.h (ggc_pch_count_object): Pass bool indicating
	stringiness. Update all callers.
	(ggc_pch_alloc_object): Ditto.
	(ggc_pch_write_object): Ditto.
	(ggc_alloc_rtx): Use typed allocation, since all RTX's are of a single
	type.
	(ggc_alloc_rtvec): Ditto.
	(ggc_alloc_tree): Use zone allocation, since some things using this macro
	aren't a single typecode.
	* ggc-none.c (ggc_alloc_typed): New function.
	(ggc_alloc_zone): Ditto.
	* ggc-page.c: Ditto on both functions.

From-SVN: r72971
parent 60b6a815
2003-10-26 Daniel Berlin <dberlin@dberlin.org>
* ggc-zone.c: New file, zone allocating collector.
* configure: Accept zone option for --with-gc
* configure.in: Ditto.
* ggc.h (ggc_pch_count_object): Pass bool indicating
stringiness. Update all callers.
(ggc_pch_alloc_object): Ditto.
(ggc_pch_write_object): Ditto.
(ggc_alloc_rtx): Use typed allocation, since all RTX's are of a single
type.
(ggc_alloc_rtvec): Ditto.
(ggc_alloc_tree): Use zone allocation, since some things using this macro
aren't a single typecode.
* ggc-none.c (ggc_alloc_typed): New function.
(ggc_alloc_zone): Ditto.
* ggc-page.c: Ditto on both functions.
2003-10-26 Gunther Nikl <gni@gecko.de>
* config/m68k/m68k.c (m68k_compute_frame_layout): Ensure FPU related
......
......@@ -850,7 +850,7 @@ OBJS-common = \
insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o \
integrate.o intl.o jump.o langhooks.o lcm.o lists.o local-alloc.o \
loop.o optabs.o options.o opts.o params.o postreload.o predict.o \
print-rtl.o print-tree.o value-prof.o \
print-rtl.o print-tree.o value-prof.o \
profile.o ra.o ra-build.o ra-colorize.o ra-debug.o ra-rewrite.o \
real.o recog.o reg-stack.o regclass.o regmove.o regrename.o \
reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \
......@@ -1462,6 +1462,9 @@ ggc-simple.o: ggc-simple.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H)
ggc-page.o: ggc-page.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
flags.h toplev.h $(GGC_H) $(TIMEVAR_H) $(TM_P_H) $(PARAMS_H)
ggc-zone.o: ggc-zone.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
flags.h toplev.h $(GGC_H) $(TIMEVAR_H) $(TM_P_H) $(PARAMS_H)
stringpool.o: stringpool.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(GGC_H) gt-stringpool.h
......
......@@ -83,7 +83,7 @@ ac_help="$ac_help
use KEY instead of GCC version as the last portion
of the registry key"
ac_help="$ac_help
--with-gc={simple,page} choose the garbage collection mechanism to use
--with-gc={simple,page,zone} choose the garbage collection mechanism to use
with the compiler"
ac_help="$ac_help
--with-system-zlib use installed libz"
......@@ -7609,7 +7609,7 @@ fi
if test "${with_gc+set}" = set; then
withval="$with_gc"
case "$withval" in
simple | page)
simple | page | zone)
GGC=ggc-$withval
;;
*)
......
......@@ -2695,10 +2695,10 @@ AC_SUBST(gthread_flags)
# Find out what GC implementation we want, or may, use.
AC_ARG_WITH(gc,
[ --with-gc={simple,page} choose the garbage collection mechanism to use
[ --with-gc={simple,page,zone} choose the garbage collection mechanism to use
with the compiler],
[case "$withval" in
simple | page)
simple | page | zone)
GGC=ggc-$withval
;;
*)
......
......@@ -328,7 +328,7 @@ 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);
ggc_pch_count_object (state->d, d->obj, d->size, d->note_ptr_fn == gt_pch_p_S);
state->count++;
return 1;
}
......@@ -339,7 +339,7 @@ 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->new_addr = ggc_pch_alloc_object (state->d, d->obj, d->size, d->note_ptr_fn == gt_pch_p_S);
state->ptrs[state->ptrs_i++] = d;
return 1;
}
......@@ -524,7 +524,7 @@ gt_pch_save (FILE *f)
state.ptrs[i]->note_ptr_cookie,
relocate_ptrs, &state);
ggc_pch_write_object (state.d, state.f, state.ptrs[i]->obj,
state.ptrs[i]->new_addr, state.ptrs[i]->size);
state.ptrs[i]->new_addr, state.ptrs[i]->size, state.ptrs[i]->note_ptr_fn == gt_pch_p_S);
if (state.ptrs[i]->note_ptr_fn != gt_pch_p_S)
memcpy (state.ptrs[i]->obj, this_object, state.ptrs[i]->size);
}
......
......@@ -28,6 +28,14 @@
#include "coretypes.h"
#include "tm.h"
#include "ggc.h"
struct alloc_zone *rtl_zone = NULL;
struct alloc_zone *garbage_zone = NULL;
void *
ggc_alloc_typed (enum gt_types_enum gte ATTRIBUTE_UNUSED, size_t size)
{
return xmalloc (size);
}
void *
ggc_alloc (size_t size)
......@@ -36,6 +44,12 @@ ggc_alloc (size_t size)
}
void *
ggc_alloc_zone (size_t size, struct alloc_zone *zone ATTRIBUTE_UNUSED)
{
return xmalloc (size);
}
void *
ggc_alloc_cleared (size_t size)
{
return xcalloc (size, 1);
......
......@@ -469,7 +469,10 @@ static void poison_pages (void);
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. */
inline static void
......@@ -1021,6 +1024,22 @@ static unsigned char size_lookup[257] =
8
};
/* Typed allocation function. Does nothing special in this collector. */
void *
ggc_alloc_typed (enum gt_types_enum type ATTRIBUTE_UNUSED, size_t size)
{
return ggc_alloc (size);
}
/* Zone allocation function. Does nothing special in this collector. */
void *
ggc_alloc_zone (size_t size, struct alloc_zone *zone ATTRIBUTE_UNUSED)
{
return ggc_alloc (size);
}
/* Allocate a chunk of memory of SIZE bytes. Its contents are undefined. */
void *
......@@ -1894,7 +1913,7 @@ init_ggc_pch (void)
void
ggc_pch_count_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED,
size_t size)
size_t size, bool is_string ATTRIBUTE_UNUSED)
{
unsigned order;
......@@ -1937,7 +1956,7 @@ 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)
size_t size, bool is_string ATTRIBUTE_UNUSED)
{
unsigned order;
char *result;
......@@ -1966,7 +1985,7 @@ ggc_pch_prepare_write (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
void
ggc_pch_write_object (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
FILE *f, void *x, void *newx ATTRIBUTE_UNUSED,
size_t size)
size_t size, bool is_string ATTRIBUTE_UNUSED)
{
unsigned order;
static const char emptyBytes[256];
......
This diff is collapsed. Click to expand it.
......@@ -159,8 +159,9 @@ 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. */
extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t);
that information as is necessary. The last argument should be true
if the object is a string. */
extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool);
/* Return the total size of the data to be written to hold all
the objects previously passed to ggc_pch_count_object. */
......@@ -171,14 +172,16 @@ extern size_t ggc_pch_total_size (struct ggc_pch_data *);
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. */
extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t);
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);
/* Write out any initial information required. */
extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
/* Write out this object, including any padding. */
/* Write out this object, including any padding. The last argument should be
true if the object is a string. */
extern void ggc_pch_write_object (struct ggc_pch_data *, FILE *, void *,
void *, size_t);
void *, size_t, bool);
/* All objects have been written, write out any final information
required. */
extern void ggc_pch_finish (struct ggc_pch_data *, FILE *);
......@@ -190,22 +193,38 @@ extern void ggc_pch_read (FILE *, void *);
/* Allocation. */
/* Zone structure. */
struct alloc_zone;
/* 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;
/* The internal primitive. */
extern void *ggc_alloc (size_t);
/* Allocate an object into the specified allocation zone. */
extern void *ggc_alloc_zone (size_t, struct alloc_zone *);
/* Allocate an object of the specified type and size. */
extern void *ggc_alloc_typed (enum gt_types_enum, size_t);
/* Like ggc_alloc, but allocates cleared memory. */
extern void *ggc_alloc_cleared (size_t);
/* Like ggc_alloc_zone, but allocates cleared memory. */
extern void *ggc_alloc_cleared_zone (size_t, struct alloc_zone *);
/* Resize a block. */
extern void *ggc_realloc (void *, size_t);
/* Like ggc_alloc_cleared, but performs a multiplication. */
extern void *ggc_calloc (size_t, size_t);
#define ggc_alloc_rtx(CODE) ((rtx) ggc_alloc (RTX_SIZE (CODE)))
#define ggc_alloc_rtx(CODE) \
((rtx) ggc_alloc_typed (gt_ggc_e_7rtx_def, RTX_SIZE (CODE)))
#define ggc_alloc_rtvec(NELT) \
((rtvec) ggc_alloc (sizeof (struct rtvec_def) \
((rtvec) ggc_alloc_typed (gt_ggc_e_9rtvec_def, sizeof (struct rtvec_def) \
+ ((NELT) - 1) * sizeof (rtx)))
#define ggc_alloc_tree(LENGTH) ((tree) ggc_alloc (LENGTH))
#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)
......
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