ggc.h (ggc_root): Move to ggc-common.c.
authorAlex Samuel <samuel@codesourcery.com>
Thu, 16 Sep 1999 19:27:01 +0000 (12:27 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 16 Sep 1999 19:27:01 +0000 (12:27 -0700)
Thu Sep 16 11:50:52 1999  Alex Samuel  <samuel@codesourcery.com>

        * ggc.h (ggc_root): Move to ggc-common.c.
        (roots): Remove.
        (ggc_mark_rtx, ggc_mark_tree): Change to macro.
        (ggc_mark_rtvec, ggc_mark_tree_varray): Declare extern.
        (ggc_mark_tree_hash_table, ggc_mark_string, ggc_mark): Likewise.
        (ggc_mark_roots, ggc_mark_rtx_children, ggc_mark_tree_children): New.
        * ggc-common.c (ggc_root): Move from ggc.h.
        (roots): Declare, static.
        (ggc_mark_rtx, ggc_mark_tree): Renamed to...
        (ggc_mark_rtx_children, ggc_mark_tree_children): Don't check for
        null or check/set mark bit.
        (ggc_mark_roots): New.
        * ggc-simple.c (ggc_collect): Call ggc_mark_roots.

From-SVN: r29461

gcc/ChangeLog
gcc/ggc-common.c
gcc/ggc-simple.c
gcc/ggc.h

index 688024c77c48fcb7d0dc19838748cf40cf0686e1..1e19202dabcb2fb625b7c7d65fecbb5a0fd1dc6b 100644 (file)
@@ -1,3 +1,19 @@
+Thu Sep 16 11:50:52 1999  Alex Samuel  <samuel@codesourcery.com>
+
+       * ggc.h (ggc_root): Move to ggc-common.c.
+       (roots): Remove.
+       (ggc_mark_rtx, ggc_mark_tree): Change to macro.
+       (ggc_mark_rtvec, ggc_mark_tree_varray): Declare extern.
+       (ggc_mark_tree_hash_table, ggc_mark_string, ggc_mark): Likewise.
+       (ggc_mark_roots, ggc_mark_rtx_children, ggc_mark_tree_children): New.
+       * ggc-common.c (ggc_root): Move from ggc.h.
+       (roots): Declare, static.
+       (ggc_mark_rtx, ggc_mark_tree): Renamed to...
+       (ggc_mark_rtx_children, ggc_mark_tree_children): Don't check for
+       null or check/set mark bit.
+       (ggc_mark_roots): New.
+       * ggc-simple.c (ggc_collect): Call ggc_mark_roots.
+
 Thu Sep 16 11:37:32 1999  Richard Henderson  <rth@cygnus.com>
 
        * m32r.c: Include toplev.h.
@@ -364,8 +380,8 @@ Tue Sep 14 04:01:46 1999  Loren Rittle  <ljrittle@acm.org>
 
 Tue Sep 14 03:58:44 1999  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
 
-        * configure.in: Add crtbeginS.o, crtendS.o for mips-linux; add 
-        thread support.
+       * configure.in: Add crtbeginS.o, crtendS.o for mips-linux; add 
+       thread support.
        * configure: Rebuilt.
 
 Tue Sep 14 03:47:23 1999  Joel Sherrill <joel@OARcorp.com>
index 30725a28c867048a3f620498ac5e2a8f5cd2b8fe..319623b0c7761b0df7b8d2683d0153de9f92e711 100644 (file)
 
 /* Maintain global roots that are preserved during GC.  */
 
-struct ggc_root *roots;
+/* Global roots that are preserved during calls to gc.  */
+
+struct ggc_root
+{
+  struct ggc_root *next;
+  void *base;
+  int nelt;
+  int size;
+  void (*cb) PROTO ((void *));
+};
+
+static struct ggc_root *roots;
 
 /* Type-correct function to pass to ggc_add_root.  It just forwards
    *ELT (which is an rtx) to ggc_mark_tree_varray.  */
@@ -170,15 +181,29 @@ ggc_del_root (base)
 }
 
 void
-ggc_mark_rtx (r)
+ggc_mark_roots ()
+{
+  struct ggc_root* x;
+  
+  for (x = roots; x != NULL; x = x->next)
+    {
+      char *elt = x->base;
+      int s = x->size, n = x->nelt;
+      void (*cb) PROTO ((void *)) = x->cb;
+      int i;
+
+      for (i = 0; i < n; ++i, elt += s)
+       (*cb)(elt);
+    }
+}
+
+void
+ggc_mark_rtx_children (r)
      rtx r;
 {
   const char *fmt;
   int i;
 
-  if (r == NULL_RTX || ggc_set_mark_rtx (r))
-    return;
-
   /* ??? If (some of) these are really pass-dependant info, do we have
      any right poking our noses in?  */
   switch (GET_CODE (r))
@@ -256,13 +281,9 @@ ggc_mark_rtvec (v)
 }
 
 void
-ggc_mark_tree (t)
+ggc_mark_tree_children (t)
      tree t;
 {
-  /* FIXME what if t == NULL_TREE ? */
-  if (t == NULL || ggc_set_mark_tree (t))
-    return;
-
   /* Bits from common.  */
   ggc_mark_tree (TREE_TYPE (t));
   ggc_mark_tree (TREE_CHAIN (t));
index 8f375d157ac3e731358948fdd8faeae65b871937..3eeb8c38378e01c7200299db1a468daa374d7a13 100644 (file)
@@ -490,7 +490,6 @@ ggc_collect ()
   struct ggc_rtvec *v, **vp;
   struct ggc_tree *t, **tp;
   struct ggc_string *s, **sp;
-  struct ggc_root *x;
   struct ggc_status *gs;
   struct ggc_any *a, **ap;
   int time, n_rtxs, n_trees, n_vecs, n_strings, n_anys;
@@ -521,17 +520,7 @@ ggc_collect ()
        a->magic_mark = GGC_ANY_MAGIC;
     }
 
-  /* Mark through all the roots.  */
-  for (x = roots; x != NULL; x = x->next)
-    {
-      char *elt = x->base;
-      int s = x->size, n = x->nelt;
-      void (*cb) PROTO ((void *)) = x->cb;
-      int i;
-
-      for (i = 0; i < n; ++i, elt += s)
-       (*cb)(elt);
-    }
+  ggc_mark_roots ();
 
   /* Sweep the resulting dead nodes.  */
 
index 20b3bb8771dd128f62dc2c2ef9a741e8db55de40..de43e9e8ab5436bfd12499de0e9ed41a14df1442 100644 (file)
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -42,19 +42,6 @@ union  tree_node;
 struct varasm_status;
 struct varray_head_tag;
 
-/* Global roots that are preserved during calls to gc.  */
-
-struct ggc_root
-{
-  struct ggc_root *next;
-  void *base;
-  int nelt;
-  int size;
-  void (*cb) PROTO ((void *));
-};
-
-extern struct ggc_root *roots;
-
 /* Manipulate global roots that are needed between calls to gc.  */
 void ggc_add_root PROTO ((void *base, int nelt, int size, void (*)(void *)));
 void ggc_add_rtx_root PROTO ((struct rtx_def **, int nelt));
@@ -66,14 +53,29 @@ void ggc_del_root PROTO ((void *base));
 
 /* Mark nodes from the gc_add_root callback.  These functions follow
    pointers to mark other objects too.  */
-void ggc_mark_rtx PROTO ((struct rtx_def *));
-void ggc_mark_rtvec PROTO ((struct rtvec_def *));
-void ggc_mark_tree PROTO ((union tree_node *));
-void ggc_mark_tree_varray PROTO ((struct varray_head_tag *));
-void ggc_mark_tree_hash_table PROTO ((struct hash_table *));
-void ggc_mark_string PROTO ((char *));
-void ggc_mark PROTO ((void *));
-
+extern void ggc_mark_rtvec PROTO ((struct rtvec_def *));
+extern void ggc_mark_tree_varray PROTO ((struct varray_head_tag *));
+extern void ggc_mark_tree_hash_table PROTO ((struct hash_table *));
+extern void ggc_mark_string PROTO ((char *));
+extern void ggc_mark PROTO ((void *));
+extern void ggc_mark_roots PROTO((void));
+
+extern void ggc_mark_rtx_children PROTO ((struct rtx_def *));
+extern void ggc_mark_tree_children PROTO ((union tree_node *));
+
+#define ggc_mark_rtx(RTX_EXPR)                         \
+  do {                                                 \
+    rtx r__ = (RTX_EXPR);                              \
+    if (r__ != NULL && ! ggc_set_mark_rtx (r__))       \
+      ggc_mark_rtx_children (r__);                     \
+  } while (0)
+
+#define ggc_mark_tree(TREE_EXPR)                       \
+  do {                                                 \
+    tree t__ = (TREE_EXPR);                            \
+    if (t__ != NULL && ! ggc_set_mark_tree (t__))      \
+      ggc_mark_tree_children (t__);                    \
+  } while (0)
 
 /* A GC implementation must provide these functions.  */