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]

[boehm-gc] Current code for type-tagged memory management


Hi,

I'm stuck with debugging this, thus armed with Daniel's advice, I
decided to dump the current unfinished code with all its atrocities
into the branch. Basically it should be an almost feature complete
implementation of type-tagged memory management. However, the compiler
crashes somewhere in middle of libgcc, and I'm making progress quite
slowly.

This code does the following:
- Changes to gengtype to output type aware marker functions, that look like

struct GC_ms_entry *
gt_tggc_mx_VEC_eh_region_gc (GC_word *x_p, struct GC_ms_entry *
mark_stack_ptr, struct GC_ms_entry * mark_stack_limit)
{
 struct VEC_eh_region_gc * const x = (struct VEC_eh_region_gc *)x_p;
 if (ggc_consider_for_marking (x))
   {
     MAYBE_MARK (x );
     {
       size_t i0;
       for (i0 = 0; i0 != (size_t)(((*x).base).num); i0++) {
         MAYBE_MARK ((*x).base.vec[i0]);
       }
     }
   }
 return mark_stack_ptr;
},

which hopefully is very close to the final version of how those typed
marker functions should look like.
- An opportunity taken to refactor some of the things in gengtype to
hopefully clean up things a bit.
- Factored out valgrind support into its own header file
- The architecture of type-tagged MM is following: every object has its type
- Turned on Boehm's GC custom marking allocation by default. All
type-tagged objects are presented as being of a single type to Boehm's
GC and are discriminated by a type byte, generated by gengtype, which
is stored in memory immediately after the object itself. A marker
function gt_tggc_m_mark_object is registered with Boehm's GC. It calls
the real marker routine according to the type tag-indexed array of
functions generated by gengtype.
- Client code is made to call exact type allocations functions
whenever possible, e.g.

-      ivs = ggc_alloc_atomic (sizeof (struct initial_value_struct));
+      ivs = ggc_alloc_initial_value_struct();


- Untagged memory allocation is present at few places. It was probably a mistake to change textually most allocations to the tagged ones early in development. Now as I'm debugging it, I'm reverting more and more of them back to identify culprits. - Some debugging code in libcpp that was useful in debugging the very first failure.

Commited to the branch, breaking it for now. Now I'm set to continue
debugging it...

--
Laurynas
Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 116231)
+++ gcc/gengtype.c	(working copy)
@@ -927,7 +927,7 @@
 				&length, &nested_ptr);
 
 	    if (nested_ptr && f->type->kind == TYPE_POINTER)
-	      set_gc_used_type (nested_ptr, GC_POINTED_TO, 
+	      set_gc_used_type (nested_ptr, GC_POINTED_TO,
 				pass_param ? param : NULL);
 	    else if (length && f->type->kind == TYPE_POINTER)
 	      set_gc_used_type (f->type->u.p, GC_USED, NULL);
@@ -1168,8 +1168,8 @@
   const char *slashpos = strchr (basename, '/');
   unsigned j;
   unsigned k;
-  unsigned bitmap;
-
+  unsigned bitmap = 0;
+#if 0
   /* If the file resides in a language subdirectory (e.g., 'cp'), assume that
      it belongs to the corresponding language.  The file may belong to other
      languages as well (which is checked for below).  */
@@ -1190,7 +1190,7 @@
      specified.  */
 
   bitmap = 0;
-
+#endif
   for (j = 0; j < NUM_LANG_FILES; j++)
     {
       if (!strcmp(input_file, lang_files[j]))
@@ -1267,12 +1267,13 @@
   else if (strncmp (basename, "objc", 4) == 0 && IS_DIR_SEPARATOR (basename[4])
 	   && strcmp (basename + 5, "objc-act.h") == 0)
     output_name = "gt-objc-objc-act.h", for_name = "objc/objc-act.c";
-  else 
+  else
     {
       size_t i;
 
       for (i = 0; i < NUM_BASE_FILES; i++)
-	if (memcmp (basename, lang_dir_names[i], strlen (lang_dir_names[i])) == 0
+	if (memcmp (basename, lang_dir_names[i], strlen (lang_dir_names[i]))
+	    == 0
 	    && basename[strlen(lang_dir_names[i])] == '/')
 	  return base_files[i];
 
@@ -1360,6 +1361,7 @@
 };
 
 struct walk_type_data;
+struct write_types_data;
 
 /* For scalars and strings, given the item in 'val'.
    For structures, given a pointer to the item in 'val'.
@@ -1369,7 +1371,12 @@
      (type_p f, const struct walk_type_data *p);
 typedef void (*func_name_fn)
      (type_p s, const struct walk_type_data *p);
+typedef void (*process_struct_fn)
+     (type_p f, const struct walk_type_data *p);
+typedef void (*prewrite_struct_fn)
+     (type_p s, const struct write_types_data *wtd);
 
+
 /* Parameters for write_types.  */
 
 struct write_types_data
@@ -1378,7 +1385,15 @@
   const char *param_prefix;
   const char *subfield_marker_routine;
   const char *marker_routine;
+  const char *marker_routine_signature;
   const char *reorder_note_routine;
+  const process_struct_fn struct_field_processor;
+  const prewrite_struct_fn prewrite_struct;
+  const char *return_type;
+  const char *return_expression;
+  const char *marker_args;
+  const int   separate_test_and_mark;
+  const char *test_routine;
   const char *comment;
 };
 
@@ -1400,7 +1415,7 @@
      (type_p orig_s, type_p s, type_p * param);
 static void write_local (type_p structures,
 			 type_p param_structs);
-static void write_enum_defn (type_p structures, type_p param_structs);
+static void write_gt_types_enum (type_p structures, type_p param_structs);
 static int contains_scalar_p (type_p t);
 static void put_mangled_filename (outf_p , const char *);
 static void finish_root_table (struct flist *flp, const char *pfx,
@@ -1669,9 +1684,9 @@
 		d->indent += 2;
 		d->val = xasprintf ("x%d", d->counter++);
 		oprintf (d->of, "%*s%s %s * %s%s =\n", d->indent, "",
-			 (nested_ptr_d->type->kind == TYPE_UNION 
-			  ? "union" : "struct"), 
-			 nested_ptr_d->type->u.s.tag, 
+			 (nested_ptr_d->type->kind == TYPE_UNION
+			  ? "union" : "struct"),
+			 nested_ptr_d->type->u.s.tag,
 			 d->fn_wants_lvalue ? "" : "const ",
 			 d->val);
 		oprintf (d->of, "%*s", d->indent + 2, "");
@@ -1932,6 +1947,39 @@
     }
 }
 
+static void
+write_types_process_struct (type_p f, const struct walk_type_data *d)
+{
+  const struct write_types_data *wtd =
+    (const struct write_types_data *) d->cookie;
+  const char *cast = d->needs_cast_p ? "(void *)" : "";
+  oprintf (d->of, "%*sgt_%s_", d->indent, "", wtd->prefix);
+  output_mangled_typename (d->of, f);
+  oprintf (d->of, " (%s%s);\n", cast, d->val);
+}
+
+static void
+prewrite_structure (type_p s, const struct write_types_data *wtd)
+{
+  oprintf (header_file, "#define gt_%s_", wtd->prefix);
+  output_mangled_typename (header_file, s);
+  oprintf (header_file, "(X) do { \\\n");
+  oprintf (header_file, "  if (X != NULL) gt_%sx_%s (X);\\\n", wtd->prefix,
+	   s->u.s.tag);
+  oprintf (header_file, "  } while (0)\n");
+}
+
+static void
+write_tagged_types_process_struct (type_p f ATTRIBUTE_UNUSED,
+				   const struct walk_type_data *d)
+{
+  const char *cast = d->needs_cast_p ? "(void *)" : "";
+  oprintf (d->of, "%*sMAYBE_MARK", d->indent, "");
+  oprintf (d->of, " (%s%s);\n", cast,
+	   d->val);
+}
+
+
 /* process_field routine for marking routines.  */
 
 static void
@@ -1987,9 +2035,7 @@
     case TYPE_UNION:
     case TYPE_LANG_STRUCT:
     case TYPE_PARAM_STRUCT:
-      oprintf (d->of, "%*sgt_%s_", d->indent, "", wtd->prefix);
-      output_mangled_typename (d->of, f);
-      oprintf (d->of, " (%s%s);\n", cast, d->val);
+      (wtd->struct_field_processor) (f, d);
       if (d->reorder_fn && wtd->reorder_note_routine)
 	oprintf (d->of, "%*s%s (%s%s, %s%s, %s);\n", d->indent, "",
 		 wtd->reorder_note_routine, cast, d->val, cast, d->val,
@@ -2023,6 +2069,19 @@
     oprintf (of, ", gt_types_enum_last");
 }
 
+/* Finds a real source location for a param struct. */
+static const char *
+find_source_for_param_struct (type_p *param, const char * fn)
+{
+  int i;
+  /* This is a hack, and not the good kind either.  */
+  for (i = NUM_PARAM - 1; i >= 0; i--)
+    if (param && param[i] && param[i]->kind == TYPE_POINTER
+	&& UNION_OR_STRUCT_P (param[i]->u.p))
+      fn = param[i]->u.p->u.s.line.file;
+  return fn;
+}
+
 /* For S, a structure that's part of ORIG_S, and using parameters
    PARAM, write out a routine that:
    - Takes a parameter, a void * but actually of type *S
@@ -2035,19 +2094,11 @@
 write_func_for_structure (type_p orig_s, type_p s, type_p *param,
 			  const struct write_types_data *wtd)
 {
-  const char *fn = s->u.s.line.file;
-  int i;
+  const char *fn = find_source_for_param_struct (param, s->u.s.line.file);
   const char *chain_next = NULL;
   const char *chain_prev = NULL;
   options_p opt;
   struct walk_type_data d;
-
-  /* This is a hack, and not the good kind either.  */
-  for (i = NUM_PARAM - 1; i >= 0; i--)
-    if (param && param[i] && param[i]->kind == TYPE_POINTER
-	&& UNION_OR_STRUCT_P (param[i]->u.p))
-      fn = param[i]->u.p->u.s.line.file;
-
   memset (&d, 0, sizeof (d));
   d.of = get_output_file_with_visibility (fn);
 
@@ -2073,7 +2124,7 @@
   d.val = "(*x)";
 
   oprintf (d.of, "\n");
-  oprintf (d.of, "void\n");
+  oprintf (d.of, "%s\n", wtd->return_type);
   if (param == NULL)
     oprintf (d.of, "gt_%sx_%s", wtd->prefix, orig_s->u.s.tag);
   else
@@ -2081,7 +2132,8 @@
       oprintf (d.of, "gt_%s_", wtd->prefix);
       output_mangled_typename (d.of, orig_s);
     }
-  oprintf (d.of, " (void *x_p)\n");
+  oprintf (d.of, wtd->marker_routine_signature);
+  oprintf (d.of, "\n");
   oprintf (d.of, "{\n");
   oprintf (d.of, "  %s %s * %sx = (%s %s *)x_p;\n",
 	   s->kind == TYPE_UNION ? "union" : "struct", s->u.s.tag,
@@ -2092,26 +2144,40 @@
 	     s->kind == TYPE_UNION ? "union" : "struct", s->u.s.tag);
   if (chain_next == NULL)
     {
-      oprintf (d.of, "  if (%s (x", wtd->marker_routine);
-      if (wtd->param_prefix)
+      if (wtd->separate_test_and_mark)
 	{
-	  oprintf (d.of, ", x, gt_%s_", wtd->param_prefix);
-	  output_mangled_typename (d.of, orig_s);
-	  output_type_enum (d.of, orig_s);
+	  oprintf (d.of, "  if (%s (x))\n", wtd->test_routine);
 	}
-      oprintf (d.of, "))\n");
+      else
+	{
+	  oprintf (d.of, "  if (%s (x %s", wtd->marker_routine, wtd->marker_args);
+	  if (wtd->param_prefix)
+	    {
+	      oprintf (d.of, ", x, gt_%s_", wtd->param_prefix);
+	      output_mangled_typename (d.of, orig_s);
+	      output_type_enum (d.of, orig_s);
+	    }
+	  oprintf (d.of, "))\n");
+	}
     }
   else
     {
-      oprintf (d.of, "  while (%s (xlimit", wtd->marker_routine);
-      if (wtd->param_prefix)
+      if (wtd->separate_test_and_mark)
 	{
-	  oprintf (d.of, ", xlimit, gt_%s_", wtd->param_prefix);
-	  output_mangled_typename (d.of, orig_s);
-	  output_type_enum (d.of, orig_s);
+	  oprintf (d.of, "  while (%s (xlimit))\n", wtd->test_routine);
 	}
-      oprintf (d.of, "))\n");
-      oprintf (d.of, "   xlimit = (");
+      else
+	{
+	  oprintf (d.of, "  while (%s (xlimit", wtd->marker_routine);
+	  if (wtd->param_prefix)
+	    {
+	      oprintf (d.of, ", xlimit, gt_%s_", wtd->param_prefix);
+	      output_mangled_typename (d.of, orig_s);
+	      output_type_enum (d.of, orig_s);
+	    }
+	  oprintf (d.of, "))\n");
+	}
+      oprintf (d.of, "    xlimit = (");
       d.prev_val[2] = "*xlimit";
       output_escaped_param (&d, chain_next, "chain_next");
       oprintf (d.of, ");\n");
@@ -2128,8 +2194,8 @@
 	  oprintf (d.of, ");\n");
 	  oprintf (d.of, "        if (xprev == NULL) break;\n");
 	  oprintf (d.of, "        x = xprev;\n");
-	  oprintf (d.of, "        (void) %s (xprev",
-		   wtd->marker_routine);
+	  oprintf (d.of, "        %s (xprev",
+		   wtd->marker_routine); /* TODO: Result cast to void */
 	  if (wtd->param_prefix)
 	    {
 	      oprintf (d.of, ", xprev, gt_%s_", wtd->param_prefix);
@@ -2142,6 +2208,10 @@
       oprintf (d.of, "  while (x != xlimit)\n");
     }
   oprintf (d.of, "    {\n");
+  if (wtd->separate_test_and_mark)
+    {
+      oprintf(d.of, "      %s (x %s);\n", wtd->marker_routine, wtd->marker_args);
+    }
 
   d.prev_val[2] = "*x";
   d.indent = 6;
@@ -2155,6 +2225,8 @@
     }
 
   oprintf (d.of, "    }\n");
+  if (strcmp (wtd->return_type, "void"))
+    oprintf (d.of, "  %s\n", wtd->return_expression);
   oprintf (d.of, "}\n");
 }
 
@@ -2177,14 +2249,8 @@
 	    && s->u.s.line.file == NULL)
 	  continue;
 
-	oprintf (header_file, "#define gt_%s_", wtd->prefix);
-	output_mangled_typename (header_file, s);
-	oprintf (header_file, "(X) do { \\\n");
-	oprintf (header_file,
-		 "  if (X != NULL) gt_%sx_%s (X);\\\n", wtd->prefix,
-		 s->u.s.tag);
-	oprintf (header_file,
-		 "  } while (0)\n");
+	if (wtd->prewrite_struct)
+	  (wtd->prewrite_struct) (s, wtd);
 
 	for (opt = s->u.s.opt; opt; opt = opt->next)
 	  if (strcmp (opt->name, "ptr_alias") == 0)
@@ -2205,9 +2271,8 @@
 	  continue;
 
 	/* Declare the marker procedure only once.  */
-	oprintf (header_file,
-		 "extern void gt_%sx_%s (void *);\n",
-		 wtd->prefix, s->u.s.tag);
+	oprintf (header_file, "extern %s gt_%sx_%s %s;\n", wtd->return_type,
+		 wtd->prefix, s->u.s.tag, wtd->marker_routine_signature);
 
 	if (s->u.s.line.file == NULL)
 	  {
@@ -2233,9 +2298,10 @@
 	type_p stru = s->u.param_struct.stru;
 
 	/* Declare the marker procedure.  */
-	oprintf (header_file, "extern void gt_%s_", wtd->prefix);
+	oprintf (header_file, "extern %s gt_%s_", wtd->return_type,
+		 wtd->prefix);
 	output_mangled_typename (header_file, s);
-	oprintf (header_file, " (void *);\n");
+	oprintf (header_file, " %s;\n", wtd->marker_routine_signature);
 
 	if (stru->u.s.line.file == NULL)
 	  {
@@ -2256,17 +2322,30 @@
 }
 
 static const struct write_types_data ggc_wtd =
-{
-  "ggc_m", NULL, "ggc_mark", "ggc_test_and_set_mark", NULL,
-  "GC marker procedures.  "
-};
+  {
+    "ggc_m", NULL, "ggc_mark", "ggc_test_and_set_mark", " (void *x_p)", NULL,
+    write_types_process_struct, prewrite_structure, "void", NULL, "", 0, "",
+    "GC marker procedures.  "
+  };
 
+static const struct write_types_data typed_ggc_wtd =
+  {
+    "tggc_m", NULL, "MAYBE_MARK", "MAYBE_MARK",
+    " (GC_word *x_p, struct GC_ms_entry * mark_stack_ptr,"
+       " struct GC_ms_entry * mark_stack_limit)",
+    NULL, write_tagged_types_process_struct, NULL, "struct GC_ms_entry *",
+    "return mark_stack_ptr;",
+    "", 1, "ggc_consider_for_marking", /* , mark_stack_ptr, mark_stack_limit, x */
+    "Typed GC marker procedures.  "
+  };
+
 static const struct write_types_data pch_wtd =
-{
-  "pch_n", "pch_p", "gt_pch_note_object", "gt_pch_note_object",
-  "gt_pch_note_reorder",
-  "PCH type-walking procedures.  "
-};
+  {
+    "pch_n", "pch_p", "gt_pch_note_object", "gt_pch_note_object",
+    " (void *x_p)\n", "gt_pch_note_reorder", write_types_process_struct,
+    prewrite_structure, "void", NULL,
+    "", 0, NULL, "PCH type-walking procedures.  "
+  };
 
 /* Write out the local pointer-walking routines.  */
 
@@ -2305,16 +2384,8 @@
 static void
 write_local_func_for_structure (type_p orig_s, type_p s, type_p *param)
 {
-  const char *fn = s->u.s.line.file;
-  int i;
+  const char *fn = find_source_for_param_struct (param, s->u.s.line.file);
   struct walk_type_data d;
-
-  /* This is a hack, and not the good kind either.  */
-  for (i = NUM_PARAM - 1; i >= 0; i--)
-    if (param && param[i] && param[i]->kind == TYPE_POINTER
-	&& UNION_OR_STRUCT_P (param[i]->u.p))
-      fn = param[i]->u.p->u.s.line.file;
-
   memset (&d, 0, sizeof (d));
   d.of = get_output_file_with_visibility (fn);
 
@@ -2432,27 +2503,36 @@
 }
 
 /* Write out the 'enum' definition for gt_types_enum.  */
-
 static void
-write_enum_defn (type_p structures, type_p param_structs)
+write_gt_types_enum (type_p structures, type_p param_structs)
 {
   type_p s;
 
   oprintf (header_file, "\n/* Enumeration of known types.  */\n");
   oprintf (header_file, "enum gt_types_enum {\n");
+  oprintf (header_file, " gt_types_enum_free_list_obj = 0,\n");
+
   for (s = structures; s; s = s->next)
-    {
-      if (s->gc_used == GC_MAYBE_POINTED_TO
-	  && s->u.s.line.file == NULL)
-	continue;
+    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");
-    }
+	if (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)
     {
+      type_p stru = s->u.param_struct.stru;
+      if (stru->u.s.line.file == NULL)
+	continue;
       oprintf (header_file, " gt_e_");
       output_mangled_typename (header_file, s);
       oprintf (header_file, ",\n");
@@ -2493,7 +2573,7 @@
 
 static void
 write_typed_struct_alloc_def (const type_p s, const char * const fn_type,
-			      int is_vector)
+			      const char * const tag_prefix, int is_vector)
 {
   int have_size = has_size_p (s);
   const char *type_kind = get_tag_string (s);
@@ -2503,7 +2583,7 @@
 	   ((have_size && is_vector) ? ", " : ""), (is_vector ? "n" : ""));
   oprintf (header_file, "  ");
   write_typecast_to_ptr (s);
-  oprintf (header_file, " ggc_alloc_%styped(gt_ggc_e_", fn_type);
+  oprintf (header_file, " ggc_alloc_%styped(%s", fn_type, tag_prefix);
   output_mangled_typename (header_file, s);
   if (have_size)
     oprintf (header_file, ", SIZE%s)\n", (is_vector ? " * (n)" : ""));
@@ -2542,12 +2622,25 @@
   oprintf (header_file,
 	   "\n/* Typed allocation for known structs and unions.  */\n");
   for (s = structures; s; s = s->next)
-    {
-      write_typed_struct_alloc_def (s, "", NON_VECTOR_DEF);
-      write_typed_struct_alloc_def (s, "cleared_", NON_VECTOR_DEF);
-      write_typed_struct_alloc_def (s, "vec_", VECTOR_DEF);
-      write_typed_struct_alloc_def (s, "cleared_vec_", VECTOR_DEF);
-    }
+    if (s->gc_used == GC_POINTED_TO || s->gc_used == GC_MAYBE_POINTED_TO)
+      {
+	write_typed_struct_alloc_def (s, "", "gt_ggc_e_", NON_VECTOR_DEF);
+	write_typed_struct_alloc_def (s, "cleared_", "gt_ggc_e_",
+				      NON_VECTOR_DEF);
+	write_typed_struct_alloc_def (s, "vec_", "gt_ggc_e_", VECTOR_DEF);
+	write_typed_struct_alloc_def (s, "cleared_vec_", "gt_ggc_e_",
+				      VECTOR_DEF);
+      }
+  /* TODO! Not clear at this stage if this is needed or not.
+  for (s = param_structs; s; s = s->next)
+    if (s->gc_used == GC_POINTED_TO)
+      {
+	write_typed_struct_alloc_def (s, "", "gt_e_", NON_VECTOR_DEF);
+	write_typed_struct_alloc_def (s, "cleared_", "gt_e_", NON_VECTOR_DEF);
+	write_typed_struct_alloc_def (s, "vec_", "gt_e_", VECTOR_DEF);
+	write_typed_struct_alloc_def (s, "cleared_vec_", "gt_e_", VECTOR_DEF);
+      }
+  */
   oprintf (header_file, "\n/* Typed allocation for known typedefs.  */\n");
   for (p = typedefs; p != NULL; p = p->next)
     {
@@ -2566,6 +2659,134 @@
     }
 }
 
+static int base_file_has_markers[NUM_BASE_FILES];
+
+static void
+prepare_marker_output(outf_p file)
+{
+  size_t i;
+  for (i = 0; i < NUM_BASE_FILES; i++)
+    {
+      if (file == base_files[i])
+	{
+	  if (base_file_has_markers[i])
+	    break;
+	  base_file_has_markers[i] = 1;
+	  oprintf (file,
+		   "\n"
+		   "const typed_marker_fn typed_markers[gt_types_enum_last + 1] =\n"
+		   "{\n"
+		   "  &gt_tggc_m_free_list_obj,\n");
+	  break;
+	}
+    }
+  if (i == NUM_BASE_FILES)
+    gcc_unreachable();
+}
+
+static void
+finish_marker_outputs(void)
+{
+  size_t i;
+  for (i = 0; i < NUM_BASE_FILES; i++)
+    {
+      if (base_file_has_markers[i])
+	{
+	  oprintf (base_files[i],
+		   "  &gt_tggc_m_atomic_obj,\n"
+		   "  &gt_tggc_m_nonexistent_obj\n"
+		   "};\n"
+		   "\n");
+	}
+    }
+}
+
+/* Write marker routines */
+static void
+write_typed_markers (type_p structures)
+{
+  unsigned bitmap;
+  size_t fnum;
+  type_p s;
+
+  size_t i;
+  for (i = 0; i < NUM_BASE_FILES; i++)
+    {
+      base_file_has_markers[i] = 0;
+    }
+
+  oprintf (header_file,
+	   "#include <gc.h>\n"
+	   "#include <gc_mark.h>\n"
+	   "#define MAYBE_MARK(Obj)"
+	   " mark_stack_ptr=GC_MARK_AND_PUSH((GC_PTR) (Obj), mark_stack_ptr, mark_stack_limit, NULL)\n");
+
+  write_types (structures, param_structs, &typed_ggc_wtd);
+
+  oprintf (header_file,
+	   "\n"
+	   "typedef struct GC_ms_entry * (*typed_marker_fn)("
+	   "GC_word * object,"
+	   " struct GC_ms_entry * mark_stack_ptr,"
+	   " struct GC_ms_entry * mark_stack_limit);\n"
+	   "extern const typed_marker_fn"
+	   " typed_markers[gt_types_enum_last + 1];\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;
+
+	if (s->u.s.line.file == NULL)
+	  continue;
+
+	bitmap = get_base_file_bitmap (s->u.s.line.file);
+	for (fnum = 0; bitmap != 0; fnum++, bitmap >>= 1)
+	  if (bitmap & 1)
+	    {
+	      prepare_marker_output (base_files[fnum]);
+	      oprintf (base_files[fnum], "  &gt_%sx_%s,\n",
+		       typed_ggc_wtd.prefix, s->u.s.tag);
+	    }
+	  else
+	    {
+	      prepare_marker_output (base_files[fnum]);
+	      oprintf (base_files[fnum], "  NULL,\n");
+	    }
+      }
+
+  for (s = param_structs; s; s = s->next)
+    if (s->gc_used == GC_POINTED_TO)
+      {
+	type_p * param = s->u.param_struct.param;
+
+	type_p stru = s->u.param_struct.stru;
+	if (stru->u.s.line.file == NULL)
+	  continue;
+	const char *fn = find_source_for_param_struct (param,
+						       stru->u.s.line.file);
+
+	bitmap = get_base_file_bitmap (fn);
+	for (fnum = 0; bitmap != 0; fnum++, bitmap >>= 1)
+	  if (bitmap & 1)
+	    {
+	      prepare_marker_output (base_files[fnum]);
+	      oprintf (base_files[fnum], "  &gt_%s_", typed_ggc_wtd.prefix);
+	      output_mangled_typename (base_files[fnum], s);
+	      oprintf (base_files[fnum], ",\n");
+	    }
+	  else
+	    {
+	      prepare_marker_output (base_files[fnum]);
+	      oprintf (base_files[fnum], "  NULL,\n");
+	    }
+      }
+  finish_marker_outputs();
+}
+
+
 /* Might T contain any non-pointer elements?  */
 
 static int
@@ -3187,8 +3408,9 @@
   set_gc_used (variables);
 
   open_base_files ();
-  write_enum_defn (structures, param_structs);
+  write_gt_types_enum (structures, param_structs);
   write_typed_alloc_defns (structures);
+  write_typed_markers (structures);
   write_types (structures, param_structs, &ggc_wtd);
   write_types (structures, param_structs, &pch_wtd);
   write_local (structures, param_structs);
Index: gcc/ggc-boehm.c
===================================================================
--- gcc/ggc-boehm.c	(revision 116231)
+++ gcc/ggc-boehm.c	(working copy)
@@ -6,10 +6,15 @@
 #include "timevar.h"
 #include "ggc.h"
 #include "symtab.h"
+#include "valgrind-support.h"
 
-/* #define GC_DEBUG */
+#define GC_DEBUG
 #include <gc.h>
+#include <gc_mark.h>
 
+#undef GC_FREE
+#define GC_FREE(x)
+
 extern struct ht *ident_hash;
 
 static int ggc_htab_register_weak_ptr(void **slot, void *info);
@@ -21,8 +26,7 @@
 static void register_gty_roots(void);
 static void gc_warning_filter(char * msg, GC_word arg);
 
-static enum gt_types_enum *get_type_offset(void * block);
-static enum gt_types_enum get_block_type(void * block);
+static enum gt_types_enum *get_type_offset(const void * block);
 
 static void register_weak_pointers(void);
 static void unregister_weak_pointers(void);
@@ -35,9 +39,14 @@
 
 #define OBJ_OVERHEAD sizeof(enum gt_types_enum)
 
+static void **tagged_obj_free_list;
+static int tagged_obj_kind;
+
 void
 init_ggc (void)
 {
+  int gc_proc;
+
   /* Have better idea of roots before initialization, because it performs
      blacklisting according to the current set of roots.  We miss stringpool
      roots here, but we can get information about them only when it's way too
@@ -51,39 +60,36 @@
   stringpool_roots.one_after_finish = NULL;
 
   default_warn_proc = GC_set_warn_proc(gc_warning_filter);
-}
 
-void *
-ggc_internal_alloc_stat (size_t size MEM_STAT_DECL)
-{
-  void * result = GC_MALLOC(size);
-  return result;
+  tagged_obj_free_list = GC_new_free_list();
+  gc_proc = GC_new_proc((GC_mark_proc)gt_tggc_m_mark_object);
+  tagged_obj_kind = GC_new_kind(tagged_obj_free_list,
+				 GC_MAKE_PROC (gc_proc, 0), 0, 1);
 }
 
 enum gt_types_enum *
-get_type_offset(void * block)
+get_type_offset(const void * block)
 {
-  return (enum gt_types_enum *)((char *)block + GC_size(block) - OBJ_OVERHEAD);
+  return (enum gt_types_enum *)((const char *)block + GC_size((void *)block)
+				- OBJ_OVERHEAD);
 }
 
 void *
 ggc_alloc_typed_stat (enum gt_types_enum type, size_t size MEM_STAT_DECL)
 {
-  void * result = NULL;
-
-  size_t actual_obj_size;
-  const size_t obj_plus_info_size = size + OBJ_OVERHEAD;
-  type_overhead += obj_plus_info_size;
-
-  result = GC_malloc (obj_plus_info_size);
-  actual_obj_size = GC_size(result);
-
-  *(get_type_offset(result)) = type;
-
-  /* Verification */
-  gcc_assert (type == get_block_type (result));
-
-  return result;
+  if ((type == gt_types_enum_atomic_data))
+    return GC_MALLOC (size);
+  else
+  {
+      void * result = NULL;
+      size_t actual_obj_size;
+      const size_t obj_plus_info_size = size + OBJ_OVERHEAD;
+      type_overhead += obj_plus_info_size;
+      result = GC_generic_malloc (obj_plus_info_size, tagged_obj_kind);
+      actual_obj_size = GC_size(result);
+      *(get_type_offset(result)) = type;
+      return result;
+  }
 }
 
 void *
@@ -98,7 +104,9 @@
 void *
 ggc_alloc_atomic_stat (size_t size MEM_STAT_INFO)
 {
-  return ggc_alloc_typed_stat (gt_types_enum_atomic_data, size);
+  //  return ggc_alloc_typed_stat (gt_types_enum_atomic_data, size);
+  // A "kind" of uninitialized atomic data is not supported by Boehm's GC.
+  return ggc_alloc_cleared_atomic_stat (size);
 }
 
 void *
@@ -109,7 +117,7 @@
 
 
 enum gt_types_enum
-get_block_type(void * block)
+ggc_get_block_type(const void * block)
 {
   return *(get_type_offset(block));
 }
@@ -117,13 +125,23 @@
 void *
 ggc_realloc_atomic_stat (void *x, size_t size MEM_STAT_DECL)
 {
+  if (1)
+    return GC_REALLOC (x, size);
+  else
+    {
+  int oldsize;
   void * result;
   if (x == NULL)
     return ggc_alloc_atomic_stat (size);
-  gcc_assert (get_block_type(x) == gt_types_enum_atomic_data);
-  result = GC_REALLOC(x, size);
+  oldsize = ggc_get_size (x);
+  gcc_assert (ggc_get_block_type(x) == gt_types_enum_atomic_data);
+  result = ggc_alloc_atomic_stat (size);
+  memcpy (result, x, oldsize);
+  GC_FREE (x);
+  // result = GC_REALLOC (x, size);
   *(get_type_offset(result)) = gt_types_enum_atomic_data;
   return result;
+    }
 }
 
 void
@@ -137,17 +155,18 @@
 int
 ggc_htab_register_weak_ptr(void **slot, void *info)
 {
-  GC_general_register_disappearing_link_callback (slot, *slot,
+  int result = GC_general_register_disappearing_link_callback (slot, *slot,
 						  ggc_htab_delete_weak_ptr,
 						  info);
+  gcc_assert (result == 0);
   return 1;
 }
 
 int
 ggc_htab_unregister_weak_ptr(void **slot, void *info ATTRIBUTE_UNUSED)
 {
-  int result = GC_unregister_disappearing_link (slot);
-  gcc_assert (result != 0);
+  /* int result = */ GC_unregister_disappearing_link (slot);
+  /* gcc_assert (result != 0); */
   return 1;
 }
 
@@ -157,9 +176,6 @@
   const struct ggc_cache_tab *const *ct;
   const struct ggc_cache_tab *cti;
 
-  /* Register hash caches as weak pointers. Boehm's GC weak pointer facility
-     will clear any weak pointers to deleted objects.  After collection hash
-     table cleanup to shrink it should be performed. */
   for (ct = gt_ggc_cache_rtab; *ct; ct++)
     for (cti = *ct; cti->base != NULL; cti++)
       if (*cti->base)
@@ -217,17 +233,17 @@
     }
 
   /* Clear pointers with GTY "deletable" */
-  for (rt = gt_ggc_deletable_rtab; *rt; rt++)
+  /*  for (rt = gt_ggc_deletable_rtab; *rt; rt++)
     for (rti = *rt; rti->base != NULL; rti++)
-      memset (rti->base, 0, rti->stride);
+    memset (rti->base, 0, rti->stride);*/
 
-  register_weak_pointers();
+  //  register_weak_pointers();
 
   GC_enable();
   GC_gcollect();
   GC_disable();
 
-  unregister_weak_pointers();
+  //  unregister_weak_pointers();
 
   if (!quiet_flag)
     fprintf (stderr, "%luk}", (unsigned long) get_used_heap_size() / 1024);
@@ -238,7 +254,7 @@
 void
 ggc_free (void * block)
 {
-  GC_FREE(block); /* For some blocks might be unprofitable? */
+  GC_FREE (block); /* For some blocks might be unprofitable? */
 }
 
 size_t
@@ -249,6 +265,46 @@
 						   originally requested */
 }
 
+struct GC_ms_entry *
+gt_tggc_m_free_list_obj (GC_word * object ATTRIBUTE_UNUSED,
+			 struct GC_ms_entry * mark_stack_ptr ATTRIBUTE_UNUSED,
+			 struct GC_ms_entry * mark_stack_limit ATTRIBUTE_UNUSED)
+{
+  /* No action is required to mark an object on the free list.  */
+  return mark_stack_ptr;
+}
+
+struct GC_ms_entry *
+gt_tggc_m_atomic_obj (GC_word * object,
+		      struct GC_ms_entry * mark_stack_ptr,
+		      struct GC_ms_entry * mark_stack_limit)
+{
+  MAYBE_MARK (object);
+  return mark_stack_ptr;
+}
+
+struct GC_ms_entry *
+gt_tggc_m_nonexistent_obj (GC_word * object ATTRIBUTE_UNUSED,
+			   struct GC_ms_entry * mark_stack_ptr ATTRIBUTE_UNUSED,
+			   struct GC_ms_entry * mark_stack_limit ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable();
+  return NULL;
+}
+
+/* Typed marker entry point */
+struct GC_ms_entry *
+gt_tggc_m_mark_object (GC_word * object,
+		       struct GC_ms_entry * mark_stack_ptr,
+		       struct GC_ms_entry * mark_stack_limit,
+		       GC_word env ATTRIBUTE_UNUSED)
+{
+  mark_stack_ptr = (typed_markers[ggc_get_block_type(object)])(object,
+							       mark_stack_ptr,
+							       mark_stack_limit);
+  return mark_stack_ptr;
+}
+
 int
 ggc_marked_p (const void * d ATTRIBUTE_UNUSED)
 {
@@ -341,11 +397,17 @@
 }
 
 int
+ggc_consider_for_marking (const void * ptr)
+{
+  return (ptr != NULL) && (ptr != (void *)1);
+}
+/*
+int
 ggc_set_mark (const void * block ATTRIBUTE_UNUSED)
 {
   abort();
 }
-
+*/
 struct ggc_pch_data *
 init_ggc_pch (void)
 {
@@ -405,3 +467,8 @@
   if (!quiet_flag)
     (*default_warn_proc)(msg, arg);
 }
+
+void *ggc_alloc_conservative(size_t s)
+{
+  return GC_MALLOC (s);
+}
Index: gcc/valgrind-support.h
===================================================================
--- gcc/valgrind-support.h	(revision 0)
+++ gcc/valgrind-support.h	(revision 0)
@@ -0,0 +1,41 @@
+/* Support for --enable-checking=valgrind.
+   Copyright (C) 2006
+   Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
+
+#ifndef GCC_VALGRIND_SUPPORT_H
+#define GCC_VALGRIND_SUPPORT_H
+
+#ifdef ENABLE_VALGRIND_CHECKING
+# ifdef HAVE_VALGRIND_MEMCHECK_H
+#  include <valgrind/memcheck.h>
+# elif defined HAVE_MEMCHECK_H
+#  include <memcheck.h>
+# else
+#  include <valgrind.h>
+# endif
+#else
+/* Avoid #ifdef:s when we can help it.  */
+#define VALGRIND_DISCARD(x)
+#define VALGRIND_MALLOCLIKE_BLOCK(x, y, z, t)
+#define VALGRIND_FREELIKE_BLOCK(x, y)
+#define VALGRIND_MAKE_NOACCESS(x, y)
+#endif
+
+#endif
Index: gcc/c-format.c
===================================================================
--- gcc/c-format.c	(revision 116310)
+++ gcc/c-format.c	(working copy)
@@ -280,6 +280,8 @@
   struct format_wanted_type *next;
 } format_wanted_type;
 
+#define ggc_alloc_format_wanted_type()					\
+  ((struct format_wanted_type *)ggc_alloc_atomic (sizeof (struct format_wanted_type)))
 
 static const format_length_info printf_length_specs[] =
 {
@@ -2077,7 +2079,7 @@
 	      fci = fci->chain;
 	      if (fci)
 		{
-		  wanted_type_ptr = ggc_alloc_atomic (sizeof (struct format_wanted_type));
+		  wanted_type_ptr = ggc_alloc_format_wanted_type();
 		  arg_num++;
 		  wanted_type = *fci->types[length_chars_val].type;
 		  wanted_type_name = fci->types[length_chars_val].name;
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 116231)
+++ gcc/dwarf2out.c	(working copy)
@@ -2610,8 +2610,7 @@
 dwarf2out_frame_init (void)
 {
   /* Allocate the initial hunk of the fde_table.  */
-  fde_table = ggc_alloc_vec_atomic (sizeof (dw_fde_node),
-					   FDE_TABLE_INCREMENT);
+  fde_table = ggc_alloc_vec_dw_fde_node (FDE_TABLE_INCREMENT);
   fde_table_allocated = FDE_TABLE_INCREMENT;
   fde_table_in_use = 0;
 
@@ -13754,8 +13753,9 @@
   decl_scope_table = VEC_alloc (tree, gc, 256);
 
   /* Allocate the initial hunk of the abbrev_die_table.  */
-  abbrev_die_table = ggc_alloc_cleared_vec_atomic (sizeof(dw_die_ref),
-						   ABBREV_DIE_TABLE_INCREMENT);
+  abbrev_die_table = //ggc_alloc_cleared_vec_atomic (sizeof(dw_die_ref),
+    //			   ABBREV_DIE_TABLE_INCREMENT); TODO!!!
+    ggc_alloc_conservative (sizeof (dw_die_ref) * ABBREV_DIE_TABLE_INCREMENT);
   abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT;
   /* Zero-th entry is allocated, but unused.  */
   abbrev_die_table_in_use = 1;
Index: gcc/local-alloc.c
===================================================================
--- gcc/local-alloc.c	(revision 116231)
+++ gcc/local-alloc.c	(working copy)
@@ -801,7 +801,8 @@
 
   reg_equiv = XCNEWVEC (struct equivalence, max_regno);
   INIT_REG_SET (&cleared_regs);
-  reg_equiv_init = ggc_alloc_cleared_vec_atomic (sizeof (rtx), max_regno);
+  reg_equiv_init = // ggc_alloc_cleared_vec_atomic (sizeof (rtx), max_regno); TODO!!!
+    ggc_alloc_conservative (sizeof (rtx) * max_regno);
   reg_equiv_init_size = max_regno;
 
   init_alias_analysis ();
Index: gcc/alias.c
===================================================================
--- gcc/alias.c	(revision 116231)
+++ gcc/alias.c	(working copy)
@@ -2421,8 +2421,9 @@
   timevar_push (TV_ALIAS_ANALYSIS);
 
   reg_known_value_size = maxreg - FIRST_PSEUDO_REGISTER;
-  reg_known_value = ggc_alloc_cleared_vec_atomic (reg_known_value_size,
-						  sizeof (rtx));
+  reg_known_value = //ggc_alloc_cleared_vec_atomic (reg_known_value_size, // TODO !!!
+    ///				  sizeof (rtx));
+    ggc_alloc_conservative (reg_known_value_size * sizeof (rtx));
   reg_known_equiv_p = xcalloc (reg_known_value_size, sizeof (bool));
 
   /* If we have memory allocated from the previous run, use it.  */
Index: gcc/ggc.h
===================================================================
--- gcc/ggc.h	(revision 116231)
+++ gcc/ggc.h	(working copy)
@@ -23,6 +23,8 @@
 #define GCC_GGC_H
 #include "statistics.h"
 
+#include <gc.h>
+
 /* Symbols are marked with `ggc' for `gcc gc' so as not to interfere with
    an external gc library that might be linked in.  */
 
@@ -94,25 +96,53 @@
 /* Pointers to arrays of ggc_cache_tab, terminated by NULL.  */
 extern const struct ggc_cache_tab * const gt_ggc_cache_rtab[];
 
+/* Marker routines  */
+
+struct GC_ms_entry;
+extern struct GC_ms_entry * gt_tggc_m_mark_object (GC_word *,
+						   struct GC_ms_entry *,
+						   struct GC_ms_entry *,
+						   GC_word);
+
+/* Tagged GGC marker for an object residing on the free-list.  */
+extern struct GC_ms_entry * gt_tggc_m_free_list_obj (GC_word *,
+						     struct GC_ms_entry *,
+						     struct GC_ms_entry *);
+
+/* Tagged GGC marker for an atomic object.  */
+extern struct GC_ms_entry * gt_tggc_m_atomic_obj (GC_word *,
+						  struct GC_ms_entry *,
+						  struct GC_ms_entry *);
+
+/* Sentinel tagged GGC marker for an object of nonexistent type.  */
+extern struct GC_ms_entry * gt_tggc_m_nonexistent_obj (GC_word *,
+						       struct GC_ms_entry *,
+						       struct GC_ms_entry *);
+
 /* 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_test_and_set_mark(EXPR)					\
+  ((EXPR) != NULL && ((void *) (EXPR)) != (void *) 1 && ! ggc_set_mark (EXPR)) */
+#define ggc_test_and_set_mark(EXPR) 0
 
-#define ggc_mark(EXPR)				\
-  do {						\
+
+/*#define ggc_mark(EXPR)			\
+  do {					\
     const void *const a__ = (EXPR);		\
     if (a__ != NULL && a__ != (void *) 1)	\
       ggc_set_mark (a__);			\
-  } while (0)
+      } while (0) */
+#define ggc_mark(EXPR) abort()
 
 /* 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; nonzero 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	(const void *);
+//extern int ggc_set_mark	(const void *);
+#define ggc_set_mark(x) abort()
 
+extern int ggc_consider_for_marking (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.  */
@@ -201,6 +231,8 @@
 /* When set, ggc_collect will do collection.  */
 extern bool ggc_force_collect;
 
+extern void *ggc_alloc_conservative (size_t);
+
 /* The internal primitive.  */
 extern void *ggc_internal_alloc_stat (size_t MEM_STAT_DECL);
 #define ggc_internal_alloc(s) ggc_internal_alloc_stat (s MEM_STAT_INFO)
@@ -210,7 +242,7 @@
 #define ggc_alloc_typed(s,z) ggc_alloc_typed_stat (s,z MEM_STAT_INFO)
 #define ggc_alloc_vec_typed(s, z) ggc_alloc_typed_stat (s,z MEM_STAT_INFO)
 
-/* Like ggc_alloc, but allocates cleared memory.  */
+/* Like ggc_alloc, but clears allocated memory.  */
 extern void *ggc_internal_alloc_cleared_stat (size_t MEM_STAT_DECL);
 extern void *ggc_alloc_cleared_typed_stat (enum gt_types_enum,
 					   size_t MEM_STAT_DECL);
@@ -263,6 +295,12 @@
 #define htab_create_ggc(SIZE, HASH, EQ, DEL) \
   htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_calloc_atomic, NULL)
 
+// extern void *ggc_internal_calloc (size_t, size_t);
+
+/* #define htab_create_ggc(SIZE, HASH, EQ, DEL)				\
+   htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_internal_calloc, NULL */
+
+
 #define splay_tree_new_ggc(COMPARE)				       \
   splay_tree_new_with_allocator (COMPARE, NULL, NULL,		       \
 				 &ggc_splay_alloc_tree,		       \
@@ -289,6 +327,9 @@
 /* Return the number of bytes allocated at the indicated address.  */
 extern size_t ggc_get_size (const void *);
 
+/* Return the type of the allocated block by its starting address.  */
+extern enum gt_types_enum ggc_get_block_type(const void *);
+
 /* Write out all GCed objects to F.  */
 extern void gt_pch_save (FILE *f);
 
Index: gcc/ggc-common.c
===================================================================
--- gcc/ggc-common.c	(revision 116310)
+++ gcc/ggc-common.c	(working copy)
@@ -136,8 +136,7 @@
 void *
 ggc_internal_alloc_cleared_stat (size_t size MEM_STAT_DECL)
 {
-  void *buf = ggc_internal_alloc_stat (size PASS_MEM_STAT);
-  memset (buf, 0, size);
+  void *buf = ggc_alloc_cleared_atomic_stat (size);
   return buf;
 }
 
Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c	(revision 116231)
+++ gcc/emit-rtl.c	(working copy)
@@ -4983,8 +4983,9 @@
     = ggc_alloc_cleared_vec_atomic (f->emit->regno_pointer_align_length,
 				    sizeof (unsigned char));
 
-  regno_reg_rtx
-    = ggc_alloc_vec_atomic (f->emit->regno_pointer_align_length, sizeof(rtx));
+  regno_reg_rtx // TODO !!!
+    // = ggc_alloc_vec_atomic (f->emit->regno_pointer_align_length, sizeof(rtx));
+    = ggc_alloc_conservative (f->emit->regno_pointer_align_length * sizeof(rtx));
 
   /* Put copies of all the hard registers into regno_reg_rtx.  */
   memcpy (regno_reg_rtx,
Index: gcc/ggc-page.c
===================================================================
--- gcc/ggc-page.c	(revision 116135)
+++ gcc/ggc-page.c	(working copy)
@@ -32,18 +32,7 @@
 #include "timevar.h"
 #include "params.h"
 #include "tree-flow.h"
-#ifdef ENABLE_VALGRIND_CHECKING
-# ifdef HAVE_VALGRIND_MEMCHECK_H
-#  include <valgrind/memcheck.h>
-# elif defined HAVE_MEMCHECK_H
-#  include <memcheck.h>
-# else
-#  include <valgrind.h>
-# endif
-#else
-/* Avoid #ifdef:s when we can help it.  */
-#define VALGRIND_DISCARD(x)
-#endif
+#include "valgrind-support.h"
 
 /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
    file open.  Prefer either to valloc.  */
@@ -434,16 +423,16 @@
     /* Total allocations and overhead for sizes less than 32, 64 and 128.
        These sizes are interesting because they are typical cache line
        sizes.  */
-   
+
     unsigned long long total_allocated_under32;
     unsigned long long total_overhead_under32;
-  
+
     unsigned long long total_allocated_under64;
     unsigned long long total_overhead_under64;
-  
+
     unsigned long long total_allocated_under128;
     unsigned long long total_overhead_under128;
-  
+
     /* The allocations for each of the allocation orders.  */
     unsigned long long total_allocated_per_order[NUM_ORDERS];
 
Index: gcc/lambda-code.c
===================================================================
--- gcc/lambda-code.c	(revision 116231)
+++ gcc/lambda-code.c	(working copy)
@@ -3,17 +3,17 @@
     Contributed by Daniel Berlin <dberlin@dberlin.org>
 
     This file is part of GCC.
-    
+
     GCC is free software; you can redistribute it and/or modify it under
     the terms of the GNU General Public License as published by the Free
     Software Foundation; either version 2, or (at your option) any later
     version.
-    
+
     GCC is distributed in the hope that it will be useful, but WITHOUT ANY
     WARRANTY; without even the implied warranty of MERCHANTABILITY or
     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     for more details.
-    
+
     You should have received a copy of the GNU General Public License
     along with GCC; see the file COPYING.  If not, write to the Free
     Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
Index: gcc/integrate.c
===================================================================
--- gcc/integrate.c	(revision 116310)
+++ gcc/integrate.c	(working copy)
@@ -237,7 +237,7 @@
   ivs = cfun->hard_reg_initial_vals;
   if (ivs == 0)
     {
-      ivs = ggc_alloc_atomic (sizeof (struct initial_value_struct));
+      ivs = ggc_alloc_initial_value_struct();
       ivs->num_entries = 0;
       ivs->max_entries = 5;
       ivs->entries = ggc_alloc_vec_atomic (5,
Index: gcc/c-parser.c
===================================================================
--- gcc/c-parser.c	(revision 116231)
+++ gcc/c-parser.c	(working copy)
@@ -235,7 +235,8 @@
   if (!c_dialect_objc ())
      mask |= D_OBJC;
 
-  ridpointers = GGC_CNEWVEC_ATOMIC (tree, (int) RID_MAX);
+  ridpointers = // GGC_CNEWVEC_ATOMIC (tree, (int) RID_MAX); TODO !!!
+    ggc_alloc_conservative (sizeof (tree) * (int) RID_MAX);
   for (i = 0; i < N_reswords; i++)
     {
       /* If a keyword is disabled, do not enter it into the table
Index: boehm-gc/include/gc_mark.h
===================================================================
--- boehm-gc/include/gc_mark.h	(revision 116135)
+++ boehm-gc/include/gc_mark.h	(working copy)
@@ -18,7 +18,7 @@
  * clients that provide detailed heap layout information to the collector.
  * This interface should not be used by normal C or C++ clients.
  * It will be useful to runtimes for other languages.
- * 
+ *
  * This is an experts-only interface!  There are many ways to break the
  * collector in subtle ways by using this functionality.
  */
Index: libiberty/hashtab.c
===================================================================
--- libiberty/hashtab.c	(revision 116135)
+++ libiberty/hashtab.c	(working copy)
@@ -612,7 +612,7 @@
     first_deleted_slot = &htab->entries[index];
   else if ((*htab->eq_f) (entry, element))
     return &htab->entries[index];
-      
+
   hash2 = htab_mod_m2 (hash, htab);
   for (;;)
     {
@@ -620,7 +620,7 @@
       index += hash2;
       if (index >= size)
 	index -= size;
-      
+
       entry = htab->entries[index];
       if (entry == HTAB_EMPTY_ENTRY)
 	goto empty_entry;
@@ -717,7 +717,7 @@
 {
   PTR *slot;
   PTR *limit;
-  
+
   slot = htab->entries;
   limit = slot + htab_size (htab);
 
@@ -739,7 +739,7 @@
 htab_traverse (htab_t htab, htab_trav callback, PTR info)
 {
   if (htab_elements (htab) * 8 < htab_size (htab))
-    htab_expand (htab);
+      htab_expand (htab);
 
   htab_traverse_noresize (htab, callback, info);
 }
Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c	(revision 116135)
+++ libcpp/macro.c	(working copy)
@@ -741,6 +741,7 @@
   if (! (node->flags & NODE_BUILTIN))
     {
       cpp_macro *macro = node->value.macro;
+      _cpp_valid_token_p (pfile, macro->exp.tokens);
 
       if (macro->fun_like)
 	{
@@ -807,6 +808,7 @@
   for (src = macro->exp.tokens; src < limit; src++)
     if (src->type == CPP_MACRO_ARG)
       {
+	_cpp_valid_token_p (pfile, src);
 	/* Leading and trailing padding tokens.  */
 	total += 2;
 
@@ -960,6 +962,8 @@
 {
   cpp_context *context = next_context (pfile);
 
+  _cpp_valid_token_p (pfile, *first);
+
   context->direct_p = false;
   context->macro = macro;
   context->buff = buff;
@@ -974,6 +978,8 @@
 {
   cpp_context *context = next_context (pfile);
 
+  _cpp_valid_token_p (pfile, first);
+
   context->direct_p = true;
   context->macro = macro;
   context->buff = NULL;
@@ -1538,6 +1544,7 @@
     }
 
   macro->exp.tokens = (cpp_token *) BUFF_FRONT (pfile->a_buff);
+  _cpp_valid_token_p (pfile, macro->exp.tokens);
   macro->traditional = 0;
 
   /* Don't count the CPP_EOF.  */
@@ -1555,6 +1562,7 @@
                                                           * macro->count);
       memcpy (tokns, macro->exp.tokens, sizeof (cpp_token) * macro->count);
       macro->exp.tokens = tokns;
+      _cpp_valid_token_p (pfile, macro->exp.tokens);
     }
   else
     BUFF_FRONT (pfile->a_buff) = (uchar *) &macro->exp.tokens[macro->count];
Index: libcpp/internal.h
===================================================================
--- libcpp/internal.h	(revision 116135)
+++ libcpp/internal.h	(working copy)
@@ -535,6 +535,7 @@
 extern struct op *_cpp_expand_op_stack (cpp_reader *);
 
 /* In lex.c */
+extern bool _cpp_valid_token_p (cpp_reader *, const cpp_token * const);
 extern void _cpp_process_line_notes (cpp_reader *, int);
 extern void _cpp_clean_line (cpp_reader *);
 extern bool _cpp_get_fresh_line (cpp_reader *);
Index: libcpp/lex.c
===================================================================
--- libcpp/lex.c	(revision 116135)
+++ libcpp/lex.c	(working copy)
@@ -63,6 +63,17 @@
 
 static _cpp_buff *new_buff (size_t);
 
+bool
+_cpp_valid_token_p (cpp_reader * pfile, const cpp_token * const token)
+{
+  if (token->type >= sizeof(token_spellings) / sizeof(struct token_spelling))
+    {
+      cpp_error (pfile, CPP_DL_ICE, "unknown type of token %s",
+		 TOKEN_NAME (token));
+      return 0;
+    }
+  return 1;
+}
 
 /* Utility routine:
 
@@ -595,6 +606,8 @@
   token->type = type;
   token->val.str.len = len;
   token->val.str.text = dest;
+
+  _cpp_valid_token_p (pfile, token);
 }
 
 /* Lexes a string, character constant, or angle-bracketed header file
@@ -979,6 +992,7 @@
 	{
 	  result->flags |= NAMED_OP;
 	  result->type = (enum cpp_ttype) result->val.node->directive_index;
+	  _cpp_valid_token_p (pfile, result);
 	}
       break;
 
@@ -1338,6 +1352,11 @@
       cpp_error (pfile, CPP_DL_ICE,
 		 "unspellable token %s", TOKEN_NAME (token));
       break;
+    default:
+      _cpp_valid_token_p (pfile, token);
+      /*      cpp_error (pfile, CPP_DL_ICE,
+	      "unknown type of token %s", TOKEN_NAME (token)); */
+      break;
     }
 
   return buffer;
@@ -1347,7 +1366,7 @@
    freed when the reader is destroyed.  Useful for diagnostics.  */
 unsigned char *
 cpp_token_as_text (cpp_reader *pfile, const cpp_token *token)
-{ 
+{
   unsigned int len = cpp_token_len (token) + 1;
   unsigned char *start = _cpp_unaligned_alloc (pfile, len), *end;
 

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