diff options
author | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-05-27 12:47:22 +0000 |
---|---|---|
committer | marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-05-27 12:47:22 +0000 |
commit | 0ff42de5540c1e13b681449fdca9848ad13bf69b (patch) | |
tree | 4505b8171553fd7e780bb28532a4986cd72b6f4f /gcc/hash-map.h | |
parent | e3039589e2b21cccaa24e8fddab97045dfd3da9c (diff) | |
download | gcc-0ff42de5540c1e13b681449fdca9848ad13bf69b.tar.gz |
New memory allocation statistics infrastructure.
* Makefile.in: Add additional dependencies related to memory report
enhancement.
* alloc-pool.c (allocate_pool_descriptor): Use new ctor.
* bitmap.c (struct bitmap_descriptor_d): Remove.
(struct loc): Likewise.
(struct bitmap_desc_hasher): Likewise.
(bitmap_desc_hasher::hash): Likewise.
(bitmap_desc_hasher::equal): Likewise.
(get_bitmap_descriptor): Likewise.
(bitmap_register): User new memory descriptor API.
(register_overhead): Likewise.
(bitmap_find_bit): Register nsearches and search_iter statistics.
(struct bitmap_output_info): Remove.
(print_statistics): Likewise.
(dump_bitmap_statistics): Use new memory descriptor.
* bitmap.h (struct bitmap_usage): New class.
* genmatch.c: Extend header file inclusion.
* genpreds.c: Likewise.
* ggc-common.c (struct ggc_usage): New class.
(struct ggc_loc_desc_hasher): Remove.
(ggc_loc_desc_hasher::hash): Likewise.
(ggc_loc_desc_hasher::equal): Likewise.
(struct ggc_ptr_hash_entry): Likewise.
(struct ptr_hash_hasher): Likewise.
(ptr_hash_hasher::hash): Likewise.
(ptr_hash_hasher::equal): Likewise.
(make_loc_descriptor): Likewise.
(ggc_prune_ptr): Likewise.
(dump_ggc_loc_statistics): Use new memory descriptor.
(ggc_record_overhead): Likewise.
(ggc_free_overhead): Likewise.
(final_cmp_statistic): Remove.
(cmp_statistic): Likewise.
(ggc_add_statistics): Liekwise.
(ggc_prune_overhead_list): Likewise.
* hash-map-traits.h: New file.
* hash-map.h (struct default_hashmap_traits): Move the traits to a
separate header file.
* hash-set.h: Pass memory statistics info to ctor.
* hash-table.c (void dump_hash_table_loc_statistics): New function.
* hash-table.h (hash_table::hash_table): Add new ctor arguments.
(hash_table::~hash_table): Register memory release operation.
(hash_table::alloc_entries): Handle memory allocation operation.
(hash_table::expand): Likewise.
* inchash.c (iterative_hash_hashval_t): Move implementation to header
file.
(iterative_hash_host_wide_int): Likewise.
* inchash.h (class hash): Likewise.
* mem-stats-traits.h: New file.
* mem-stats.h: New file.
(mem_location): Add new class.
(mem_usage): Likewise.
(mem_alloc_description): Likewise.
* sese.c: Add new header file inclusision.
* toplev.c (dump_memory_report): Add report for hash_table, hash_map
and hash_set.
* tree-sra.c: Add new header file inclusision.
* vec.c (struct vec_descriptor): Remove.
(hash_descriptor): Likewise.
(struct vec_usage): Likewise.
(struct ptr_hash_entry): Likewise.
(hash_ptr): Likewise.
(eq_ptr): Likewise.
(vec_prefix::register_overhead): Use new memory descriptor API.
(vec_prefix::release_overhead): Likewise.
(add_statistics): Remove.
(dump_vec_loc_statistics): Use new memory descriptor API.
* vec.h (struct vec_prefix): Likewise.
(va_heap::reserve): Likewise.
(va_heap::release): Likewise.
* emit-rtl.c (gen_raw_REG): Fix passing MEM_STAT.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223748 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/hash-map.h')
-rw-r--r-- | gcc/hash-map.h | 92 |
1 files changed, 10 insertions, 82 deletions
diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 4cca702a0e2..fb1a522a25d 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -24,87 +24,12 @@ along with GCC; see the file COPYING3. If not see #include <new> #include <utility> #include "hash-table.h" - -/* implement default behavior for traits when types allow it. */ - -struct default_hashmap_traits -{ - /* Hashes the passed in key. */ - - template<typename T> - static hashval_t - hash (T *p) - { - return uintptr_t(p) >> 3; - } - - /* If the value converts to hashval_t just use it. */ - - template<typename T> static hashval_t hash (T v) { return v; } - - /* Return true if the two keys passed as arguments are equal. */ - - template<typename T> - static bool - equal_keys (const T &a, const T &b) - { - return a == b; - } - - /* Called to dispose of the key and value before marking the entry as - deleted. */ - - template<typename T> static void remove (T &v) { v.~T (); } - - /* Mark the passed in entry as being deleted. */ - - template<typename T> - static void - mark_deleted (T &e) - { - mark_key_deleted (e.m_key); - } - - /* Mark the passed in entry as being empty. */ - - template<typename T> - static void - mark_empty (T &e) - { - mark_key_empty (e.m_key); - } - - /* Return true if the passed in entry is marked as deleted. */ - - template<typename T> - static bool - is_deleted (T &e) - { - return e.m_key == (void *)1; - } - - /* Return true if the passed in entry is marked as empty. */ - - template<typename T> static bool is_empty (T &e) { return e.m_key == NULL; } - -private: - template<typename T> - static void - mark_key_deleted (T *&k) - { - k = reinterpret_cast<T *> (1); - } - - template<typename T> - static void - mark_key_empty (T *&k) - { - k = static_cast<T *> (0); - } -}; +#include "hash-map-traits.h" +#include "mem-stats.h" +#include "vec.h" template<typename Key, typename Value, - typename Traits = default_hashmap_traits> + typename Traits> class GTY((user)) hash_map { struct hash_entry @@ -187,13 +112,16 @@ class GTY((user)) hash_map }; public: - explicit hash_map (size_t n = 13, bool ggc = false) : m_table (n, ggc) {} + explicit hash_map (size_t n = 13, bool ggc = false, + bool gather_mem_stats = true CXX_MEM_STAT_INFO) + : m_table (n, ggc, gather_mem_stats, HASH_MAP PASS_MEM_STAT) {} /* Create a hash_map in ggc memory. */ - static hash_map *create_ggc (size_t size) + static hash_map *create_ggc (size_t size, bool gather_mem_stats = true + CXX_MEM_STAT_INFO) { hash_map *map = ggc_alloc<hash_map> (); - new (map) hash_map (size, true); + new (map) hash_map (size, true, gather_mem_stats PASS_MEM_STAT); return map; } |