small GC tweak
Zack Weinberg
zackw@stanford.edu
Tue Jan 16 08:35:00 GMT 2001
When I was removing strings from the GC arena I missed one place where
we try to mark strings, because it was using ggc_mark_if_gcable
instead of ggc_mark_string. This patch eliminates that place. Since
that was the only user of ggc_mark_if_gcable, I've eliminated that
routine as well.
This should be a small performance improvement. However I do not have
numbers (and the compiler seems to be getting slower, overall,
lately).
Bootstrapped i686-linux; ok to apply? (after the branch?)
zw
* ggc-common.c (ggc_mark_rtx_children): No need to mark 'S' or
's' slots in RTXen.
* ggc-page.c, ggc-simple.c (ggc_mark_if_gcable): Delete function.
* ggc.h (ggc_mark_if_gcable): Delete prototype.
===================================================================
Index: ggc-common.c
--- ggc-common.c 2000/11/17 17:31:08 1.34
+++ ggc-common.c 2001/01/16 16:34:08
@@ -1,5 +1,5 @@
/* Simple garbage collection for the GNU compiler.
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -276,9 +276,6 @@ ggc_mark_rtx_children (r)
break;
case 'V': case 'E':
ggc_mark_rtvec (XVEC (r, i));
- break;
- case 'S': case 's':
- ggc_mark_if_gcable (XSTR (r, i));
break;
}
}
===================================================================
Index: ggc-page.c
--- ggc-page.c 2001/01/14 11:22:12 1.38
+++ ggc-page.c 2001/01/16 16:34:08
@@ -1001,16 +1001,6 @@ ggc_set_mark (p)
return 0;
}
-/* Mark P, but check first that it was allocated by the collector. */
-
-void
-ggc_mark_if_gcable (p)
- const void *p;
-{
- if (p && ggc_allocated_p (p))
- ggc_set_mark (p);
-}
-
/* Return the size of the gc-able object P. */
size_t
===================================================================
Index: ggc-simple.c
--- ggc-simple.c 2000/11/17 06:05:15 1.36
+++ ggc-simple.c 2001/01/16 16:34:08
@@ -1,5 +1,5 @@
/* Simple garbage collection for the GNU compiler.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -226,29 +226,6 @@ ggc_set_mark (p)
G.objects += 1;
return 0;
-}
-
-/* Mark a node, but check first to see that it's really gc-able memory. */
-
-void
-ggc_mark_if_gcable (p)
- const void *p;
-{
- struct ggc_mem *x;
-
- if (p == NULL)
- return;
-
- x = (struct ggc_mem *) ((const char *)p - offsetof (struct ggc_mem, u));
- if (! tree_lookup (x))
- return;
-
- if (x->mark)
- return;
-
- x->mark = 1;
- G.allocated += x->size;
- G.objects += 1;
}
/* Return the size of the gc-able object P. */
===================================================================
Index: ggc.h
--- ggc.h 2000/11/17 17:31:08 1.33
+++ ggc.h 2001/01/16 16:34:09
@@ -1,5 +1,5 @@
/* Garbage collection for the GNU compiler.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -99,9 +99,6 @@ extern void ggc_mark_rtvec_children PARA
ggc_set_mark (a__); \
} while (0)
-/* Mark, but only if it was allocated in collectable memory. */
-extern void ggc_mark_if_gcable PARAMS ((const void *));
-
/* A GC implementation must provide these functions. */
/* Initialize the garbage collector. */
@@ -141,8 +138,8 @@ const char *ggc_alloc_string PARAMS ((co
/* Make a copy of S, in GC-able memory. */
#define ggc_strdup(S) ggc_alloc_string((S), -1)
-/* Invoke the collector. This is really just a hint, but in the case of
- the simple collector, the only time it will happen. */
+/* Invoke the collector. Garbage collection occurs only when this
+ function is called, not during allocations. */
void ggc_collect PARAMS ((void));
/* Actually set the mark on a particular region of memory, but don't
More information about the Gcc-patches
mailing list