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]

PATCH: GC marking speedup; GC root reorganization


This patch moves the list of GC root nodes into the file scope of
ggc-common.c.  GC implementations call ggc_mark_roots. 

Also, macro definitions for ggc_mark_rtx and ggc_mark_tree check for
NULL and check whether the node has already been marked before calling
the recursive mark function.

Alex Samuel
CodeSourcery, LLC



This patch moves the list of GC root nodes into the file scope of
ggc-common.c.  GC implementations call ggc_mark_roots. 

Also, macro definitions for ggc_mark_rtx and ggc_mark_tree check for
NULL and check whether the node has already been marked before calling
the recursive mark function.

Alex Samuel
CodeSourcery, LLC



Tue Sep 14 17:32:48 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.
	


Index: ggc.h
===================================================================
RCS file: /cvs/egcs/egcs/gcc/ggc.h,v
retrieving revision 1.11
diff -c -r1.11 ggc.h
*** ggc.h	1999/09/11 19:50:42	1.11
--- ggc.h	1999/09/15 00:40:18
***************
*** 41,59 ****
  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));
--- 41,46 ----
***************
*** 65,78 ****
  
  /* 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 *));
  
  
  /* A GC implementation must provide these functions.  */
  
--- 52,80 ----
  
  /* Mark nodes from the gc_add_root callback.  These functions follow
     pointers to mark other objects too.  */
! 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 { \
!     struct rtx_def *__r = __rtx_expr; \
!     if (__r != NULL && __r != NULL_RTX && ! ggc_set_mark_rtx (__r)) \
!       ggc_mark_rtx_children (__r); \
!   } while (0)
  
+ #define ggc_mark_tree(__tree_expr) \
+   do { \
+     union tree_node *__tr = __tree_expr; \
+     if (__tr != NULL && ! ggc_set_mark_tree (__tr)) \
+       ggc_mark_tree_children (__tr); \
+   } while (0)
  
  /* A GC implementation must provide these functions.  */
  



Index: ggc-common.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/ggc-common.c,v
retrieving revision 1.4
diff -c -r1.4 ggc-common.c
*** ggc-common.c	1999/09/15 23:05:04	1.4
--- ggc-common.c	1999/09/16 18:13:19
***************
*** 32,39 ****
  
  /* Maintain global roots that are preserved during GC.  */
  
! 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.  */
  
--- 32,50 ----
  
  /* 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) 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.  */
  
***************
*** 169,184 ****
    abort();
  }
  
  void
! ggc_mark_rtx (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))
--- 180,209 ----
    abort();
  }
  
+ void
+ 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 (some of) these are really pass-dependant info, do we have
       any right poking our noses in?  */
    switch (GET_CODE (r))
***************
*** 256,268 ****
  }
  
  void
! ggc_mark_tree (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));
--- 281,289 ----
  }
  
  void
! ggc_mark_tree_children (t)
       tree t;
  {
    /* Bits from common.  */
    ggc_mark_tree (TREE_TYPE (t));
    ggc_mark_tree (TREE_CHAIN (t));




Index: ggc-simple.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/ggc-simple.c,v
retrieving revision 1.16
diff -c -r1.16 ggc-simple.c
*** ggc-simple.c	1999/09/12 06:25:44	1.16
--- ggc-simple.c	1999/09/15 00:43:31
***************
*** 486,492 ****
    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;
--- 486,491 ----
***************
*** 517,533 ****
  	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);
!     }
  
    /* Sweep the resulting dead nodes.  */
  
--- 516,522 ----
  	a->magic_mark = GGC_ANY_MAGIC;
      }
  
!   ggc_mark_roots ();
  
    /* Sweep the resulting dead nodes.  */
  


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