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]

[PCH] Remove remainder of old marking machinery


This patch finally kills ggc_add_root and friends.  Now all marking is
done using gengtype-generated code.

Bootstrapped & tested (without gcac checking!) on x86-linux.

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/pchbranch-noaddroot.patch=================
2002-08-09  Geoffrey Keating  <geoffk@redhat.com>

	* ggc.h: Don't include varray.h.  Rearrange functions to be more
	organized.
	(ggc_add_root): Delete.
	(ggc_mark_rtx): Delete.
	(ggc_mark_tree): Delete.
	(struct ggc_statistics): Remove contents.
	* ggc-common.c: Remove unneeded includes.
	(struct ggc_root): Delete.
	(roots): Delete.
	(ggc_add_root): Delete.
	(ggc_mark_roots): Don't mark `roots'.  Call ggc_mark_stringpool.
	(ggc_print_common_statistics): Remove most of the contents.
	* Makefile.in (GGC_H): No longer uses varray.h.
	(ggc-common.o): Update dependencies.
	(c-parse.o): Add varray.h to dependencies.
	(c-common.o): Add varray.h.
	* stringpool.c (mark_ident): Use mangled name for tree marker routine.
	(mark_ident_hash): Rename to ggc_mark_stringpool.
	(init_stringpool): Don't use ggc_add_root.
	* c-parse.in: Include varray.h.
	* c-common.c: Include varray.h.
	* objc/Make-lang.in (objc-act.o): Add varray.h.
	* objc/objc-act.c: Include varray.h.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.822.2.28
diff -p -u -p -r1.822.2.28 Makefile.in
--- Makefile.in	5 Aug 2002 18:39:54 -0000	1.822.2.28
+++ Makefile.in	9 Aug 2002 20:18:37 -0000
@@ -564,7 +564,7 @@ REGS_H = regs.h varray.h $(MACHMODE_H)
 INTEGRATE_H = integrate.h varray.h
 LOOP_H = loop.h varray.h bitmap.h
 GCC_H = gcc.h version.h
-GGC_H = ggc.h varray.h gtype-desc.h
+GGC_H = ggc.h gtype-desc.h
 TIMEVAR_H = timevar.h timevar.def
 INSN_ATTR_H = insn-attr.h $(srcdir)/insn-addr.h $(srcdir)/varray.h
 C_COMMON_H = c-common.h $(SPLAY_TREE_H) $(CPPLIB_H)
@@ -1150,7 +1150,7 @@ c-errors.o: c-errors.c $(CONFIG_H) $(SYS
     diagnostic.h $(TM_P_H)
 c-parse.o : $(srcdir)/c-parse.c $(CONFIG_H) $(TREE_H) $(GGC_H) intl.h \
     $(C_TREE_H) input.h flags.h $(SYSTEM_H) toplev.h output.h $(CPPLIB_H) \
-    gt-c-parse.h
+    varray.h gt-c-parse.h
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 	       -c $(srcdir)/c-parse.c $(OUTPUT_OPTION)
 
@@ -1236,7 +1236,8 @@ s-under: $(GCC_PASSES)
 c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(OBSTACK_H) \
 	$(C_COMMON_H) flags.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \
 	$(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def $(TARGET_H) \
-	diagnostic.h tree-inline.h except.h gt-c-common.h real.h langhooks.h
+	diagnostic.h tree-inline.h except.h gt-c-common.h real.h langhooks.h \
+	varray.h
 
 # A file used by all variants of C and some other languages.
 
@@ -1328,8 +1329,7 @@ gtype-desc.o: gtype-desc.c $(CONFIG_H) $
 	libfuncs.h debug.h $(GGC_H) bitmap.h $(BASIC_BLOCK_H) hard-reg-set.h \
 	ssa.h cselib.h insn-addr.h
 
-ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) \
-	flags.h $(GGC_H) varray.h $(HASHTAB_H) $(TM_P_H) langhooks.h
+ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) $(GGC_H) $(HASHTAB_H)
 
 ggc-simple.o: ggc-simple.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
 	$(GGC_H) varray.h $(TIMEVAR_H) $(TM_P_H)
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.286.4.9
diff -p -u -p -r1.286.4.9 c-common.c
--- c-common.c	24 Jul 2002 20:08:58 -0000	1.286.4.9
+++ c-common.c	9 Aug 2002 20:18:38 -0000
@@ -29,6 +29,7 @@ Software Foundation, 59 Temple Place - S
 #include "c-pragma.h"
 #include "rtl.h"
 #include "ggc.h"
+#include "varray.h"
 #include "expr.h"
 #include "c-common.h"
 #include "tree-inline.h"
Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.125.4.7
diff -p -u -p -r1.125.4.7 c-parse.in
--- c-parse.in	24 Jul 2002 20:08:59 -0000	1.125.4.7
+++ c-parse.in	9 Aug 2002 20:18:38 -0000
@@ -46,6 +46,7 @@ end ifc
 #include "c-pragma.h"		/* For YYDEBUG definition, and parse_in.  */
 #include "c-tree.h"
 #include "flags.h"
+#include "varray.h"
 #include "output.h"
 #include "toplev.h"
 #include "ggc.h"
Index: ggc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-common.c,v
retrieving revision 1.46.4.20
diff -p -u -p -r1.46.4.20 ggc-common.c
--- ggc-common.c	18 Jul 2002 17:35:37 -0000	1.46.4.20
+++ ggc-common.c	9 Aug 2002 20:18:38 -0000
@@ -23,13 +23,8 @@ Software Foundation, 59 Temple Place - S
 
 #include "config.h"
 #include "system.h"
-#include "rtl.h"
-#include "tree.h"
-#include "tm_p.h"
 #include "hashtab.h"
-#include "varray.h"
 #include "ggc.h"
-#include "langhooks.h"
 
 /* Statistics about the allocation.  */
 static ggc_statistics *ggc_stats;
@@ -38,42 +33,6 @@ static int ggc_htab_delete PARAMS ((void
 
 /* Maintain global roots that are preserved during GC.  */
 
-/* Global roots that are preserved during calls to gc.  */
-
-struct ggc_root
-{
-  struct ggc_root *next;
-  void *base;
-  int nelt;
-  int size;
-  void (*cb) PARAMS ((void *));
-};
-
-static struct ggc_root *roots;
-
-/* Add BASE as a new garbage collection root.  It is an array of
-   length NELT with each element SIZE bytes long.  CB is a
-   function that will be called with a pointer to each element
-   of the array; it is the intention that CB call the appropriate
-   routine to mark gc-able memory for that element.  */
-
-void
-ggc_add_root (base, nelt, size, cb)
-     void *base;
-     int nelt, size;
-     void (*cb) PARAMS ((void *));
-{
-  struct ggc_root *x = (struct ggc_root *) xmalloc (sizeof (*x));
-
-  x->next = roots;
-  x->base = base;
-  x->nelt = nelt;
-  x->size = size;
-  x->cb = cb;
-
-  roots = x;
-}
-
 /* Process a slot of an htab by deleting it if it has not been marked.  */
 
 static int
@@ -112,16 +71,7 @@ ggc_mark_roots ()
       for (i = 0; i < rti->nelt; i++)
 	(*rti->cb)(*(void **)((char *)rti->base + rti->stride * i));
 
-  for (x = roots; x != NULL; x = x->next)
-    {
-      char *elt = x->base;
-      int s = x->size, n = x->nelt;
-      void (*cb) PARAMS ((void *)) = x->cb;
-      int i;
-
-      for (i = 0; i < n; ++i, elt += s)
-	(*cb)(elt);
-    }
+  ggc_mark_stringpool ();
 
   /* Now scan all hash tables that have objects which are to be deleted if
      they are not already marked.  */
@@ -211,57 +161,7 @@ ggc_print_common_statistics (stream, sta
   /* Then do one collection to fill in the statistics.  */
   ggc_collect ();
 
-  /* Total the statistics.  */
-  for (code = 0; code < MAX_TREE_CODES; ++code)
-    {
-      stats->total_num_trees += stats->num_trees[code];
-      stats->total_size_trees += stats->size_trees[code];
-    }
-  for (code = 0; code < NUM_RTX_CODE; ++code)
-    {
-      stats->total_num_rtxs += stats->num_rtxs[code];
-      stats->total_size_rtxs += stats->size_rtxs[code];
-    }
-
-  /* Print the statistics for trees.  */
-  fprintf (stream, "\n%-17s%10s %16s %10s\n", "Tree",
-	   "Number", "Bytes", "% Total");
-  for (code = 0; code < MAX_TREE_CODES; ++code)
-    if (ggc_stats->num_trees[code])
-      {
-	fprintf (stream, "%-17s%10u%16ld%c %10.3f\n",
-		 tree_code_name[code],
-		 ggc_stats->num_trees[code],
-		 SCALE (ggc_stats->size_trees[code]),
-		 LABEL (ggc_stats->size_trees[code]),
-		 (100 * ((double) ggc_stats->size_trees[code])
-		  / ggc_stats->total_size_trees));
-      }
-  fprintf (stream,
-	   "%-17s%10u%16ld%c\n", "Total",
-	   ggc_stats->total_num_trees,
-	   SCALE (ggc_stats->total_size_trees),
-	   LABEL (ggc_stats->total_size_trees));
-
-  /* Print the statistics for RTL.  */
-  fprintf (stream, "\n%-17s%10s %16s %10s\n", "RTX",
-	   "Number", "Bytes", "% Total");
-  for (code = 0; code < NUM_RTX_CODE; ++code)
-    if (ggc_stats->num_rtxs[code])
-      {
-	fprintf (stream, "%-17s%10u%16ld%c %10.3f\n",
-		 rtx_name[code],
-		 ggc_stats->num_rtxs[code],
-		 SCALE (ggc_stats->size_rtxs[code]),
-		 LABEL (ggc_stats->size_rtxs[code]),
-		 (100 * ((double) ggc_stats->size_rtxs[code])
-		  / ggc_stats->total_size_rtxs));
-      }
-  fprintf (stream,
-	   "%-17s%10u%16ld%c\n", "Total",
-	   ggc_stats->total_num_rtxs,
-	   SCALE (ggc_stats->total_size_rtxs),
-	   LABEL (ggc_stats->total_size_rtxs));
+  /* At present, we don't really gather any interesting statistics.  */
 
   /* Don't gather statistics any more.  */
   ggc_stats = NULL;
Index: ggc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc.h,v
retrieving revision 1.39.6.20
diff -p -u -p -r1.39.6.20 ggc.h
--- ggc.h	18 Jul 2002 17:35:38 -0000	1.39.6.20
+++ ggc.h	9 Aug 2002 20:18:38 -0000
@@ -18,7 +18,6 @@ along with GCC; see the file COPYING.  I
 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
-#include "varray.h"
 #include "gtype-desc.h"
 
 /* Symbols are marked with `ggc' for `gcc gc' so as not to interfere with
@@ -29,10 +28,8 @@ extern const char empty_string[];	/* emp
 extern const char digit_vector[];	/* "0" .. "9" */
 #define digit_string(d) (digit_vector + ((d) * 2))
 
-/* Manipulate global roots that are needed between calls to gc.  
-   THIS ROUTINE IS OBSOLETE, do not use it for new code.  */
-extern void ggc_add_root		PARAMS ((void *base, int nelt,
-						 int size, void (*)(void *)));
+/* Internal GGC functions and data structures used by the marking
+   machinery.  */
 
 /* Structures for the easy way to mark roots.
    In an array, terminated by having base == NULL.*/
@@ -60,16 +57,11 @@ struct ggc_cache_tab {
 /* Pointers to arrays of ggc_cache_tab, terminated by NULL.  */
 extern const struct ggc_cache_tab * const gt_ggc_cache_rtab[];
 
-extern void ggc_mark_roots		PARAMS ((void));
-
 /* If EXPR is not NULL and previously unmarked, mark it and evaluate
    to true.  Otherwise evaluate to false.  */
 #define ggc_test_and_set_mark(EXPR) \
   ((EXPR) != NULL && ((void *) (EXPR)) != (void *) 1 && ! ggc_set_mark (EXPR))
 
-#define ggc_mark_rtx gt_ggc_m_7rtx_def
-#define ggc_mark_tree gt_ggc_m_9tree_node
-
 #define ggc_mark(EXPR)				\
   do {						\
     const void *const a__ = (EXPR);		\
@@ -77,6 +69,23 @@ extern void ggc_mark_roots		PARAMS ((voi
       ggc_set_mark (a__);			\
   } while (0)
 
+/* Actually set the mark on a particular region of memory, but don't
+   follow pointers.  This function is called by ggc_mark_*.  It
+   returns zero if the object was not previously marked; non-zero if
+   the object was already marked, or if, for any other reason,
+   pointers in this data structure should not be traversed.  */
+extern int ggc_set_mark			PARAMS ((const void *));
+
+/* Return 1 if P has been marked, zero otherwise.
+   P must have been allocated by the GC allocator; it mustn't point to
+   static objects, stack variables, or memory allocated with malloc.  */
+extern int ggc_marked_p			PARAMS ((const void *));
+
+/* Mark the entries in the string pool.  */
+extern void ggc_mark_stringpool PARAMS ((void));
+
+extern void ggc_mark_roots		PARAMS ((void));
+
 /* A GC implementation must provide these functions.  */
 
 /* Initialize the garbage collector.  */
@@ -90,7 +99,7 @@ extern void ggc_push_context	PARAMS ((vo
 /* Finish a GC context.  Any uncollected memory in the new context
    will be merged with the old context.  */
 extern void ggc_pop_context 	PARAMS ((void));
-
+
 /* Allocation.  */
 
 /* The internal primitive.  */
@@ -135,46 +144,18 @@ extern const char *ggc_alloc_string	PARA
    function is called, not during allocations.  */
 extern void ggc_collect			PARAMS ((void));
 
-/* Actually set the mark on a particular region of memory, but don't
-   follow pointers.  This function is called by ggc_mark_*.  It
-   returns zero if the object was not previously marked; non-zero if
-   the object was already marked, or if, for any other reason,
-   pointers in this data structure should not be traversed.  */
-extern int ggc_set_mark			PARAMS ((const void *));
-
-/* Return 1 if P has been marked, zero otherwise.
-   P must have been allocated by the GC allocator; it mustn't point to
-   static objects, stack variables, or memory allocated with malloc.  */
-extern int ggc_marked_p			PARAMS ((const void *));
-
+/* Return the number of bytes allocated at the indicated address.  */
+extern size_t ggc_get_size		PARAMS ((const void *));
+
 /* Statistics.  */
 
 /* This structure contains the statistics common to all collectors.
    Particular collectors can extend this structure.  */
 typedef struct ggc_statistics
 {
-  /* The Ith element is the number of nodes allocated with code I.  */
-  unsigned num_trees[256];
-  /* The Ith element is the number of bytes allocated by nodes with
-     code I.  */
-  size_t size_trees[256];
-  /* The Ith element is the number of nodes allocated with code I.  */
-  unsigned num_rtxs[256];
-  /* The Ith element is the number of bytes allocated by nodes with
-     code I.  */
-  size_t size_rtxs[256];
-  /* The total size of the tree nodes allocated.  */
-  size_t total_size_trees;
-  /* The total size of the RTL nodes allocated.  */
-  size_t total_size_rtxs;
-  /* The total number of tree nodes allocated.  */
-  unsigned total_num_trees;
-  /* The total number of RTL nodes allocated.  */
-  unsigned total_num_rtxs;
+  /* At present, we don't really gather any interesting statistics.  */
+  int unused;
 } ggc_statistics;
-
-/* Return the number of bytes allocated at the indicated address.  */
-extern size_t ggc_get_size		PARAMS ((const void *));
 
 /* Used by the various collectors to gather and print statistics that
    do not depend on the collector in use.  */
Index: stringpool.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stringpool.c,v
retrieving revision 1.14.6.2
diff -p -u -p -r1.14.6.2 stringpool.c
--- stringpool.c	20 May 2002 22:33:59 -0000	1.14.6.2
+++ stringpool.c	9 Aug 2002 20:18:38 -0000
@@ -48,7 +48,6 @@ static struct obstack string_stack;
 
 static hashnode alloc_node PARAMS ((hash_table *));
 static int mark_ident PARAMS ((struct cpp_reader *, hashnode, const PTR));
-static void mark_ident_hash PARAMS ((void *));
 
 /* Initialize the string pool.  */
 void
@@ -58,7 +57,6 @@ init_stringpool ()
   ident_hash = ht_create (14);
   ident_hash->alloc_node = alloc_node;
   gcc_obstack_init (&string_stack);
-  ggc_add_root (&ident_hash, 1, sizeof ident_hash, mark_ident_hash);
 }
 
 /* Allocate a hash node.  */
@@ -158,15 +156,16 @@ mark_ident (pfile, h, v)
      hashnode h;
      const PTR v ATTRIBUTE_UNUSED;
 {
-  ggc_mark_tree (HT_IDENT_TO_GCC_IDENT (h));
+  gt_ggc_m_9tree_node (HT_IDENT_TO_GCC_IDENT (h));
   return 1;
 }
 
-/* Mark all identifiers for GC.  */
+/* Mark the trees hanging off the identifier node for GGC.  These are
+   handled specially (not using gengtype) because of the special
+   treatment for strings.  */
 
-static void
-mark_ident_hash (arg)
-     PTR arg ATTRIBUTE_UNUSED;
+void
+ggc_mark_stringpool ()
 {
   ht_forall (ident_hash, mark_ident, NULL);
 }
Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.123.2.7
diff -p -u -p -r1.123.2.7 objc-act.c
--- objc/objc-act.c	24 Jul 2002 20:10:08 -0000	1.123.2.7
+++ objc/objc-act.c	9 Aug 2002 20:18:40 -0000
@@ -54,6 +54,7 @@ Boston, MA 02111-1307, USA.  */
 #include "output.h"
 #include "toplev.h"
 #include "ggc.h"
+#include "varray.h"
 #include "debug.h"
 #include "target.h"
 #include "diagnostic.h"
============================================================


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