[PCH] improve performance

Geoffrey Keating geoffk@romulus.sfbay.redhat.com
Fri May 17 11:03:00 GMT 2002


This brings pch-branch performance back to about the level of the
original GC, by inlining the test for a NULL pointer.

I tried lots of other things, including:

- Explicitly implementing the stack
- Replacing some recursive calls by loops
- Marking an object in the caller

but none of these did as well as this simple patch.

Bootstrapped & tested on i686-pc-linux-gnu.

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/pchbranch-gofaster-1.patch================
2002-05-15  Geoffrey Keating  <geoffk@redhat.com>

	* gengtype.c (write_gc_marker_routine_for_structure): Name
	the routines 'gt_ggc_mx_*' instead of 'gt_ggc_m_*'.  
	(write_gc_types): Arrange for the tests with NULL to be inlined.
	(write_gc_roots): Update uses of procedure pointers.
	* ggc-common.c (gt_ggc_mx_rtx_def): Rename from gt_ggc_m_rtx_def.

Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gengtype.c,v
retrieving revision 1.1.2.18
diff -p -u -p -r1.1.2.18 gengtype.c
--- gengtype.c	14 May 2002 22:31:14 -0000	1.1.2.18
+++ gengtype.c	15 May 2002 18:08:31 -0000
@@ -1232,7 +1232,7 @@ write_gc_marker_routine_for_structure (s
   fputc ('\n', f);
   fputs ("void\n", f);
   if (param == NULL)
-    fprintf (f, "gt_ggc_m_%s (x_p)\n", s->u.s.tag);
+    fprintf (f, "gt_ggc_mx_%s (x_p)\n", s->u.s.tag);
   else
     fprintf (f, "gt_ggc_mm_%d%s_%s (x_p)\n", strlen (param->u.s.tag),
 	     param->u.s.tag, s->u.s.tag);
@@ -1271,6 +1271,13 @@ write_gc_types (structures, param_struct
 	    && s->u.s.line.file == NULL)
 	  continue;
 
+	fprintf (header_file,
+		 "#define gt_ggc_m_%s(X) do { \\\n", s->u.s.tag);
+	fprintf (header_file,
+		 "  if (X != NULL) gt_ggc_mx_%s (X);\\\n", s->u.s.tag);
+	fprintf (header_file,
+		 "  } while (0)\n");
+	
 	for (opt = s->u.s.opt; opt; opt = opt->next)
 	  if (strcmp (opt->name, "ptr_alias") == 0)
 	    {
@@ -1279,7 +1286,7 @@ write_gc_types (structures, param_struct
 		  || t->kind == TYPE_UNION
 		  || t->kind == TYPE_LANG_STRUCT)
 		fprintf (header_file,
-			 "#define gt_ggc_m_%s gt_ggc_m_%s\n",
+			 "#define gt_ggc_mx_%s gt_ggc_mx_%s\n",
 			 s->u.s.tag, t->u.s.tag);
 	      else
 		error_at_line (&s->u.s.line, 
@@ -1291,7 +1298,7 @@ write_gc_types (structures, param_struct
 
 	/* Declare the marker procedure only once.  */
 	fprintf (header_file, 
-		 "extern void gt_ggc_m_%s PARAMS ((void *));\n",
+		 "extern void gt_ggc_mx_%s PARAMS ((void *));\n",
 		 s->u.s.tag);
   
 	if (s->u.s.line.file == NULL)
@@ -1553,7 +1560,7 @@ write_gc_root (f, v, type, name, has_len
 	if (! has_length
 	    && (tp->kind == TYPE_UNION || tp->kind == TYPE_STRUCT))
 	  {
-	    fprintf (f, "    &gt_ggc_m_%s", tp->u.s.tag);
+	    fprintf (f, "    &gt_ggc_mx_%s\n", tp->u.s.tag);
 	  }
 	else if (! has_length && tp->kind == TYPE_PARAM_STRUCT)
 	  {
Index: ggc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-common.c,v
retrieving revision 1.46.4.14
diff -p -u -p -r1.46.4.14 ggc-common.c
--- ggc-common.c	14 May 2002 22:31:14 -0000	1.46.4.14
+++ ggc-common.c	15 May 2002 18:08:31 -0000
@@ -335,7 +335,7 @@ ggc_mark_tree_varray_ptr (elt)
 
 /* Various adaptor functions.  */
 void
-gt_ggc_m_rtx_def (x)
+gt_ggc_mx_rtx_def (x)
      void *x;
 {
   ggc_mark_rtx((rtx)x);
============================================================



More information about the Gcc-patches mailing list