summaryrefslogtreecommitdiff
path: root/gcc/alloc-pool.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2015-06-03 11:33:32 +0200
committerMartin Liska <marxin@gcc.gnu.org>2015-06-03 09:33:32 +0000
commitac05926156c0997b191af1176122ee3d8663d19e (patch)
tree125beb54d6d03f07b223139332359997e5d92a29 /gcc/alloc-pool.c
parent8a810680ee212c8c01239699859a4dd395db6174 (diff)
Port pool-allocator memory stats to a new infrastructure.
* alloc-pool.c (allocate_pool_descriptor): Remove. (struct pool_output_info): Likewise. (print_alloc_pool_statistics): Likewise. (dump_alloc_pool_statistics): Likewise. * alloc-pool.h (struct pool_usage): New struct. (pool_allocator::initialize): Change usage of memory statistics to a new interface. (pool_allocator::release): Likewise. (pool_allocator::allocate): Likewise. (pool_allocator::remove): Likewise. * mem-stats-traits.h (enum mem_alloc_origin): Add new enum value for a pool allocator. * mem-stats.h (struct mem_location): Add new ctor. (struct mem_usage): Add counter for number of instances. (mem_alloc_description::register_descriptor): New overload of * mem-stats.h (mem_location::to_string): New function. * bitmap.h (struct bitmap_usage): Use this new function. * ggc-common.c (struct ggc_usage): Likewise. the function. From-SVN: r224070
Diffstat (limited to 'gcc/alloc-pool.c')
-rw-r--r--gcc/alloc-pool.c60
1 files changed, 2 insertions, 58 deletions
diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c
index e9fdc86b016..601c2b73f81 100644
--- a/gcc/alloc-pool.c
+++ b/gcc/alloc-pool.c
@@ -26,70 +26,14 @@ along with GCC; see the file COPYING3. If not see
#include "hash-map.h"
ALLOC_POOL_ID_TYPE last_id;
-
-/* Hashtable mapping alloc_pool names to descriptors. */
-hash_map<const char *, alloc_pool_descriptor> *alloc_pool_hash;
-
-struct alloc_pool_descriptor *
-allocate_pool_descriptor (const char *name)
-{
- if (!alloc_pool_hash)
- alloc_pool_hash = new hash_map<const char *, alloc_pool_descriptor> (10,
- false,
- false);
-
- return &alloc_pool_hash->get_or_insert (name);
-}
-
-/* Output per-alloc_pool statistics. */
-
-/* Used to accumulate statistics about alloc_pool sizes. */
-struct pool_output_info
-{
- unsigned long total_created;
- unsigned long total_allocated;
-};
-
-/* Called via hash_map.traverse. Output alloc_pool descriptor pointed out by
- SLOT and update statistics. */
-bool
-print_alloc_pool_statistics (const char *const &name,
- const alloc_pool_descriptor &d,
- struct pool_output_info *i)
-{
- if (d.allocated)
- {
- fprintf (stderr,
- "%-22s %6d %10lu %10lu(%10lu) %10lu(%10lu) %10lu(%10lu)\n",
- name, d.elt_size, d.created, d.allocated,
- d.allocated / d.elt_size, d.peak, d.peak / d.elt_size,
- d.current, d.current / d.elt_size);
- i->total_allocated += d.allocated;
- i->total_created += d.created;
- }
- return 1;
-}
+mem_alloc_description<pool_usage> pool_allocator_usage;
/* Output per-alloc_pool memory usage statistics. */
void
dump_alloc_pool_statistics (void)
{
- struct pool_output_info info;
-
if (! GATHER_STATISTICS)
return;
- if (!alloc_pool_hash)
- return;
-
- fprintf (stderr, "\nAlloc-pool Kind Elt size Pools Allocated (elts) Peak (elts) Leak (elts)\n");
- fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
- info.total_created = 0;
- info.total_allocated = 0;
- alloc_pool_hash->traverse <struct pool_output_info *,
- print_alloc_pool_statistics> (&info);
- fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
- fprintf (stderr, "%-22s %7lu %10lu\n",
- "Total", info.total_created, info.total_allocated);
- fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
+ pool_allocator_usage.dump (ALLOC_POOL);
}