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] reduce stack use


The first patch reduces the maximum stack depth from a little under
30000 levels when bootstrapping on x86 to a little over 1000.
Unfortunately, it seems to make marking about 5% slower, almost all of
which is accounted for by adding the first loop added to
gt_ggc_m_rtx_def.  My guess is that the extra time is caused by the
additional overhead in a call to gt_ggc_m_rtx_def and the less
localised memory access pattern.

This patch was bootstrapped & tested on x86-linux with gcac checking.

The second is the patch I used to count stack depth, which I'm
attaching for reference purposes.

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/pchbranch-lessrecursion.patch=============
Index: ChangeLog
2002-08-03  Geoffrey Keating  <geoffk@redhat.com>

	* rtl.h (rtx_next): Declare.
	(struct rtx_def): Add chain_next and chain_prev options.
	(RTX_NEXT): New.
	(RTX_PREV): New.
	* gengtype.c (enum rtx_code): Make global.
	(rtx_format): Make global.
	(rtx_next): New.
	(gen_rtx_next): New.
	(write_rtx_next): New.
	(adjust_field_rtx_def): Skip fields marked by chain_next.
	(open_base_files): Delete redundant prototype.
	(write_enum_defn): New.
	(output_mangled_typename): Correct abort call.
	(write_gc_marker_routine_for_structure): Handle chain_next and
	chain_prev options.
	(finish_root_table): Don't output redundant \n.
	(main): Call gen_rtx_next, write_rtx_next, write_enum_defn.
	* c-tree.h (union lang_tree_node): Add chain_next option.

Index: ada/ChangeLog
2002-08-03  Geoffrey Keating  <geoffk@redhat.com>

	* ada-tree.h (union lang_tree_node): Add chain_next option.

Index: cp/ChangeLog
2002-08-03  Geoffrey Keating  <geoffk@redhat.com>

	* cp-tree.h (union lang_tree_node): Add chain_next option.

Index: f/ChangeLog
2002-08-03  Geoffrey Keating  <geoffk@redhat.com>

	* com.c (union lang_tree_node): Add chain_next option.

Index: java/ChangeLog
2002-08-03  Geoffrey Keating  <geoffk@redhat.com>

	* java-tree.h (union lang_tree_node): Add chain_next option.

Index: c-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v
retrieving revision 1.80.2.12
diff -p -u -p -r1.80.2.12 c-tree.h
--- c-tree.h	24 Jul 2002 20:09:00 -0000	1.80.2.12
+++ c-tree.h	4 Aug 2002 01:19:23 -0000
@@ -48,7 +48,8 @@ struct lang_identifier GTY(())
 /* The resulting tree type.  */
 
 union lang_tree_node 
-  GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE")))
+  GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
+       chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
 {
   union tree_node GTY ((tag ("0"), 
 			desc ("tree_node_structure (&%h)"))) 
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.1.2.30
diff -p -u -p -r1.1.2.30 gengtype.c
--- gengtype.c	24 Jul 2002 20:09:12 -0000	1.1.2.30
+++ gengtype.c	4 Aug 2002 01:19:24 -0000
@@ -26,10 +26,11 @@ Software Foundation, 59 Temple Place - S
 /* Nonzero iff an error has occurred.  */
 static int hit_error = 0;
 
+static void gen_rtx_next PARAMS ((void));
+static void write_rtx_next PARAMS ((void));
 static void open_base_files PARAMS ((void));
 static void close_output_files PARAMS ((void));
 
-
 /* Report an error at POS, printing MSG.  */
 
 void
@@ -333,6 +334,65 @@ note_variable (s, t, o, pos)
   variables = n;
 }
 
+enum rtx_code {
+#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   ENUM ,
+#include "rtl.def"
+#undef DEF_RTL_EXPR
+    NUM_RTX_CODE
+};
+
+/* We really don't care how long a CONST_DOUBLE is.  */
+#define CONST_DOUBLE_FORMAT "ww"
+static const char * const rtx_format[NUM_RTX_CODE] = {
+#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   FORMAT ,
+#include "rtl.def"
+#undef DEF_RTL_EXPR
+};
+
+static char rtx_next[NUM_RTX_CODE];
+
+/* Generate the contents of the rtx_next array.  This really doesn't belong
+   in gengtype at all, but it's needed for adjust_field_rtx_def.  */
+
+static void
+gen_rtx_next ()
+{
+  int i;
+  for (i = 0; i < NUM_RTX_CODE; i++)
+    {
+      int k;
+      
+      rtx_next[i] = -1;
+      if (strncmp (rtx_format[i], "iuu", 3) == 0)
+	rtx_next[i] = 2;
+      else if (i == COND_EXEC || i == SET || i == EXPR_LIST || i == INSN_LIST)
+	rtx_next[i] = 1;
+      else 
+	for (k = strlen (rtx_format[i]) - 1; k >= 0; k--)
+	  if (rtx_format[i][k] == 'e' || rtx_format[i][k] == 'u')
+	    rtx_next[i] = k;
+    }
+}
+
+/* Write out the contents of the rtx_next array.  */
+static void
+write_rtx_next ()
+{
+  outf_p f = get_output_file_with_visibility (NULL);
+  int i;
+  
+  oprintf (f, "\n/* Used to implement the RTX_NEXT macro.  */\n");
+  oprintf (f, "const unsigned char rtx_next[NUM_RTX_CODE] = {\n");
+  for (i = 0; i < NUM_RTX_CODE; i++)
+    if (rtx_next[i] == -1)
+      oprintf (f, "  0,\n");
+    else
+      oprintf (f, 
+	       "  offsetof (struct rtx_def, fld) + %d * sizeof (rtunion),\n",
+	       rtx_next[i]);
+  oprintf (f, "};\n");
+}
+
 /* Handle `special("rtx_def")'.  This is a special case for field
    `fld' of struct rtx_def, which is an array of unions whose values
    are based in a complex way on the type of RTL.  */
@@ -348,24 +408,11 @@ adjust_field_rtx_def (t, opt)
   type_p rtx_tp, rtvec_tp, tree_tp, mem_attrs_tp, note_union_tp, scalar_tp;
   type_p bitmap_tp, basic_block_tp;
 
-  enum rtx_code {
-#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   ENUM ,
-#include "rtl.def"
-#undef DEF_RTL_EXPR
-    NUM_RTX_CODE
-  };
   static const char * const rtx_name[NUM_RTX_CODE] = {
 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   NAME ,
 #include "rtl.def"
 #undef DEF_RTL_EXPR
   };
-  /* We really don't care how long a CONST_DOUBLE is.  */
-#define CONST_DOUBLE_FORMAT "ww"
-  static const char * const rtx_format[NUM_RTX_CODE] = {
-#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   FORMAT ,
-#include "rtl.def"
-#undef DEF_RTL_EXPR
-  };
   
   if (t->kind != TYPE_ARRAY)
     {
@@ -430,7 +477,7 @@ adjust_field_rtx_def (t, opt)
 	  pair_p old_subf = subfields;
 	  type_p t;
 	  const char *subname;
-	  
+
 	  switch (rtx_format[i][aindex])
 	    {
 	    case '*':
@@ -538,6 +585,14 @@ adjust_field_rtx_def (t, opt)
 	      subfields->opt->name = "skip";
 	      subfields->opt->info = NULL;
 	    }
+	  else if ((size_t) rtx_next[i] == aindex)
+	    {
+	      /* The 'next' field will be marked by the chain_next option.  */
+	      subfields->opt = xmalloc (sizeof (*subfields->opt));
+	      subfields->opt->next = nodot;
+	      subfields->opt->name = "skip";
+	      subfields->opt->info = NULL;
+	    }
 	  else
 	    subfields->opt = nodot;
 	}
@@ -1022,8 +1077,6 @@ oprintf VPARAMS ((outf_p o, const char *
 
 /* Open the global header file and the language-specific header files.  */
 
-static void open_base_files PARAMS((void));
-
 static void
 open_base_files ()
 {
@@ -1298,6 +1351,7 @@ static void write_gc_structure_fields 
 static void write_gc_marker_routine_for_structure PARAMS ((type_p, type_p, 
 							   type_p *));
 static void write_gc_types PARAMS ((type_p structures, type_p param_structs));
+static void write_enum_defn PARAMS ((type_p structures, type_p param_structs));
 static void put_mangled_filename PARAMS ((outf_p , const char *));
 static void finish_root_table PARAMS ((struct flist *flp, const char *pfx, 
 				       const char *tname, const char *lastname,
@@ -1373,7 +1427,7 @@ output_mangled_typename (of, t)
       }
       break;
     case TYPE_ARRAY:
-      abort;
+      abort ();
     }
 }
 
@@ -1791,6 +1845,9 @@ write_gc_marker_routine_for_structure (o
   outf_p f;
   const char *fn = s->u.s.line.file;
   int i;
+  const char *chain_next = NULL;
+  const char *chain_prev = NULL;
+  options_p opt;
   
   /* This is a hack, and not the good kind either.  */
   for (i = NUM_PARAM - 1; i >= 0; i--)
@@ -1800,7 +1857,16 @@ write_gc_marker_routine_for_structure (o
   
   f = get_output_file_with_visibility (fn);
   
-  oprintf (f, "%c", '\n');
+  for (opt = s->u.s.opt; opt; opt = opt->next)
+    if (strcmp (opt->name, "chain_next") == 0)
+      chain_next = (const char *) opt->info;
+    else if (strcmp (opt->name, "chain_prev") == 0)
+      chain_prev = (const char *) opt->info;
+
+  if (chain_prev != NULL && chain_next == NULL)
+    error_at_line (&s->u.s.line, "chain_prev without chain_next");
+
+  oprintf (f, "\n");
   oprintf (f, "void\n");
   if (param == NULL)
     oprintf (f, "gt_ggc_mx_%s", s->u.s.tag);
@@ -1812,17 +1878,55 @@ write_gc_marker_routine_for_structure (o
   oprintf (f, " (x_p)\n");
   oprintf (f, "      void *x_p;\n");
   oprintf (f, "{\n");
-  oprintf (f, "  %s %s * const x = (%s %s *)x_p;\n",
+  oprintf (f, "  %s %s * %sx = (%s %s *)x_p;\n",
 	   s->kind == TYPE_UNION ? "union" : "struct", s->u.s.tag,
+	   chain_next == NULL ? "const " : "",
 	   s->kind == TYPE_UNION ? "union" : "struct", s->u.s.tag);
-  oprintf (f, "  if (! ggc_test_and_set_mark (x))\n");
-  oprintf (f, "    return;\n");
+  if (chain_next != NULL)
+    oprintf (f, "  %s %s * xlimit = x;\n",
+	     s->kind == TYPE_UNION ? "union" : "struct", s->u.s.tag);
+  if (chain_next == NULL)
+    oprintf (f, "  if (ggc_test_and_set_mark (x))\n");
+  else
+    {
+      oprintf (f, "  while (ggc_test_and_set_mark (xlimit))\n");
+      oprintf (f, "   xlimit = (");
+      output_escaped_param (f, chain_next, "*xlimit", "*xlimit", 
+			    "chain_next", &s->u.s.line);
+      oprintf (f, ");\n");
+      if (chain_prev != NULL)
+	{
+	  oprintf (f, "  if (x != xlimit)\n");
+	  oprintf (f, "    for (;;)\n");
+	  oprintf (f, "      {\n");
+	  oprintf (f, "        %s %s * const xprev = (",
+		   s->kind == TYPE_UNION ? "union" : "struct", s->u.s.tag);
+	  output_escaped_param (f, chain_prev, "*x", "*x",
+				"chain_prev", &s->u.s.line);
+	  oprintf (f, ");\n");
+	  oprintf (f, "        if (xprev == NULL) break;\n");
+	  oprintf (f, "        x = xprev;\n");
+	  oprintf (f, "        ggc_set_mark (xprev);\n");
+	  oprintf (f, "      }\n");
+	}
+      oprintf (f, "  while (x != xlimit)\n");
+    }
+  oprintf (f, "    {\n");
   
   gc_counter = 0;
   write_gc_structure_fields (f, s, "(*x)", "not valid postage",
-			     s->u.s.opt, 2, &s->u.s.line, s->u.s.bitmap,
+			     s->u.s.opt, 6, &s->u.s.line, s->u.s.bitmap,
 			     param);
   
+  if (chain_next != NULL)
+    {
+      oprintf (f, "      x = (");
+      output_escaped_param (f, chain_next, "*x", "*x",
+			    "chain_next", &s->u.s.line);
+      oprintf (f, ");\n");
+    }
+
+  oprintf (f, "  }\n");
   oprintf (f, "}\n");
 }
 
@@ -1923,6 +2027,41 @@ write_gc_types (structures, param_struct
       }
 }
 
+/* Write out the 'enum' definition for gt_types_enum.  */
+
+static void
+write_enum_defn (structures, param_structs)
+     type_p structures;
+     type_p param_structs;
+{
+  type_p s;
+  
+  oprintf (header_file, "\n/* Enumeration of types known.  */\n");
+  oprintf (header_file, "enum gt_types_enum {\n");
+  for (s = structures; s; s = s->next)
+    if (s->gc_used == GC_POINTED_TO
+	|| s->gc_used == GC_MAYBE_POINTED_TO)
+      {
+	if (s->gc_used == GC_MAYBE_POINTED_TO
+	    && s->u.s.line.file == NULL)
+	  continue;
+
+	oprintf (header_file, " gt_ggc_e_");
+	output_mangled_typename (header_file, s);
+	oprintf (header_file, ", \n");
+      }
+  for (s = param_structs; s; s = s->next)
+    if (s->gc_used == GC_POINTED_TO)
+      {
+	oprintf (header_file, " gt_e_");
+	output_mangled_typename (header_file, s);
+	oprintf (header_file, ", \n");
+      }
+  oprintf (header_file, " gt_types_enum_last\n");
+  oprintf (header_file, "};\n");
+}
+
+
 /* Mangle FN and print it to F.  */
 
 static void
@@ -2009,7 +2148,7 @@ finish_root_table (flp, pfx, lastname, t
       if (bitmap & 1)
 	{
 	  oprintf (base_files[fnum], "  NULL\n");
-	  oprintf (base_files[fnum], "};\n\n");
+	  oprintf (base_files[fnum], "};\n");
 	}
   }
 }
@@ -2399,6 +2538,8 @@ main(argc, argv)
   static struct fileloc pos = { __FILE__, __LINE__ };
   unsigned j;
   
+  gen_rtx_next ();
+
   srcdir_len = strlen (srcdir);
 
   do_typedef ("CUMULATIVE_ARGS",
@@ -2439,8 +2580,10 @@ main(argc, argv)
   set_gc_used (variables);
 
   open_base_files ();
+  write_enum_defn (structures, param_structs);
   write_gc_types (structures, param_structs);
   write_gc_roots (variables);
+  write_rtx_next ();
   close_output_files ();
 
   return (hit_error != 0);
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.324.4.11
diff -p -u -p -r1.324.4.11 rtl.h
--- rtl.h	24 Jul 2002 20:09:15 -0000	1.324.4.11
+++ rtl.h	4 Aug 2002 01:19:24 -0000
@@ -62,6 +62,8 @@ extern const char * const rtx_format[NUM
 
 extern const char rtx_class[NUM_RTX_CODE];
 #define GET_RTX_CLASS(CODE)		(rtx_class[(int) (CODE)])
+
+extern const unsigned char rtx_next[NUM_RTX_CODE];
 
 /* The flags and bitfields of an ADDR_DIFF_VEC.  BASE is the base label
    relative to which the offsets are calculated, as explained in rtl.def.  */
@@ -120,7 +122,8 @@ typedef union rtunion_def rtunion;
 
 /* RTL expression ("rtx").  */
 
-struct rtx_def GTY(())
+struct rtx_def GTY((chain_next ("RTX_NEXT (&%h)"), 
+		    chain_prev ("RTX_PREV (&%h)")))
 {
   /* The kind of expression this is.  */
   ENUM_BITFIELD(rtx_code) code: 16;
@@ -201,6 +204,23 @@ struct rtx_def GTY(())
 };
 
 #define NULL_RTX (rtx) 0
+
+/* The "next" and "previous" RTX, relative to this one.  */
+
+#define RTX_NEXT(X) (rtx_next[GET_CODE (X)] == 0 ? NULL			\
+		     : *(rtx *)(((char *)X) + rtx_next[GET_CODE (X)]))
+
+/* FIXME: the "NEXT_INSN (PREV_INSN (X)) == X" condition shouldn't be needed.
+ */
+#define RTX_PREV(X) ((GET_CODE (X) == INSN              \
+                      || GET_CODE (X) == CALL_INSN      \
+                      || GET_CODE (X) == JUMP_INSN      \
+                      || GET_CODE (X) == NOTE           \
+                      || GET_CODE (X) == BARRIER        \
+                      || GET_CODE (X) == CODE_LABEL)    \
+                     && PREV_INSN (X) != NULL           \
+                     && NEXT_INSN (PREV_INSN (X)) == X  \
+                     ? PREV_INSN (X) : NULL)
 
 /* Define macros to access the `code' field of the rtx.  */
 
Index: ada/ada-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/ada-tree.h,v
retrieving revision 1.1.14.4
diff -p -u -p -r1.1.14.4 ada-tree.h
--- ada/ada-tree.h	31 May 2002 06:12:59 -0000	1.1.14.4
+++ ada/ada-tree.h	4 Aug 2002 01:19:25 -0000
@@ -43,7 +43,8 @@ struct tree_loop_id GTY(()) 
 
 /* The language-specific tree.  */
 union lang_tree_node 
-  GTY((desc ("TREE_CODE (&%h.generic) == GNAT_LOOP_ID")))
+  GTY((desc ("TREE_CODE (&%h.generic) == GNAT_LOOP_ID"),
+       chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
 {
   union tree_node GTY ((tag ("0"), 
 			desc ("tree_node_structure (&%h)"))) 
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.671.2.13
diff -p -u -p -r1.671.2.13 cp-tree.h
--- cp/cp-tree.h	24 Jul 2002 20:09:54 -0000	1.671.2.13
+++ cp/cp-tree.h	4 Aug 2002 01:19:28 -0000
@@ -512,7 +512,8 @@ enum cp_tree_node_structure_enum {
 };
 
 /* The resulting tree type.  */
-union lang_tree_node GTY((desc ("cp_tree_node_structure (&%h)")))
+union lang_tree_node GTY((desc ("cp_tree_node_structure (&%h)"),
+       chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
 {
   struct tree_common GTY ((tag ("TS_CP_COMMON"))) common;
   union tree_node GTY ((tag ("TS_CP_GENERIC"),
Index: f/com.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com.c,v
retrieving revision 1.148.6.9
diff -p -u -p -r1.148.6.9 com.c
--- f/com.c	24 Jul 2002 20:10:01 -0000	1.148.6.9
+++ f/com.c	4 Aug 2002 01:19:29 -0000
@@ -605,7 +605,8 @@ struct lang_identifier GTY(())
 
 /* The resulting tree type.  */
 union lang_tree_node 
-  GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE")))
+  GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
+       chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
 {
   union tree_node GTY ((tag ("0"), 
 			desc ("tree_node_structure (&%h)"))) 
Index: java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.133.6.9
diff -p -u -p -r1.133.6.9 java-tree.h
--- java/java-tree.h	24 Jun 2002 23:27:57 -0000	1.133.6.9
+++ java/java-tree.h	4 Aug 2002 01:19:31 -0000
@@ -693,7 +693,8 @@ struct lang_identifier GTY(())
 
 /* The resulting tree type.  */
 union lang_tree_node 
-  GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE")))
+  GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
+       chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
 {
   union tree_node GTY ((tag ("0"), 
 			desc ("tree_node_structure (&%h)"))) 
============================================================

===File ~/patches/pchbranch-maxdepth.patch==================
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.1.2.30
diff -p -u -p -r1.1.2.30 gengtype.c
--- gengtype.c	24 Jul 2002 20:09:12 -0000	1.1.2.30
+++ gengtype.c	2 Aug 2002 22:11:17 -0000
@@ -1815,6 +1815,8 @@ write_gc_marker_routine_for_structure (o
   oprintf (f, "  %s %s * const x = (%s %s *)x_p;\n",
 	   s->kind == TYPE_UNION ? "union" : "struct", s->u.s.tag,
 	   s->kind == TYPE_UNION ? "union" : "struct", s->u.s.tag);
+  oprintf (f, "  if ((++ggc_cur_depth) > ggc_max_depth)\n");
+  oprintf (f, "    ggc_max_depth = ggc_cur_depth;\n");
   oprintf (f, "  if (! ggc_test_and_set_mark (x))\n");
   oprintf (f, "    return;\n");
   
@@ -1823,6 +1825,7 @@ write_gc_marker_routine_for_structure (o
 			     s->u.s.opt, 2, &s->u.s.line, s->u.s.bitmap,
 			     param);
   
+  oprintf (f, "  ggc_cur_depth--;\n");
   oprintf (f, "}\n");
 }
 
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	2 Aug 2002 22:11:17 -0000
@@ -31,6 +31,9 @@ Software Foundation, 59 Temple Place - S
 #include "ggc.h"
 #include "langhooks.h"
 
+unsigned ggc_cur_depth;
+unsigned ggc_max_depth = 0;
+
 /* Statistics about the allocation.  */
 static ggc_statistics *ggc_stats;
 
@@ -102,6 +105,8 @@ ggc_mark_roots ()
   const struct ggc_cache_tab *const *ct;
   const struct ggc_cache_tab *cti;
   size_t i;
+
+  ggc_cur_depth = 0;
 
   for (rt = gt_ggc_deletable_rtab; *rt; rt++)
     for (rti = *rt; rti->base != NULL; rti++)
Index: ggc-page.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-page.c,v
retrieving revision 1.48.4.2
diff -p -u -p -r1.48.4.2 ggc-page.c
--- ggc-page.c	24 Jun 2002 23:23:08 -0000	1.48.4.2
+++ ggc-page.c	2 Aug 2002 22:11:17 -0000
@@ -973,6 +973,9 @@ ggc_set_mark (p)
   unsigned bit, word;
   unsigned long mask;
 
+  if (ggc_max_depth > 890)
+    kill (getpid(), SIGQUIT);
+
   /* Look up the page on which the object is alloced.  If the object
      wasn't allocated by the collector, we'll probably die.  */
   entry = lookup_page_table_entry (p);
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	2 Aug 2002 22:11:17 -0000
@@ -62,6 +62,9 @@ extern const struct ggc_cache_tab * cons
 
 extern void ggc_mark_roots		PARAMS ((void));
 
+extern unsigned ggc_cur_depth;
+extern unsigned ggc_max_depth;
+
 /* 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) \
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.571.2.8
diff -p -u -p -r1.571.2.8 toplev.c
--- toplev.c	24 Jul 2002 20:09:17 -0000	1.571.2.8
+++ toplev.c	2 Aug 2002 22:11:17 -0000
@@ -5254,6 +5254,7 @@ do_compile (no_backend)
   /* Stop timing and print the times.  */
   timevar_stop (TV_TOTAL);
   timevar_print (stderr);
+  fprintf (stderr, "maximum GGC depth: %d\n", ggc_max_depth);
 }
 
 /* Entry point of cc1, cc1plus, jc1, f771, etc.
============================================================


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