summaryrefslogtreecommitdiff
path: root/gcc/ggc-page.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>1999-10-29 04:17:33 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>1999-10-29 04:17:33 +0000
commit4e00b6fd23bf82e4038e115609361fb0c62465f7 (patch)
tree8885ce2ea35f645ae60061b2f77bd345ad926d71 /gcc/ggc-page.c
parent637be39f421b23c745f14f52d76daf974cc93460 (diff)
downloadgcc-4e00b6fd23bf82e4038e115609361fb0c62465f7.tar.gz
* ggc.h (struct ggc_statistics): New type.
(ggc_get_size): New function. (ggc_print_statistics): Likewise. * ggc-common.c (ggc_stats): New variable. (ggc_mark_rtx_children): Keep statistics. (ggc_mark_tree_children): Likewise. (ggc_print_statistics): New function. * ggc-page.c (struct globals): Add bytes_mapped field. (alloc_anon): Update it. (release_pages): Likewise. (ggc_get_size): New function. (ggc_page_print_statistics): New function. * ggc-simple.c (ggc_get_size): New function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30251 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r--gcc/ggc-page.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index f034a4fb47f..c1cef10a5fc 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -226,6 +226,9 @@ static struct globals
/* Bytes currently allocated at the end of the last collection. */
size_t allocated_last_gc;
+ /* Total amount of memory mapped. */
+ size_t bytes_mapped;
+
/* The current depth in the context stack. */
unsigned char context_depth;
@@ -444,6 +447,9 @@ alloc_anon (pref, size)
#endif /* HAVE_VALLOC */
#endif /* HAVE_MMAP */
+ /* Remember that we allocated this memory. */
+ G.bytes_mapped += size;
+
return page;
}
@@ -565,6 +571,7 @@ release_pages ()
else
{
munmap (start, len);
+ G.bytes_mapped -= len;
start = p->page;
len = p->bytes;
}
@@ -573,6 +580,7 @@ release_pages ()
}
munmap (start, len);
+ G.bytes_mapped -= len;
#else
#ifdef HAVE_VALLOC
page_entry *p, *next;
@@ -581,6 +589,7 @@ release_pages ()
{
next = p->next;
free (p->page);
+ G.bytes_mapped -= p->bytes;
free (p);
}
#endif /* HAVE_VALLOC */
@@ -778,6 +787,14 @@ ggc_mark_if_gcable (p)
if (p && ggc_allocated_p (p))
ggc_set_mark (p);
}
+
+size_t
+ggc_get_size (p)
+ void *p;
+{
+ page_entry *pe = lookup_page_table_entry (p);
+ return 1 << pe->order;
+}
/* Initialize the ggc-mmap allocator. */
void
@@ -1088,3 +1105,51 @@ ggc_collect ()
(unsigned long) G.allocated / 1024, time * 1e-6);
}
}
+
+/* Print allocation statistics. */
+
+void
+ggc_page_print_statistics ()
+{
+ struct ggc_statistics stats;
+ int i;
+
+ /* Clear the statistics. */
+ bzero (&stats, sizeof (stats));
+
+ /* Make sure collection will really occur. */
+ G.allocated_last_gc = 0;
+
+ /* Collect and print the statistics common across collectors. */
+ ggc_print_statistics (stderr, &stats);
+
+ /* Collect some information about the various sizes of
+ allocation. */
+ fprintf (stderr, "\n%-4s%-16s%-16s\n", "Log", "Allocated", "Used");
+ for (i = 0; i < HOST_BITS_PER_PTR; ++i)
+ {
+ page_entry *p;
+ size_t allocated;
+ size_t in_use;
+
+ /* Skip empty entries. */
+ if (!G.pages[i])
+ continue;
+
+ allocated = in_use = 0;
+
+ /* Figure out the total number of bytes allocated for objects of
+ this size, and how many of them are actually in use. */
+ for (p = G.pages[i]; p; p = p->next)
+ {
+ allocated += p->bytes;
+ in_use +=
+ (OBJECTS_PER_PAGE (i) - p->num_free_objects) * (1 << i);
+ }
+ fprintf (stderr, "%-3d %-15u %-15u\n", i, allocated, in_use);
+ }
+
+ /* Print out some global information. */
+ fprintf (stderr, "\nTotal bytes marked: %u\n", G.allocated);
+ fprintf (stderr, "Total bytes mapped: %u\n", G.bytes_mapped);
+}