This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Summary of patches
> > On Tue, Mar 02, 2004 at 03:16:54PM +0100, Jan Hubicka wrote:
> > > > marked and swept without ever using ggc_alloc (which is not suited to
> > > > resizable data structures) for them.
> > >
> > > I will try to think about this deeper, but it seems to be that we will
> > > just end up with two ggc allocators hooked together. With Richard's
> > > ggc_free patch we can now release the memory explicitely, so I am not
> > > quite sure what is the most sane approach here.
> >
> > I think with ggc_free, ggc_alloc is no worse than malloc here.
> Hi,
> the attached patch make VARRAY_FREE to work on varrays in ggc as well.
> This saves about 3MB of garbage, but more of VARRAY_FREEs are certainly
> possible.
>
> Bootstrapped/regtested i686-pc-gnu-linux, OK?
>
> Honza
>
> 2004-03-05 Jan Hubicka <jh@suse.cz>
> * function.c (reorder_blocks): Use VARRAY_FREE.
> * insn-addr.h (INSN_ADDRESSES_FREE): Use VARRAY_FREE.
> * reg-stack.c (reg_to_stack): Use VARRAY_FREE.
> * tree-inline.c (optimize_inline_calls): Likewise.
> (clone_body): Likewise.
> * cp/mangle.c (finish_mangling): Likewise.
Oops, forgot the varray_free bits themselves
2004-03-05 Jan Hubicka <jh@suse.cz>
* varray.c (varray_free): New function.
* varray.h (varray_free): Declare.
(VARRAY_FREE): Use it.
Index: varray.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varray.c,v
retrieving revision 1.27
diff -c -3 -p -r1.27 varray.c
*** varray.c 25 Jan 2004 03:52:42 -0000 1.27
--- varray.c 4 Mar 2004 23:10:58 -0000
*************** varray_init (size_t num_elements, enum v
*** 136,141 ****
--- 136,151 ----
return ptr;
}
+ /* Free memory used by varray. */
+ void
+ varray_free (varray_type va)
+ {
+ if (element[va->type].uses_ggc)
+ ggc_free (va);
+ else
+ free (va);
+ }
+
/* Grow/shrink the virtual array VA to N elements. Zero any new elements
allocated. */
varray_type
Index: varray.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varray.h,v
retrieving revision 1.35
diff -c -3 -p -r1.35 varray.h
*** varray.h 21 Jan 2004 20:40:04 -0000 1.35
--- varray.h 4 Mar 2004 23:10:58 -0000
*************** typedef struct varray_head_tag *varray_t
*** 144,149 ****
--- 144,151 ----
long, named NAME. Array elements are zeroed. */
extern varray_type varray_init (size_t, enum varray_data_enum, const char *);
+ extern void varray_free (varray_type);
+
#define VARRAY_CHAR_INIT(va, num, name) \
va = varray_init (num, VARRAY_DATA_C, name)
*************** extern varray_type varray_init (size_t,
*** 207,213 ****
/* Free up memory allocated by the virtual array, but do not free any of the
elements involved. */
#define VARRAY_FREE(vp) \
! do { if (vp) { free (vp); vp = (varray_type) 0; } } while (0)
/* Grow/shrink the virtual array VA to N elements. */
extern varray_type varray_grow (varray_type, size_t);
--- 209,215 ----
/* Free up memory allocated by the virtual array, but do not free any of the
elements involved. */
#define VARRAY_FREE(vp) \
! do { if (vp) { varray_free (vp); vp = (varray_type) 0; } } while (0)
/* Grow/shrink the virtual array VA to N elements. */
extern varray_type varray_grow (varray_type, size_t);