PATCH for gc roots

Mark Mitchell mark@codesourcery.com
Sat Sep 4 20:53:00 GMT 1999


This patch finishes merging the GC-root marking code from the GC
branch.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Sat Sep  4 20:40:19 1999  Richard Henderson  <rth@cygnus.com>
	                  Bernd Schmidt <bernds@cygnus.co.uk>
	                  Mark Mitchell  <mark@codesourcery.com>

	* Makefile.in (stor-layout.o): Depend on ggc.h.
	(expr.o): Depend on ggc.h.
	(profile.o): Depend on ggc.h.
	* emit-rtl.c (init_emit_once): Add gc roots.
	* expr.c: Include ggc.h.
	(emit_block_move): Add gc roots.
	(clear_storage): Likewise.
	* expr.h (init_stor_layout_once): New function.
	* profile.c: Include ggc.h.
	(init_arc_profiler): profiler_label is a root.
	* scan.c (make_sstring_space): Trust xrealloc to function
	correctly with first parameter NULL.
	* stor-layout.c: Include ggc.h.
	(set_sizetype): Add gc root.
	(init_stor_layout_once): New function.
	* toplev.c (compile_file): Call it.
	
Index: Makefile.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/Makefile.in,v
retrieving revision 1.290
diff -c -p -r1.290 Makefile.in
*** Makefile.in	1999/09/05 02:41:33	1.290
--- Makefile.in	1999/09/05 03:14:44
*************** tree.o : tree.c $(CONFIG_H) system.h $(T
*** 1454,1460 ****
     ggc.h
  print-tree.o : print-tree.c $(CONFIG_H) system.h $(TREE_H)
  stor-layout.o : stor-layout.c $(CONFIG_H) system.h $(TREE_H) flags.h \
!    function.h $(EXPR_H) $(RTL_H) toplev.h
  fold-const.o : fold-const.c $(CONFIG_H) system.h $(TREE_H) flags.h toplev.h \
     $(RTL_H)
  toplev.o : toplev.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) function.h \
--- 1454,1460 ----
     ggc.h
  print-tree.o : print-tree.c $(CONFIG_H) system.h $(TREE_H)
  stor-layout.o : stor-layout.c $(CONFIG_H) system.h $(TREE_H) flags.h \
!    function.h $(EXPR_H) $(RTL_H) toplev.h ggc.h
  fold-const.o : fold-const.c $(CONFIG_H) system.h $(TREE_H) flags.h toplev.h \
     $(RTL_H)
  toplev.o : toplev.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) function.h \
*************** except.o : except.c $(CONFIG_H) system.h
*** 1486,1492 ****
     insn-config.h $(RECOG_H) output.h except.h toplev.h intl.h ggc.h
  expr.o : expr.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h function.h \
     $(REGS_H) insn-flags.h insn-codes.h $(EXPR_H) insn-config.h $(RECOG_H) \
!    output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h except.h
  builtins.o : builtins.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \
     function.h $(REGS_H) insn-flags.h insn-codes.h $(EXPR_H) insn-config.h \
     $(RECOG_H) output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h \
--- 1486,1493 ----
     insn-config.h $(RECOG_H) output.h except.h toplev.h intl.h ggc.h
  expr.o : expr.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h function.h \
     $(REGS_H) insn-flags.h insn-codes.h $(EXPR_H) insn-config.h $(RECOG_H) \
!    output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h except.h \
!    ggc.h
  builtins.o : builtins.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \
     function.h $(REGS_H) insn-flags.h insn-codes.h $(EXPR_H) insn-config.h \
     $(RECOG_H) output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h \
*************** resource.o : resource.c $(CONFIG_H) $(RT
*** 1541,1547 ****
  lcm.o : lcm.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) hard-reg-set.h flags.h \
     real.h insn-config.h $(RECOG_H) $(EXPR_H) $(BASIC_BLOCK_H)
  profile.o : profile.c $(CONFIG_H) system.h $(RTL_H) flags.h insn-flags.h \
!    gcov-io.h $(TREE_H) output.h $(REGS_H) toplev.h function.h insn-config.h
  loop.o : loop.c $(CONFIG_H) system.h $(RTL_H) flags.h loop.h insn-config.h \
     insn-flags.h $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) real.h \
     function.h toplev.h varray.h
--- 1542,1549 ----
  lcm.o : lcm.c $(CONFIG_H) system.h $(RTL_H) $(REGS_H) hard-reg-set.h flags.h \
     real.h insn-config.h $(RECOG_H) $(EXPR_H) $(BASIC_BLOCK_H)
  profile.o : profile.c $(CONFIG_H) system.h $(RTL_H) flags.h insn-flags.h \
!    gcov-io.h $(TREE_H) output.h $(REGS_H) toplev.h function.h insn-config.h \
!    ggc.h
  loop.o : loop.c $(CONFIG_H) system.h $(RTL_H) flags.h loop.h insn-config.h \
     insn-flags.h $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) real.h \
     function.h toplev.h varray.h
Index: emit-rtl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/emit-rtl.c,v
retrieving revision 1.79
diff -c -p -r1.79 emit-rtl.c
*** emit-rtl.c	1999/09/05 02:41:33	1.79
--- emit-rtl.c	1999/09/05 03:14:46
*************** init_emit_once (line_numbers)
*** 3685,3690 ****
--- 3685,3699 ----
       init_function_start.  */
    INIT_EXPANDERS;
  #endif
+ 
+   ggc_add_rtx_root (&const_tiny_rtx[0][0], sizeof(const_tiny_rtx)/sizeof(rtx));
+ 
+   ggc_add_rtx_root (&pic_offset_table_rtx, 1);
+   ggc_add_rtx_root (&struct_value_rtx, 1);
+   ggc_add_rtx_root (&struct_value_incoming_rtx, 1);
+   ggc_add_rtx_root (&static_chain_rtx, 1);
+   ggc_add_rtx_root (&static_chain_incoming_rtx, 1);
+   ggc_add_rtx_root (&return_address_pointer_rtx, 1);
  }
  
  /* Query and clear/ restore no_line_numbers.  This is used by the
Index: expr.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/expr.c,v
retrieving revision 1.165
diff -c -p -r1.165 expr.c
*** expr.c	1999/09/02 17:29:19	1.165
--- expr.c	1999/09/05 03:14:52
*************** Boston, MA 02111-1307, USA.  */
*** 40,45 ****
--- 40,46 ----
  #include "typeclass.h"
  #include "defaults.h"
  #include "toplev.h"
+ #include "ggc.h"
  
  #define CEIL(x,y) (((x) + (y) - 1) / (y))
  
*************** emit_block_move (x, y, size, align)
*** 1677,1682 ****
--- 1678,1684 ----
  	  fntype = build_pointer_type (void_type_node);
  	  fntype = build_function_type (fntype, NULL_TREE);
  	  fn = build_decl (FUNCTION_DECL, fn, fntype);
+  	  ggc_add_tree_root (&fn, 1);
  	  DECL_EXTERNAL (fn) = 1;
  	  TREE_PUBLIC (fn) = 1;
  	  DECL_ARTIFICIAL (fn) = 1;
*************** clear_storage (object, size, align)
*** 2451,2456 ****
--- 2453,2459 ----
  	      fntype = build_pointer_type (void_type_node);
  	      fntype = build_function_type (fntype, NULL_TREE);
  	      fn = build_decl (FUNCTION_DECL, fn, fntype);
+ 	      ggc_add_tree_root (&fn, 1);
  	      DECL_EXTERNAL (fn) = 1;
  	      TREE_PUBLIC (fn) = 1;
  	      DECL_ARTIFICIAL (fn) = 1;
Index: expr.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/expr.h,v
retrieving revision 1.44
diff -c -p -r1.44 expr.h
*** expr.h	1999/09/04 22:08:44	1.44
--- expr.h	1999/09/05 03:14:52
*************** extern void init_expr_once PROTO((void))
*** 878,883 ****
--- 878,887 ----
  /* This is run at the start of compiling a function.  */
  extern void init_expr PROTO((void));
  
+ /* This function is run once to initialize stor-layout.c.  */
+ 
+ extern void init_stor_layout_once PROTO((void));
+ 
  /* This is run at the end of compiling a function.  */
  extern void finish_expr_for_function PROTO((void));
  
Index: profile.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/profile.c,v
retrieving revision 1.28
diff -c -p -r1.28 profile.c
*** profile.c	1999/08/09 13:59:47	1.28
--- profile.c	1999/09/05 03:14:54
*************** Boston, MA 02111-1307, USA.  */
*** 54,59 ****
--- 54,60 ----
  #include "output.h"
  #include "gcov-io.h"
  #include "toplev.h"
+ #include "ggc.h"
  
  /* One of these is dynamically created whenever we identify an arc in the
     function.  */
*************** init_arc_profiler ()
*** 1544,1549 ****
--- 1545,1551 ----
    char *name = xmalloc (20);
    ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 2);
    profiler_label = gen_rtx_SYMBOL_REF (Pmode, name);
+   ggc_add_rtx_root (&profiler_label, 1);
  }
  
  /* Output instructions as RTL to increment the arc execution count.  */
Index: scan.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/scan.c,v
retrieving revision 1.7
diff -c -p -r1.7 scan.c
*** scan.c	1999/01/06 20:51:13	1.7
--- scan.c	1999/09/05 03:14:54
*************** make_sstring_space (str, count)
*** 35,44 ****
    if (new_size <= cur_size)
      return;
    
!   if (str->base == NULL)
!     str->base = xmalloc (new_size);
!   else
!     str->base = xrealloc (str->base, new_size);
    str->ptr = str->base + cur_size;
    str->limit = str->base + new_size;
  }
--- 35,41 ----
    if (new_size <= cur_size)
      return;
    
!   str->base = xrealloc (str->base, new_size);
    str->ptr = str->base + cur_size;
    str->limit = str->base + new_size;
  }
Index: stor-layout.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/stor-layout.c,v
retrieving revision 1.29
diff -c -p -r1.29 stor-layout.c
*** stor-layout.c	1999/08/27 07:37:16	1.29
--- stor-layout.c	1999/09/05 03:14:55
*************** Boston, MA 02111-1307, USA.  */
*** 28,33 ****
--- 28,34 ----
  #include "function.h"
  #include "expr.h"
  #include "toplev.h"
+ #include "ggc.h"
  
  #define CEIL(x,y) (((x) + (y) - 1) / (y))
  
*************** set_sizetype (type)
*** 1256,1261 ****
--- 1257,1264 ----
        usizetype = make_unsigned_type (oprecision);
        ubitsizetype = make_unsigned_type (precision);
      }
+ 
+   ggc_add_tree_root ((tree*) &sizetype_tab, sizeof(sizetype_tab)/sizeof(tree));
  }
  
  /* Set the extreme values of TYPE based on its precision in bits,
*************** get_best_mode (bitsize, bitpos, align, l
*** 1386,1389 ****
--- 1389,1400 ----
      }
  
    return mode;
+ }
+ 
+ /* This function is run once to initialize stor-layout.c.  */
+ 
+ void
+ init_stor_layout_once ()
+ {
+   ggc_add_tree_root (&pending_sizes, 1);
  }
Index: toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.207
diff -c -p -r1.207 toplev.c
*** toplev.c	1999/09/05 02:41:34	1.207
--- toplev.c	1999/09/05 03:14:58
*************** compile_file (name)
*** 2936,2941 ****
--- 2936,2942 ----
    init_reload ();
    init_alias_once ();
    init_function_once ();
+   init_stor_layout_once ();
  
    /* The following initialization functions need to generate rtl, so
       provide a dummy function context for them.  */


More information about the Gcc-patches mailing list