This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gc-improv] Finish GGC_NEWVAR, GGC_CNEWVAR, convert zone allocators, reshuffle ggc.h around.


This patch:
1) adds provisions to gengtype to output zoned versions of allocators too.
) Converts all zoned allocator invocation to typed zoned allocator invocations.
) Fix ggc-zone.c for the C++ compilation.
2) If a language specific type in one frontend gets variable_size GTY
option, then its siblings in other frontends should get the same
option too even if they are of fixed size since only one shared set of
allocators is generated for these types.
) Converts ggc_realloc to GGC_RESIZEVEC/GGC_RESIZEVAR. Note that there
is no need for "typed ggc_realloc" as realloc can figure out the type
of the object from its old pointer.
) Reshuffle around definitions in ggc.h: rename ggc_alloc to
ggc_internal_alloc and #define ggc_alloc to it. Use ggc_internal_alloc
where appropriate (such is in gengtype typed alloc macro defs). The
same for cleared for zoned allocators. This is in preparation to
removing ggc_alloc definition altogether.
) rename ggc_alloc_rtvec to ggc_alloc_rtvec_sized (any better ideas
for the name?) to avoid clash with gengtype-generated definition.
) Converts more allocation sites, get rid of GGC_NEWVAR and
GGC_CNEWVAR altogether.

Now it only remains to convert allocator callbacks in hash tables (in
a similar way as it's already done in splay trees) and to convert
allocators in various backends.

The patch was bootstrapped/regtested on x86_64-unknown-linux-gnu in
two different configurations:
--with-gc=page --enable-languages=all,ada,obj-c++
The Ada and obj-c++ testsuites were run but were not
regression-compared against some baseline.
--with-gc=zone

The zone collector has the following regressions against the page
collector. I will take a look but I strongly suspect that it's the
same on trunk.

         FAIL: gcc.dg/pch/macro-4.c -O0 -g -I. (internal compiler error)
         FAIL: gcc.dg/pch/macro-4.c -O0 -g -I. (test for excess errors)
         FAIL: gcc.dg/pch/macro-4.c -O0 -g assembly comparison
         FAIL: gcc.dg/pch/macro-4.c  -O0  -I. (internal compiler error)
         FAIL: gcc.dg/pch/macro-4.c  -O0  -I. (test for excess errors)
         FAIL: gcc.dg/pch/macro-4.c  -O0  assembly comparison
         FAIL: gcc.dg/pch/macro-4.c  -O1  -I. (internal compiler error)
         FAIL: gcc.dg/pch/macro-4.c  -O1  -I. (test for excess errors)
         FAIL: gcc.dg/pch/macro-4.c  -O1  assembly comparison
         FAIL: gcc.dg/pch/macro-4.c  -O2  -I. (internal compiler error)
         FAIL: gcc.dg/pch/macro-4.c  -O2  -I. (test for excess errors)
         FAIL: gcc.dg/pch/macro-4.c  -O2  assembly comparison
         FAIL: gcc.dg/pch/macro-4.c  -O3 -fomit-frame-pointer  -I.
(internal compiler error)
         FAIL: gcc.dg/pch/macro-4.c  -O3 -fomit-frame-pointer  -I.
(test for excess errors)
         FAIL: gcc.dg/pch/macro-4.c  -O3 -fomit-frame-pointer
assembly comparison
         FAIL: gcc.dg/pch/macro-4.c  -O3 -g  -I. (internal compiler error)
         FAIL: gcc.dg/pch/macro-4.c  -O3 -g  -I. (test for excess errors)
         FAIL: gcc.dg/pch/macro-4.c  -O3 -g  assembly comparison
         FAIL: gcc.dg/pch/macro-4.c  -Os  -I. (internal compiler error)
         FAIL: gcc.dg/pch/macro-4.c  -Os  -I. (test for excess errors)
         FAIL: gcc.dg/pch/macro-4.c  -Os  assembly comparison

Commited to gc-improv.

ChangeLog:

2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

	* ggc.h (ggc_alloc_stat): Rename to ggc_internal_alloc_stat.
	(ggc_internal_alloc, ggc_alloc): Redefine.
	(ggc_alloc_cleared_stat): Rename to
	ggc_internal_cleared_alloc_stat.
	(ggc_internal_cleared_alloc, ggc_alloc_cleared): Redefine.
	(GGC_NEW, GGC_CNEW, GGC_RESIZEVEC, GGC_RESIZEVAR): Redefine.
	(GGC_NEWVAR, GGC_CNEWVAR): Remove.
	(ggc_internal_vec_alloc, ggc_internal_cleared_vec_alloc): Redefine.
	(ggc_internal_sized_alloc): Remove.
	(ggc_internal_cleared_sized_alloc): Remove.
	(ggc_internal_vec_sized_alloc): Remove.
	(ggc_internal_cleared_vec_sized_alloc): Remove.
	(ggc_alloc_atomic, ggc_alloc_cleared_atomic): Redefine.
	(ggc_alloc_rtvec): Rename to ggc_alloc_rtvec_sized and redefine.
	(ggc_alloc_zone_stat): Rename to ggc_internal_alloc_zone_stat.
	(ggc_alloc_zone, ggc_alloc_zone_pass_stat): Remove.
	(ggc_internal_cleared_alloc_zone_stat): New.
	(ggc_internal_zone_stat_alloc): Define.
	(ggc_internal_zone_cleared_stat_alloc): Define.
	(ggc_internal_zone_vec_alloc): Define.
	* ggc-none.c (ggc_alloc_stat): Rename to ggc_internal_alloc_stat.
	(ggc_alloc_cleared_stat): Rename to
	ggc_internal_cleared_alloc_stat.
	* ggc-page.c (ggc_alloc_typed_stat): Use ggc_internal_alloc_stat.
	(ggc_alloc_stat): Rename to ggc_internal_alloc_stat.
	* ggc-zone.c (ggc_alloc_zone_stat): Rename to
	ggc_internal_alloc_zone_stat.
	(ggc_internal_cleared_alloc_zone_stat): New.
	(ggc_internal_alloc_zone_pass_stat): Define.
	(ggc_alloc_typed_stat): Use ggc_internal_alloc_zone_pass_stat.
	(ggc_alloc_stat): Rename to ggc_internal_alloc_stat.  Use
	ggc_internal_alloc_zone_pass_stat.
	(ggc_pch_total_size): Change type of i to int.
	* ggc-common.c (ggc_internal_alloc_stat): Rename to
	ggc_internal_cleared_alloc_stat, use ggc_internal_alloc_stat.
	(ggc_realloc_stat): Use ggc_internal_alloc_stat.
	(ggc_calloc): Use ggc_internal_cleared_alloc.
	(ggc_splay_alloc): Use ggc_internal_alloc.
	* gengtype.c (alloc_quantity, alloc_zone): new enumerations.
	(write_typed_alloc_end): Replace argument `is_vector' with
	`quantity'.  Rewrite to support zone allocators.
	(write_typed_struct_alloc_def): Likewise.
	(write_typed_typedef_alloc_def): Likewise.
	(write_typed_alloc_defns): Output zone allocators.
	(write_typed_alloc_defns): Likewise.
	* varray.h (struct varray_head_tag): Add variable_size GTY option.
	* varray.c (varray_init): Use typed GC allocation.
	* rtl.h (struct rtvec_def): add variable_size GTY option.
	* rtl.c (rtvec_alloc): Use ggc_alloc_rtvec_sized.
	* ira.c (fix_reg_equiv_init): Use GGC_RESIZEVEC.
	* c-tree.h (struct lang_type): add variable_size GTY option.
	(struct lang_decl): Likewise.
	* c-decl.c (finish_struct): Pass size to GC allocator.
	(finish_enum): Likewise.
	(c_dup_lang_specific_decl): Likewise.
	* toplev.c (realloc_for_line_map): Use GGC_RESIZEVAR.
	* tree.c (make_node_stat): Convert to typed GC allocation.
	(copy_node_stat): Likewise.
	(make_tree_binfo_stat): Likewise.
	(make_tree_vec_stat): Likewise.
	(tree_cons_stat): Likewise.
	(build1_stat): Likewise.
	(build_vl_exp_stat): Likewise.

ada/ChangeLog:

2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

	* gcc-interface/ada-tree.h (struct lang_type): add variable_size
	GTY option.
	(struct lang_decl): Likewise.
	(SET_TYPE_LANG_SPECIFIC, SET_DECL_LANG_SPECIFIC): Pass size to GC
	allocator.
	* gcc-interface/utils.c (init_gnat_to_gnu): Convert to typed GC
	allocation.
	(init_dummy_type): Likewise.

cp/ChangeLog:

2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

	* cp-tree.h (struct lang_type): add variable_size GTY option.
	(struct lang_decl): Likewise.
	(TYPE_SET_PTRMEMFUNC_TYPE): Pass size to GC allocator.
	* lex.c (retrofit_lang_decl): Convert to typed GC allocation.
	(cxx_dup_lang_specific_decl): Likewise.
	(copy_lang_type): Likewise.
	(cxx_make_type): Likewise.

fortran/ChangeLog:

2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

	* trans.h (struct lang_type): add variable_size GTY option.
	(struct lang_decl): Likewise.
	* trans-decl.c (gfc_allocate_lang_decl): Pass size to GC
	allocator.
	* trans-types.c (gfc_get_nodesc_array_type): Likewise.
	(gfc_get_array_type_bounds): Likewise.

java/ChangeLog:

2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

	* java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Pass
	size to GC allocator.
	(struct lang_dec): add variable_size GTY option.
	(MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Pass size to GC
	allocator.
	(struct lang_type): add variable_size GTY option.
	* decl.c (java_dup_lang_specific_decl): Pass size to GC allocator.
	* class.c (add_method_1): Likewise.

objc/ChangeLog:

2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

	* objc-act.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Pass size to GC
	allocator.
	* objc-act.c (hash_init): Convert to typed GC allocation.

objcp/ChangeLog:

2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

	* objcp/objcp-decl.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Pass size to
	GC allocator.


Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 151010)
+++ gcc/gengtype.c	(working copy)
@@ -3661,47 +3661,64 @@
   return false;
 }

+enum alloc_quantity { single, vector };
+enum alloc_zone { any_zone, specific_zone };
+
 static void
 write_typed_alloc_end (const type_p s, const char * allocator_type,
-		       bool is_vector)
+		       enum alloc_quantity quantity, enum alloc_zone zone)
 {
   bool variable_size = variable_size_p (s);
   const char * type_tag = get_tag_string (s);

   oprintf (header_file, "((%s%s *)", type_tag, s->u.s.tag);
-  oprintf (header_file, "(ggc_internal_%s%salloc (", allocator_type,
-	   (variable_size ? "sized_" : ""));
-  oprintf (header_file, "%s%s", type_tag, s->u.s.tag);
-  oprintf (header_file, "%s", variable_size ? ", SIZE" : "");
-  oprintf (header_file, "%s", is_vector ? ", n" : "");
+  oprintf (header_file, "(ggc_internal_%salloc (", allocator_type);
+  if (zone == specific_zone)
+    oprintf (header_file, "z, ");
+  if (variable_size)
+    oprintf (header_file, "SIZE");
+  else
+    oprintf (header_file, "sizeof (%s%s)", type_tag, s->u.s.tag);
+  if (quantity == vector)
+    oprintf (header_file, ", n");
   oprintf (header_file, ")))\n");
 }

 static void
 write_typed_struct_alloc_def (const type_p s, const char * allocator_type,
-			      bool is_vector)
+			      enum alloc_quantity quantity,
+			      enum alloc_zone zone)
 {
   bool variable_size = variable_size_p (s);
-  bool two_args = variable_size && is_vector;
+  /* I hope svn blame is broken */
+  bool two_args = variable_size && (quantity == vector);
+  bool third_arg = (zone == specific_zone) && (variable_size
+					       || (quantity == vector));

   oprintf (header_file, "#define ggc_alloc_%s%s", allocator_type, s->u.s.tag);
-  oprintf (header_file, "(%s%s%s) ", (variable_size ? "SIZE" : ""),
-	   (two_args ? ", " : ""), (is_vector ? "n" : ""));
-  write_typed_alloc_end (s, allocator_type, is_vector);
+  oprintf (header_file, "(%s%s%s%s%s) ", (variable_size ? "SIZE" : ""),
+	   (two_args ? ", " : ""), ((quantity == vector) ? "n" : ""),
+	   (third_arg ? ", " : ""), (zone == specific_zone ? "z" : ""));
+  write_typed_alloc_end (s, allocator_type, quantity, zone);
 }

 static void
 write_typed_typedef_alloc_def (const pair_p p,
 			       const char * const allocator_type,
-			       bool is_vector)
+			       enum alloc_quantity quantity,
+			       enum alloc_zone zone)
 {
+  bool two_args = (quantity == vector) && (zone == specific_zone);
+
   oprintf (header_file, "#define ggc_alloc_%s%s", allocator_type, p->name);
-  oprintf (header_file, "(%s) ", is_vector ? "n" : "");
+  oprintf (header_file, "(%s%s%s) ", (quantity == vector) ? "n" : "",
+	   (two_args ? ", " : ""), (zone == specific_zone) ? "z" : "");
   /*  FIXME: merge oprintfs below with write_typed_alloc_end or not? */
   oprintf (header_file, "((%s *)", p->name);
   oprintf (header_file, "(ggc_internal_%salloc (", allocator_type);
-  oprintf (header_file, "%s", p->name);
-  oprintf (header_file, "%s", is_vector ? ", n" : "");
+  oprintf (header_file, (zone == specific_zone) ? "z, " : "");
+  oprintf (header_file, "sizeof (%s)", p->name);
+  oprintf (header_file, "%s", (quantity == vector) ? ", n" : "");
   oprintf (header_file, ")))\n");
 }

@@ -3716,10 +3733,14 @@
     {
       if (!USED_BY_TYPED_GC (s))
 	continue;
-      write_typed_struct_alloc_def (s, "", false);
-      write_typed_struct_alloc_def (s, "cleared_", false);
-      write_typed_struct_alloc_def (s, "vec_", true);
-      write_typed_struct_alloc_def (s, "cleared_vec_", true);
+      write_typed_struct_alloc_def (s, "", single, any_zone);
+      write_typed_struct_alloc_def (s, "cleared_", single, any_zone);
+      write_typed_struct_alloc_def (s, "vec_", vector, any_zone);
+      write_typed_struct_alloc_def (s, "cleared_vec_", vector, any_zone);
+      write_typed_struct_alloc_def (s, "zone_stat_", single, specific_zone);
+      write_typed_struct_alloc_def (s, "zone_cleared_stat_", single,
+				    specific_zone);
+      write_typed_struct_alloc_def (s, "zone_vec_", vector, specific_zone);
     }

   oprintf (header_file, "\n/* Allocators for known typedefs.  */\n");
@@ -3728,10 +3749,14 @@
       s = p->type;
       if (!USED_BY_TYPED_GC (s) || (strcmp (p->name, s->u.s.tag) == 0))
 	continue;
-      write_typed_typedef_alloc_def (p, "", false);
-      write_typed_typedef_alloc_def (p, "cleared_", false);
-      write_typed_typedef_alloc_def (p, "vec_", true);
-      write_typed_typedef_alloc_def (p, "cleared_vec_", true);
+      write_typed_typedef_alloc_def (p, "", single, any_zone);
+      write_typed_typedef_alloc_def (p, "cleared_", single, any_zone);
+      write_typed_typedef_alloc_def (p, "vec_", vector, any_zone);
+      write_typed_typedef_alloc_def (p, "cleared_vec_", vector, any_zone);
+      write_typed_typedef_alloc_def (p, "zone_stat_", single, specific_zone);
+      write_typed_typedef_alloc_def (p, "zone_cleared_stat_", single,
+				     specific_zone);
+      write_typed_typedef_alloc_def (p, "zone_vec_", vector, specific_zone);
     }
 }

Index: gcc/java/class.c
===================================================================
--- gcc/java/class.c	(revision 150498)
+++ gcc/java/class.c	(working copy)
@@ -764,7 +764,7 @@
   DECL_CONTEXT (fndecl) = this_class;

   DECL_LANG_SPECIFIC (fndecl)
-    = ggc_alloc_cleared_lang_decl();
+    = ggc_alloc_cleared_lang_decl(sizeof (struct lang_decl));
   DECL_LANG_SPECIFIC (fndecl)->desc = LANG_DECL_FUNC;

   /* Initialize the static initializer test table.  */
Index: gcc/java/decl.c
===================================================================
--- gcc/java/decl.c	(revision 150498)
+++ gcc/java/decl.c	(working copy)
@@ -1708,7 +1708,7 @@
     return;

   lang_decl_size = sizeof (struct lang_decl);
-  x = ggc_alloc_lang_decl();
+  x = ggc_alloc_lang_decl (lang_decl_size);
   memcpy (x, DECL_LANG_SPECIFIC (node), lang_decl_size);
   DECL_LANG_SPECIFIC (node) = x;
 }
Index: gcc/java/ChangeLog.gc-improv
===================================================================
--- gcc/java/ChangeLog.gc-improv	(revision 151010)
+++ gcc/java/ChangeLog.gc-improv	(working copy)
@@ -1,3 +1,14 @@
+2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+	* java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Pass
+	size to GC allocator.
+	(struct lang_dec): add variable_size GTY option.
+	(MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Pass size to GC
+	allocator.
+	(struct lang_type): add variable_size GTY option.
+	* decl.c (java_dup_lang_specific_decl): Pass size to GC allocator.
+	* class.c (add_method_1): Likewise.
+
 2009-08-22  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

 	* jcf.h (union cpool_entry): add GTY option variable_size.
Index: gcc/java/java-tree.h
===================================================================
--- gcc/java/java-tree.h	(revision 150498)
+++ gcc/java/java-tree.h	(working copy)
@@ -758,7 +758,8 @@
 #define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T)			\
   if (DECL_LANG_SPECIFIC (T) == NULL)				\
     {								\
-      DECL_LANG_SPECIFIC ((T)) = ggc_alloc_cleared_lang_decl(); \
+      DECL_LANG_SPECIFIC ((T))					\
+	= ggc_alloc_cleared_lang_decl(sizeof (struct lang_decl));	\
       DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR;		\
     }

@@ -865,7 +866,7 @@

 enum lang_decl_desc {LANG_DECL_FUNC, LANG_DECL_VAR};

-struct GTY(()) lang_decl {
+struct GTY((variable_size)) lang_decl {
   enum lang_decl_desc desc;
   union lang_decl_u
     {
@@ -883,7 +884,7 @@
 #define MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC(T) \
   if (TYPE_LANG_SPECIFIC ((T)) == NULL)		\
      TYPE_LANG_SPECIFIC ((T))			\
-       = ggc_alloc_cleared_lang_type();
+       = ggc_alloc_cleared_lang_type(sizeof (struct lang_type));

 #define TYPE_DUMMY(T)		(TYPE_LANG_SPECIFIC(T)->dummy_class)

@@ -920,7 +921,7 @@
 #define TYPE_REFLECTION_DATASIZE(T)					\
 				(TYPE_LANG_SPECIFIC (T)->reflection_datasize)

-struct GTY(()) lang_type {
+struct GTY((variable_size)) lang_type {
   tree signature;
   struct JCF *jcf;
   struct CPool *cpool;
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 150498)
+++ gcc/tree.c	(working copy)
@@ -838,13 +838,8 @@
   tree_node_sizes[(int) kind] += length;
 #endif

-  if (code == IDENTIFIER_NODE)
-    t = (tree) ggc_alloc_zone_pass_stat (length, &tree_id_zone);
-  else
-    t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
-
-  memset (t, 0, length);
-
+  t = ggc_alloc_zone_cleared_stat_tree_node (length,
+		       (code == IDENTIFIER_NODE) ? &tree_id_zone : &tree_zone);
   TREE_SET_CODE (t, code);

   switch (type)
@@ -931,7 +926,7 @@
   gcc_assert (code != STATEMENT_LIST);

   length = tree_size (node);
-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
+  t = ggc_alloc_zone_stat_tree_node (length, &tree_zone);
   memcpy (t, node, length);

   TREE_CHAIN (t) = 0;
@@ -1525,7 +1520,7 @@
   tree_node_sizes[(int) binfo_kind] += length;
 #endif

-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
+  t = ggc_alloc_zone_stat_tree_node (length, &tree_zone);

   memset (t, 0, offsetof (struct tree_binfo, base_binfos));

@@ -1550,10 +1545,8 @@
   tree_node_sizes[(int) vec_kind] += length;
 #endif

-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
+  t = ggc_alloc_zone_cleared_stat_tree_node (length, &tree_zone);

-  memset (t, 0, length);
-
   TREE_SET_CODE (t, TREE_VEC);
   TREE_VEC_LENGTH (t) = len;

@@ -2057,13 +2050,12 @@
    purpose and value fields are PURPOSE and VALUE
    and whose TREE_CHAIN is CHAIN.  */

-tree
+tree
 tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL)
 {
   tree node;

-  node = (tree) ggc_alloc_zone_pass_stat (sizeof (struct tree_list),
&tree_zone);
-
+  node = ggc_alloc_zone_stat_tree_node (sizeof (struct tree_list), &tree_zone);
   memset (node, 0, sizeof (struct tree_common));

 #ifdef GATHER_STATISTICS
@@ -3549,7 +3541,7 @@

   gcc_assert (TREE_CODE_LENGTH (code) == 1);

-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
+  t = ggc_alloc_zone_stat_tree_node (length, &tree_zone);

   memset (t, 0, sizeof (struct tree_common));

@@ -8497,10 +8489,8 @@
   tree_node_sizes[(int) e_kind] += length;
 #endif

-  t = (tree) ggc_alloc_zone_pass_stat (length, &tree_zone);
+  t = ggc_alloc_zone_cleared_stat_tree_node (length, &tree_zone);

-  memset (t, 0, length);
-
   TREE_SET_CODE (t, code);

   /* Can't use TREE_OPERAND to store the length because if checking is
Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c	(revision 150498)
+++ gcc/objc/objc-act.c	(working copy)
@@ -6845,10 +6845,8 @@
 static void
 hash_init (void)
 {
-  nst_method_hash_list
-    = (hash *) ggc_alloc_cleared (SIZEHASHTABLE * sizeof (hash));
-  cls_method_hash_list
-    = (hash *) ggc_alloc_cleared (SIZEHASHTABLE * sizeof (hash));
+  nst_method_hash_list = ggc_alloc_cleared_vec_hash (SIZEHASHTABLE);
+  cls_method_hash_list = ggc_alloc_cleared_vec_hash (SIZEHASHTABLE);

   /* Initialize the hash table used to hold the constant string objects.  */
   string_htab = htab_create_ggc (31, string_hash,
Index: gcc/objc/objc-act.h
===================================================================
--- gcc/objc/objc-act.h	(revision 150498)
+++ gcc/objc/objc-act.h	(working copy)
@@ -82,7 +82,8 @@
 #define SIZEOF_OBJC_TYPE_LANG_SPECIFIC sizeof (struct lang_type)
 #define ALLOC_OBJC_TYPE_LANG_SPECIFIC(NODE)				\
   do {									\
-    TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_cleared_lang_type();		\
+    TYPE_LANG_SPECIFIC (NODE)						\
+      = ggc_alloc_cleared_lang_type(sizeof (struct lang_type));		\
   } while (0)

 #define TYPE_HAS_OBJC_INFO(TYPE)				\
Index: gcc/objc/ChangeLog.gc-improv
===================================================================
--- gcc/objc/ChangeLog.gc-improv	(revision 150498)
+++ gcc/objc/ChangeLog.gc-improv	(working copy)
@@ -1,3 +1,9 @@
+2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+	* objc-act.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Pass size to GC
+	allocator.
+	* objc-act.c (hash_init): Convert to typed GC allocation.
+
 2009-05-21  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

 	* objc-act.c (objc_volatilize_decl): Use typed GC allocation.
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	(revision 150498)
+++ gcc/toplev.c	(working copy)
@@ -1622,7 +1622,7 @@
 static void *
 realloc_for_line_map (void *ptr, size_t len)
 {
-  return ggc_realloc (ptr, len);
+  return GGC_RESIZEVAR (void, ptr, len);
 }

 /* Initialization of the front end environment, before command line
Index: gcc/objcp/objcp-decl.h
===================================================================
--- gcc/objcp/objcp-decl.h	(revision 150498)
+++ gcc/objcp/objcp-decl.h	(working copy)
@@ -73,8 +73,8 @@
 #undef ALLOC_OBJC_TYPE_LANG_SPECIFIC
 #define ALLOC_OBJC_TYPE_LANG_SPECIFIC(NODE)				\
   do {									\
-    TYPE_LANG_SPECIFIC (NODE) = GGC_CNEWVAR	                        \
-      (struct lang_type, sizeof (struct lang_type_class));		\
+    TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_cleared_lang_type		\
+      (sizeof (struct lang_type_class));		\
     TYPE_LANG_SPECIFIC (NODE)->u.c.h.is_lang_type_class = 1;		\
   } while (0)

Index: gcc/objcp/ChangeLog.gc-improv
===================================================================
--- gcc/objcp/ChangeLog.gc-improv	(revision 0)
+++ gcc/objcp/ChangeLog.gc-improv	(revision 0)
@@ -0,0 +1,4 @@
+2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+	* objcp/objcp-decl.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Pass size to
+	GC allocator.
Index: gcc/cp/ChangeLog.gc-improv
===================================================================
--- gcc/cp/ChangeLog.gc-improv	(revision 151010)
+++ gcc/cp/ChangeLog.gc-improv	(working copy)
@@ -1,7 +1,17 @@
+2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+	* cp-tree.h (struct lang_type): add variable_size GTY option.
+	(struct lang_decl): Likewise.
+	(TYPE_SET_PTRMEMFUNC_TYPE): Pass size to GC allocator.
+	* lex.c (retrofit_lang_decl): Convert to typed GC allocation.
+	(cxx_dup_lang_specific_decl): Likewise.
+	(copy_lang_type): Likewise.
+	(cxx_make_type): Likewise.
+
 2009-08-22  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

-	* cp/class.c (finish_struct_1): Use typed GC allocation.
-	* cp/pt.c (maybe_process_partial_specialization): Likewise.
+	* class.c (finish_struct_1): Use typed GC allocation.
+	* pt.c (maybe_process_partial_specialization): Likewise.
 	(register_specialization): Likewise.
 	(lookup_template_class): Likewise.

Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 150498)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -1166,7 +1166,7 @@
   tree record;
 };

-struct GTY(()) lang_type {
+struct GTY((variable_size)) lang_type {
   union lang_type_u
   {
     struct lang_type_header GTY((skip (""))) h;
@@ -1695,7 +1695,7 @@
    union rather than a struct containing a union as its only field, but
    tree.h declares it as a struct.  */

-struct GTY(()) lang_decl {
+struct GTY((variable_size)) lang_decl {
   union GTY((desc ("%h.base.selector"))) lang_decl_u {
     struct lang_decl_base GTY ((default)) base;
     struct lang_decl_min GTY((tag ("0"))) min;
@@ -3009,8 +3009,8 @@
   do {									\
     if (TYPE_LANG_SPECIFIC (NODE) == NULL)				\
       {									\
-	TYPE_LANG_SPECIFIC (NODE) = GGC_CNEWVAR				\
-	 (struct lang_type, sizeof (struct lang_type_ptrmem));		\
+	TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_cleared_lang_type		\
+	 (sizeof (struct lang_type_ptrmem));				\
 	TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.h.is_lang_type_class = 0;	\
       }									\
     TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.record = (VALUE);		\
Index: gcc/cp/lex.c
===================================================================
--- gcc/cp/lex.c	(revision 150498)
+++ gcc/cp/lex.c	(working copy)
@@ -545,7 +545,7 @@
   else
     gcc_unreachable ();

-  ld = GGC_CNEWVAR (struct lang_decl, size);
+  ld = ggc_alloc_cleared_lang_decl (size);

   ld->u.base.selector = sel;

@@ -586,7 +586,7 @@
   else
     gcc_unreachable ();

-  ld = GGC_NEWVAR (struct lang_decl, size);
+  ld = ggc_alloc_lang_decl (size);
   memcpy (ld, DECL_LANG_SPECIFIC (node), size);
   DECL_LANG_SPECIFIC (node) = ld;

@@ -623,7 +623,7 @@
     size = sizeof (struct lang_type);
   else
     size = sizeof (struct lang_type_ptrmem);
-  lt = GGC_NEWVAR (struct lang_type, size);
+  lt = ggc_alloc_lang_type (size);
   memcpy (lt, TYPE_LANG_SPECIFIC (node), size);
   TYPE_LANG_SPECIFIC (node) = lt;

@@ -654,7 +654,8 @@
   if (RECORD_OR_UNION_CODE_P (code)
       || code == BOUND_TEMPLATE_TEMPLATE_PARM)
     {
-      struct lang_type *pi = ggc_alloc_cleared_lang_type();
+      struct lang_type *pi
+	= ggc_alloc_cleared_lang_type(sizeof (struct lang_type));

       TYPE_LANG_SPECIFIC (t) = pi;
       pi->u.c.h.is_lang_type_class = 1;
Index: gcc/c-tree.h
===================================================================
--- gcc/c-tree.h	(revision 150498)
+++ gcc/c-tree.h	(working copy)
@@ -33,7 +33,7 @@

 /* Language-specific declaration information.  */

-struct GTY(()) lang_decl {
+struct GTY((variable_size)) lang_decl {
   char dummy;
 };

@@ -56,7 +56,7 @@
    and C_RID_YYCODE is the token number wanted by Yacc.  */
 #define C_IS_RESERVED_WORD(ID) TREE_LANG_FLAG_0 (ID)

-struct GTY(()) lang_type {
+struct GTY((variable_size)) lang_type {
   /* In a RECORD_TYPE, a sorted array of the fields of the type.  */
   struct sorted_fields_type * GTY ((reorder ("resort_sorted_fields"))) s;
   /* In an ENUMERAL_TYPE, the min and max values.  */
Index: gcc/ada/gcc-interface/utils.c
===================================================================
--- gcc/ada/gcc-interface/utils.c	(revision 150498)
+++ gcc/ada/gcc-interface/utils.c	(working copy)
@@ -215,8 +215,7 @@
 void
 init_gnat_to_gnu (void)
 {
-  associate_gnat_to_gnu
-    = (tree *) ggc_alloc_cleared (max_gnat_nodes * sizeof (tree));
+  associate_gnat_to_gnu = ggc_alloc_cleared_vec_tree (max_gnat_nodes);
 }

 /* GNAT_ENTITY is a GNAT tree node for an entity.   GNU_DECL is the GCC tree
@@ -266,8 +265,7 @@
 void
 init_dummy_type (void)
 {
-  dummy_node_table
-    = (tree *) ggc_alloc_cleared (max_gnat_nodes * sizeof (tree));
+  dummy_node_table = ggc_alloc_cleared_vec_tree (max_gnat_nodes);
 }

 /* Make a dummy type corresponding to GNAT_TYPE.  */
Index: gcc/ada/gcc-interface/ada-tree.h
===================================================================
--- gcc/ada/gcc-interface/ada-tree.h	(revision 150498)
+++ gcc/ada/gcc-interface/ada-tree.h	(working copy)
@@ -33,8 +33,8 @@
 };

 /* Ada uses the lang_decl and lang_type fields to hold a tree.  */
-struct GTY(()) lang_type { tree t; };
-struct GTY(()) lang_decl { tree t; };
+struct GTY((variable_size)) lang_type { tree t; };
+struct GTY((variable_size)) lang_decl { tree t; };

 /* Macros to get and set the tree in TYPE_LANG_SPECIFIC.  */
 #define GET_TYPE_LANG_SPECIFIC(NODE) \
@@ -44,7 +44,8 @@
 do {						       \
   tree tmp = (X);				       \
   if (!TYPE_LANG_SPECIFIC (NODE))		       \
-    TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_lang_type(); \
+    TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_lang_type    \
+      (sizeof (struct lang_type));		       \
   TYPE_LANG_SPECIFIC (NODE)->t = tmp;		       \
 } while (0)

@@ -56,7 +57,8 @@
 do {						       \
   tree tmp = (X);				       \
   if (!DECL_LANG_SPECIFIC (NODE))		       \
-    DECL_LANG_SPECIFIC (NODE) = ggc_alloc_lang_decl(); \
+    DECL_LANG_SPECIFIC (NODE) = ggc_alloc_lang_decl    \
+      (sizeof (struct lang_decl));		       \
   DECL_LANG_SPECIFIC (NODE)->t = tmp;		       \
 } while (0)

Index: gcc/ada/ChangeLog.gc-improv
===================================================================
--- gcc/ada/ChangeLog.gc-improv	(revision 150498)
+++ gcc/ada/ChangeLog.gc-improv	(working copy)
@@ -1,3 +1,14 @@
+2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+	* gcc-interface/ada-tree.h (struct lang_type): add variable_size
+	GTY option.
+	(struct lang_decl): Likewise.
+	(SET_TYPE_LANG_SPECIFIC, SET_DECL_LANG_SPECIFIC): Pass size to GC
+	allocator.
+	* gcc-interface/utils.c (init_gnat_to_gnu): Convert to typed GC
+	allocation.
+	(init_dummy_type): Likewise.
+
 2009-08-05  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

 	* gcc-interface/trans.c (Attribute_to_gnu): Fix typo.
Index: gcc/c-decl.c
===================================================================
--- gcc/c-decl.c	(revision 151010)
+++ gcc/c-decl.c	(working copy)
@@ -6814,7 +6814,7 @@
 	  ensure that this lives as long as the rest of the struct decl.
 	  All decls in an inline function need to be saved.  */

-	space = ggc_alloc_cleared_lang_type();
+	space = ggc_alloc_cleared_lang_type(sizeof (struct lang_type));
 	space2 = ggc_alloc_sorted_fields_type
 	  (sizeof (struct sorted_fields_type) + len * sizeof (tree));

@@ -7092,7 +7092,7 @@

   /* Record the min/max values so that we can warn about bit-field
      enumerations that are too small for the values.  */
-  lt = ggc_alloc_cleared_lang_type();
+  lt = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
   lt->enum_min = minnode;
   lt->enum_max = maxnode;
   TYPE_LANG_SPECIFIC (enumtype) = lt;
@@ -8146,7 +8146,7 @@
   if (!DECL_LANG_SPECIFIC (decl))
     return;

-  ld = ggc_alloc_lang_decl();
+  ld = ggc_alloc_lang_decl (sizeof (struct lang_decl));
   memcpy (ld, DECL_LANG_SPECIFIC (decl), sizeof (struct lang_decl));
   DECL_LANG_SPECIFIC (decl) = ld;
 }
Index: gcc/fortran/ChangeLog.gc-improv
===================================================================
--- gcc/fortran/ChangeLog.gc-improv	(revision 150498)
+++ gcc/fortran/ChangeLog.gc-improv	(working copy)
@@ -1,3 +1,12 @@
+2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+	* trans.h (struct lang_type): add variable_size GTY option.
+	(struct lang_decl): Likewise.
+	* trans-decl.c (gfc_allocate_lang_decl): Pass size to GC
+	allocator.
+	* trans-types.c (gfc_get_nodesc_array_type): Likewise.
+	(gfc_get_array_type_bounds): Likewise.
+
 2009-05-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

 	* fortran/trans-decl.c (gfc_allocate_lang_decl)
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c	(revision 150498)
+++ gcc/fortran/trans-types.c	(working copy)
@@ -1388,7 +1388,8 @@
   type = make_node (ARRAY_TYPE);

   GFC_ARRAY_TYPE_P (type) = 1;
-  TYPE_LANG_SPECIFIC (type) = ggc_alloc_cleared_lang_type();
+  TYPE_LANG_SPECIFIC (type) = ggc_alloc_cleared_lang_type(sizeof
+							  (struct lang_type));

   known_stride = (packed != PACKED_NO);
   known_offset = 1;
@@ -1617,7 +1618,8 @@
   TYPE_NAME (fat_type) = get_identifier (name);

   GFC_DESCRIPTOR_TYPE_P (fat_type) = 1;
-  TYPE_LANG_SPECIFIC (fat_type) = ggc_alloc_cleared_lang_type();
+  TYPE_LANG_SPECIFIC (fat_type)
+    = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));

   GFC_TYPE_ARRAY_RANK (fat_type) = dimen;
   GFC_TYPE_ARRAY_DTYPE (fat_type) = NULL_TREE;
Index: gcc/fortran/trans.h
===================================================================
--- gcc/fortran/trans.h	(revision 150498)
+++ gcc/fortran/trans.h	(working copy)
@@ -617,7 +617,7 @@
 };

 /* Array types only.  */
-struct GTY(())	lang_type	 {
+struct GTY((variable_size))	lang_type	 {
   int rank;
   enum gfc_array_kind akind;
   tree lbound[GFC_MAX_DIMENSIONS];
@@ -631,7 +631,7 @@
   tree base_decl[2];
 };

-struct GTY(()) lang_decl {
+struct GTY((variable_size)) lang_decl {
   /* Dummy variables.  */
   tree saved_descriptor;
   /* Assigned integer nodes.  Stringlength is the IO format string's length.
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c	(revision 150498)
+++ gcc/fortran/trans-decl.c	(working copy)
@@ -586,7 +586,8 @@
 void
 gfc_allocate_lang_decl (tree decl)
 {
-  DECL_LANG_SPECIFIC (decl) = ggc_alloc_cleared_lang_decl();
+  DECL_LANG_SPECIFIC (decl) = ggc_alloc_cleared_lang_decl(sizeof
+							  (struct lang_decl));
 }

 /* Remember a symbol to generate initialization/cleanup code at function
Index: gcc/ggc.h
===================================================================
--- gcc/ggc.h	(revision 150993)
+++ gcc/ggc.h	(working copy)
@@ -211,18 +211,20 @@
 extern bool ggc_protect_identifiers;

 /* The internal primitive.  */
-extern void *ggc_alloc_stat (size_t MEM_STAT_DECL);
-#define ggc_alloc(s) ggc_alloc_stat (s MEM_STAT_INFO)
+extern void *ggc_internal_alloc_stat (size_t MEM_STAT_DECL);
+#define ggc_internal_alloc(s) ggc_internal_alloc_stat (s MEM_STAT_INFO)
+#define ggc_alloc(s) ggc_internal_alloc(s)
 /* 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)
+/* Allocates cleared memory.  */
+extern void *ggc_internal_cleared_alloc_stat (size_t MEM_STAT_DECL);
+#define ggc_internal_cleared_alloc(s)			\
+  ggc_internal_cleared_alloc_stat (s MEM_STAT_INFO)
+#define ggc_alloc_cleared(s) ggc_internal_cleared_alloc(s)
 /* 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)
-/* Like ggc_alloc_cleared, but performs a multiplication.  */
 extern void *ggc_calloc (size_t, size_t);
 /* Free a block.  To be used when known for certain it's not reachable.  */
 extern void ggc_free (void *);
@@ -233,36 +235,26 @@

 extern void dump_ggc_loc_statistics (bool);

-/* Type-safe, C++-friendly versions of ggc_alloc() and gcc_calloc().  */
-#define GGC_NEW(T)		((T *) ggc_alloc (sizeof (T)))
-#define GGC_CNEW(T)		((T *) ggc_alloc_cleared (sizeof (T)))
-#define GGC_RESIZEVEC(T, P, N)  ((T *) ggc_realloc ((P), (N) * sizeof (T)))
-#define GGC_NEWVAR(T, S)	((T *) ggc_alloc ((S)))
-#define GGC_CNEWVAR(T, S)	((T *) ggc_alloc_cleared ((S)))
-#define GGC_RESIZEVAR(T, P, N)  ((T *) ggc_realloc ((P), (N)))
+/* Type-safe, C++-friendly allocators.  */
+#define GGC_NEW(T)		((T *) ggc_internal_alloc (sizeof (T)))
+#define GGC_CNEW(T)		((T *) ggc_internal_alloc_cleared (sizeof (T)))
+#define GGC_RESIZEVEC(T, P, N)  ((T *) ggc_realloc_stat ((P),	\
+					      (N) * sizeof (T) MEM_STAT_INFO))
+#define GGC_RESIZEVAR(T, P, N)  ((T *) ggc_realloc_stat ((P),	\
+					      (N) MEM_STAT_INFO))

-#define ggc_internal_alloc(T)       GGC_NEW(T)
-#define ggc_internal_cleared_alloc(T) GGC_CNEW(T)
-#define ggc_internal_vec_alloc(T, C)  \
-  ((T *) ggc_alloc ((C) * sizeof(T)))
-#define ggc_internal_cleared_vec_alloc(T, C)	\
-  ((T *) ggc_alloc_cleared ((C) * sizeof(T)))
+#define ggc_internal_vec_alloc(S, C) (ggc_internal_alloc ((C) * S))
+#define ggc_internal_cleared_vec_alloc(S, C)	\
+  (ggc_internal_cleared_alloc ((C) * S))

-#define ggc_internal_sized_alloc(T, S) GGC_NEWVAR(T, S)
-#define ggc_internal_cleared_sized_alloc(T, S) GGC_CNEWVAR(T, S)
-#define ggc_internal_vec_sized_alloc(T, S, C)  ((T *) ggc_alloc ((S) * (C)))
-#define ggc_internal_cleared_vec_sized_alloc(T, S, C) ((T *)	\
-					       (ggc_alloc_cleared ((S) * (C))))
+#define ggc_alloc_atomic(S)  (ggc_internal_alloc (S))
+#define ggc_alloc_cleared_atomic(S) (ggc_internal_cleared_alloc (S))

-#define ggc_alloc_atomic(S)  (ggc_alloc (S))
-#define ggc_alloc_cleared_atomic(S) (ggc_alloc_cleared (S))
+#define ggc_alloc_rtvec_sized(NELT)					   \
+  (ggc_alloc_zone_vec_rtvec_def (sizeof (rtx),				   \
+				 sizeof (struct rtvec_def) + ((NELT) - 1), \
+				 &rtl_zone))

-/* FIXME generated rtvec allocators in gtype-desc.h! ;*/
-#undef ggc_alloc_rtvec
-#define ggc_alloc_rtvec(NELT)						 \
-  ((rtvec) ggc_alloc_zone (sizeof (struct rtvec_def) + ((NELT) - 1)	 \
-			   * sizeof (rtx), &rtl_zone))
-
 #define htab_create_ggc(SIZE, HASH, EQ, DEL) \
   htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_calloc, ggc_free)

@@ -332,13 +324,26 @@
 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)
-# define ggc_alloc_zone_pass_stat(s,z) ggc_alloc_zone_stat (s,z PASS_MEM_STAT)
+extern void *ggc_internal_alloc_zone_stat (size_t,
+					  struct alloc_zone * MEM_STAT_DECL);
+extern void *ggc_internal_cleared_alloc_zone_stat (size_t,
+					  struct alloc_zone * MEM_STAT_DECL);
+
+#define ggc_internal_zone_stat_alloc(z, s) \
+  (ggc_internal_alloc_zone_stat ((s), (z)))
+#define ggc_internal_zone_cleared_stat_alloc(z, s)	\
+  (ggc_internal_cleared_alloc_zone_stat ((s), (z)))
+#define ggc_internal_zone_vec_alloc(z, s, n) \
+  (ggc_internal_alloc_zone_stat ((s) * (n), (z)))
+
 #else

-# define ggc_alloc_zone(s, z) ggc_alloc (s)
-# define ggc_alloc_zone_pass_stat(s, z) ggc_alloc_stat (s PASS_MEM_STAT)
+#define ggc_internal_zone_stat_alloc(z, s) \
+  (ggc_internal_alloc_stat (s))
+#define ggc_internal_zone_cleared_stat_alloc(z, s) \
+  (ggc_internal_cleared_alloc_stat (s))
+#define ggc_internal_zone_vec_alloc(z, s, n) \
+  (ggc_internal_vec_alloc ((s), (n)))

 #endif

Index: gcc/ChangeLog.gc-improv
===================================================================
--- gcc/ChangeLog.gc-improv	(revision 151010)
+++ gcc/ChangeLog.gc-improv	(working copy)
@@ -1,3 +1,69 @@
+2009-08-23  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+	* ggc.h (ggc_alloc_stat): Rename to ggc_internal_alloc_stat.
+	(ggc_internal_alloc, ggc_alloc): Redefine.
+	(ggc_alloc_cleared_stat): Rename to
+	ggc_internal_cleared_alloc_stat.
+	(ggc_internal_cleared_alloc, ggc_alloc_cleared): Redefine.
+	(GGC_NEW, GGC_CNEW, GGC_RESIZEVEC, GGC_RESIZEVAR): Redefine.
+	(GGC_NEWVAR, GGC_CNEWVAR): Remove.
+	(ggc_internal_vec_alloc, ggc_internal_cleared_vec_alloc): Redefine.
+	(ggc_internal_sized_alloc): Remove.
+	(ggc_internal_cleared_sized_alloc): Remove.
+	(ggc_internal_vec_sized_alloc): Remove.
+	(ggc_internal_cleared_vec_sized_alloc): Remove.
+	(ggc_alloc_atomic, ggc_alloc_cleared_atomic): Redefine.
+	(ggc_alloc_rtvec): Rename to ggc_alloc_rtvec_sized and redefine.
+	(ggc_alloc_zone_stat): Rename to ggc_internal_alloc_zone_stat.
+	(ggc_alloc_zone, ggc_alloc_zone_pass_stat): Remove.
+	(ggc_internal_cleared_alloc_zone_stat): New.
+	(ggc_internal_zone_stat_alloc): Define.
+	(ggc_internal_zone_cleared_stat_alloc): Define.
+	(ggc_internal_zone_vec_alloc): Define.
+	* ggc-none.c (ggc_alloc_stat): Rename to ggc_internal_alloc_stat.
+	(ggc_alloc_cleared_stat): Rename to
+	ggc_internal_cleared_alloc_stat.
+	* ggc-page.c (ggc_alloc_typed_stat): Use ggc_internal_alloc_stat.
+	(ggc_alloc_stat): Rename to ggc_internal_alloc_stat.
+	* ggc-zone.c (ggc_alloc_zone_stat): Rename to
+	ggc_internal_alloc_zone_stat.
+	(ggc_internal_cleared_alloc_zone_stat): New.
+	(ggc_internal_alloc_zone_pass_stat): Define.
+	(ggc_alloc_typed_stat): Use ggc_internal_alloc_zone_pass_stat.
+	(ggc_alloc_stat): Rename to ggc_internal_alloc_stat.  Use
+	ggc_internal_alloc_zone_pass_stat.
+	(ggc_pch_total_size): Change type of i to int.
+	* ggc-common.c (ggc_internal_alloc_stat): Rename to
+	ggc_internal_cleared_alloc_stat, use ggc_internal_alloc_stat.
+	(ggc_realloc_stat): Use ggc_internal_alloc_stat.
+	(ggc_calloc): Use ggc_internal_cleared_alloc.
+	(ggc_splay_alloc): Use ggc_internal_alloc.
+	* gengtype.c (alloc_quantity, alloc_zone): new enumerations.
+	(write_typed_alloc_end): Replace argument `is_vector' with
+	`quantity'.  Rewrite to support zone allocators.
+	(write_typed_struct_alloc_def): Likewise.
+	(write_typed_typedef_alloc_def): Likewise.
+	(write_typed_alloc_defns): Output zone allocators.
+	(write_typed_alloc_defns): Likewise.
+	* varray.h (struct varray_head_tag): Add variable_size GTY option.
+	* varray.c (varray_init): Use typed GC allocation.
+	* rtl.h (struct rtvec_def): add variable_size GTY option.
+	* rtl.c (rtvec_alloc): Use ggc_alloc_rtvec_sized.
+	* ira.c (fix_reg_equiv_init): Use GGC_RESIZEVEC.
+	* c-tree.h (struct lang_type): add variable_size GTY option.
+	(struct lang_decl): Likewise.
+	* c-decl.c (finish_struct): Pass size to GC allocator.
+	(finish_enum): Likewise.
+	(c_dup_lang_specific_decl): Likewise.
+	* toplev.c (realloc_for_line_map): Use GGC_RESIZEVAR.
+	* tree.c (make_node_stat): Convert to typed GC allocation.
+	(copy_node_stat): Likewise.
+	(make_tree_binfo_stat): Likewise.
+	(make_tree_vec_stat): Likewise.
+	(tree_cons_stat): Likewise.
+	(build1_stat): Likewise.
+	(build_vl_exp_stat): Likewise.
+
 2009-08-22  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

 	* cgraph.h (cgraph_node_ptr, cgraph_node_set): Remove vector
Index: gcc/ggc-common.c
===================================================================
--- gcc/ggc-common.c	(revision 150498)
+++ gcc/ggc-common.c	(working copy)
@@ -174,9 +174,9 @@

 /* Allocate a block of memory, then clear it.  */
 void *
-ggc_alloc_cleared_stat (size_t size MEM_STAT_DECL)
+ggc_internal_cleared_alloc_stat (size_t size MEM_STAT_DECL)
 {
-  void *buf = ggc_alloc_stat (size PASS_MEM_STAT);
+  void *buf = ggc_internal_alloc_stat (size PASS_MEM_STAT);
   memset (buf, 0, size);
   return buf;
 }
@@ -189,7 +189,7 @@
   size_t old_size;

   if (x == NULL)
-    return ggc_alloc_stat (size PASS_MEM_STAT);
+    return ggc_internal_alloc_stat (size PASS_MEM_STAT);

   old_size = ggc_get_size (x);

@@ -211,7 +211,7 @@
       return x;
     }

-  r = ggc_alloc_stat (size PASS_MEM_STAT);
+  r = ggc_internal_alloc_stat (size PASS_MEM_STAT);

   /* Since ggc_get_size returns the size of the pool, not the size of the
      individually allocated object, we'd access parts of the old object
@@ -227,11 +227,10 @@
   return r;
 }

-/* Like ggc_alloc_cleared, but performs a multiplication.  */
 void *
 ggc_calloc (size_t s1, size_t s2)
 {
-  return ggc_alloc_cleared (s1 * s2);
+  return ggc_internal_cleared_alloc (s1 * s2);
 }

 /* These are for splay_tree_new_ggc.  */
@@ -240,7 +239,7 @@
 		 void *nl)
 {
   gcc_assert (!nl);
-  return ggc_alloc (sz);
+  return ggc_internal_alloc (sz);
 }

 void
Index: gcc/ggc-zone.c
===================================================================
--- gcc/ggc-zone.c	(revision 151010)
+++ gcc/ggc-zone.c	(working copy)
@@ -861,7 +861,7 @@
   zone->bytes_mapped += size;

   /* Pretend we don't have access to the allocated pages.  We'll enable
-     access to smaller pieces of the area in ggc_alloc.  Discard the
+     access to smaller pieces of the area in ggc_internal_alloc.  Discard the
      handle to avoid handle leak.  */
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (page, size));

@@ -1090,8 +1090,8 @@
 /* Allocate a chunk of memory of at least ORIG_SIZE bytes, in ZONE.  */

 void *
-ggc_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone
-		     MEM_STAT_DECL)
+ggc_internal_alloc_zone_stat (size_t orig_size, struct alloc_zone *zone
+			      MEM_STAT_DECL)
 {
   size_t bin;
   size_t csize;
@@ -1353,6 +1353,19 @@
   return result;
 }

+void *
+ggc_internal_cleared_alloc_zone_stat (size_t orig_size,
+				      struct alloc_zone *zone MEM_STAT_DECL)
+{
+  void * result = ggc_internal_alloc_zone_stat (orig_size, zone);
+  memset (result, 0, orig_size);
+  return result;
+}
+
+
+#define ggc_internal_alloc_zone_pass_stat(s,z)			\
+  ggc_internal_alloc_zone_stat (s,z PASS_MEM_STAT)
+
 /* Allocate a SIZE of chunk memory of GTE type, into an appropriate zone
    for that type.  */

@@ -1363,25 +1376,25 @@
   switch (gte)
     {
     case gt_ggc_e_14lang_tree_node:
-      return ggc_alloc_zone_pass_stat (size, &tree_zone);
+      return ggc_internal_alloc_zone_pass_stat (size, &tree_zone);

     case gt_ggc_e_7rtx_def:
-      return ggc_alloc_zone_pass_stat (size, &rtl_zone);
+      return ggc_internal_alloc_zone_pass_stat (size, &rtl_zone);

     case gt_ggc_e_9rtvec_def:
-      return ggc_alloc_zone_pass_stat (size, &rtl_zone);
+      return ggc_internal_alloc_zone_pass_stat (size, &rtl_zone);

     default:
-      return ggc_alloc_zone_pass_stat (size, &main_zone);
+      return ggc_internal_alloc_zone_pass_stat (size, &main_zone);
     }
 }

 /* Normal GC allocation simply allocates into the main zone.  */

 void *
-ggc_alloc_stat (size_t size MEM_STAT_DECL)
+ggc_internal_alloc_stat (size_t size MEM_STAT_DECL)
 {
-  return ggc_alloc_zone_pass_stat (size, &main_zone);
+  return ggc_internal_alloc_zone_pass_stat (size, &main_zone);
 }

 /* Poison the chunk.  */
@@ -2350,7 +2363,7 @@
 size_t
 ggc_pch_total_size (struct ggc_pch_data *d)
 {
-  enum gt_types_enum i;
+  int i;
   size_t alloc_size, total_size;

   total_size = 0;
Index: gcc/ggc-page.c
===================================================================
--- gcc/ggc-page.c	(revision 151010)
+++ gcc/ggc-page.c	(working copy)
@@ -671,7 +671,7 @@
   G.bytes_mapped += size;

   /* Pretend we don't have access to the allocated pages.  We'll enable
-     access to smaller pieces of the area in ggc_alloc.  Discard the
+     access to smaller pieces of the area in ggc_internal_alloc.  Discard the
      handle to avoid handle leak.  */
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (page, size));

@@ -1056,13 +1056,13 @@
 ggc_alloc_typed_stat (enum gt_types_enum type ATTRIBUTE_UNUSED, size_t size
 		      MEM_STAT_DECL)
 {
-  return ggc_alloc_stat (size PASS_MEM_STAT);
+  return ggc_internal_alloc_stat (size PASS_MEM_STAT);
 }

 /* Allocate a chunk of memory of SIZE bytes.  Its contents are undefined.  */

 void *
-ggc_alloc_stat (size_t size MEM_STAT_DECL)
+ggc_internal_alloc_stat (size_t size MEM_STAT_DECL)
 {
   size_t order, word, bit, object_offset, object_size;
   struct page_entry *entry;
Index: gcc/ira.c
===================================================================
--- gcc/ira.c	(revision 150498)
+++ gcc/ira.c	(working copy)
@@ -1742,8 +1742,7 @@

   if (reg_equiv_init_size < max_regno)
     {
-      reg_equiv_init
-	= (rtx *) ggc_realloc (reg_equiv_init, max_regno * sizeof (rtx));
+      reg_equiv_init = GGC_RESIZEVEC (rtx, reg_equiv_init, max_regno);
       while (reg_equiv_init_size < max_regno)
 	reg_equiv_init[reg_equiv_init_size++] = NULL_RTX;
       for (i = FIRST_PSEUDO_REGISTER; i < reg_equiv_init_size; i++)
Index: gcc/rtl.c
===================================================================
--- gcc/rtl.c	(revision 150498)
+++ gcc/rtl.c	(working copy)
@@ -150,7 +150,7 @@
 {
   rtvec rt;

-  rt = ggc_alloc_rtvec (n);
+  rt = ggc_alloc_rtvec_sized (n);
   /* Clear out the vector.  */
   memset (&rt->elem[0], 0, n * sizeof (rtx));

Index: gcc/rtl.h
===================================================================
--- gcc/rtl.h	(revision 150498)
+++ gcc/rtl.h	(working copy)
@@ -354,7 +354,7 @@
    for a variable number of things.  The principle use is inside
    PARALLEL expressions.  */

-struct GTY(()) rtvec_def {
+struct GTY((variable_size)) rtvec_def {
   int num_elem;		/* number of elements */
   rtx GTY ((length ("%h.num_elem"))) elem[1];
 };
Index: gcc/ggc-none.c
===================================================================
--- gcc/ggc-none.c	(revision 150498)
+++ gcc/ggc-none.c	(working copy)
@@ -40,13 +40,13 @@
 }

 void *
-ggc_alloc_stat (size_t size MEM_STAT_DECL)
+ggc_internal_alloc_stat (size_t size MEM_STAT_DECL)
 {
   return xmalloc (size);
 }

 void *
-ggc_alloc_cleared_stat (size_t size MEM_STAT_DECL)
+ggc_internal_cleared_alloc_stat (size_t size MEM_STAT_DECL)
 {
   return xcalloc (size, 1);
 }
Index: gcc/varray.c
===================================================================
--- gcc/varray.c	(revision 150498)
+++ gcc/varray.c	(working copy)
@@ -126,7 +126,7 @@
   desc->allocated += data_size + VARRAY_HDR_SIZE;
 #endif
   if (element[element_kind].uses_ggc)
-    ptr = GGC_CNEWVAR (struct varray_head_tag, VARRAY_HDR_SIZE + data_size);
+    ptr = ggc_alloc_cleared_varray_head_tag (VARRAY_HDR_SIZE + data_size);
   else
     ptr = XCNEWVAR (struct varray_head_tag, VARRAY_HDR_SIZE + data_size);

Index: gcc/varray.h
===================================================================
--- gcc/varray.h	(revision 150498)
+++ gcc/varray.h	(working copy)
@@ -110,7 +110,7 @@
 } varray_data;

 /* Virtual array of pointers header.  */
-struct GTY(()) varray_head_tag {
+struct GTY((variable_size)) varray_head_tag {
   size_t	num_elements;	/* Maximum element number allocated.  */
   size_t        elements_used;  /* The number of elements used, if
 				   using VARRAY_PUSH/VARRAY_POP.  */


-- 
Laurynas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]