mem-stats.h (mem_alloc_description::unregister_descriptor): New method.

* mem-stats.h (mem_alloc_description::unregister_descriptor): New
	method.
	(mem_alloc_description::release_object_overhead): Fix comment typos.
	* hash-table.h (hash_table::~hash_table): Call
	release_instance_overhead only if m_entries is non-NULL, otherwise
	call unregister_descriptor.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r269943
This commit is contained in:
Jason Merrill 2019-03-26 09:38:53 -04:00 committed by Jakub Jelinek
parent 11767f80f0
commit a6f3616693
3 changed files with 35 additions and 7 deletions

View File

@ -1,3 +1,13 @@
2019-03-26 Jason Merrill <jason@redhat.com>
Jakub Jelinek <jakub@redhat.com>
* mem-stats.h (mem_alloc_description::unregister_descriptor): New
method.
(mem_alloc_description::release_object_overhead): Fix comment typos.
* hash-table.h (hash_table::~hash_table): Call
release_instance_overhead only if m_entries is non-NULL, otherwise
call unregister_descriptor.
2019-03-26 Bin Cheng <bin.cheng@linux.alibaba.com> 2019-03-26 Bin Cheng <bin.cheng@linux.alibaba.com>
PR tree-optimization/81740 PR tree-optimization/81740

View File

@ -652,12 +652,13 @@ hash_table<Descriptor, Lazy, Allocator>::~hash_table ()
Allocator <value_type> ::data_free (m_entries); Allocator <value_type> ::data_free (m_entries);
else else
ggc_free (m_entries); ggc_free (m_entries);
if (m_gather_mem_stats)
hash_table_usage ().release_instance_overhead (this,
sizeof (value_type)
* m_size, true);
} }
else if (m_gather_mem_stats)
if (m_gather_mem_stats) hash_table_usage ().unregister_descriptor (this);
hash_table_usage ().release_instance_overhead (this,
sizeof (value_type)
* m_size, true);
} }
/* This function returns an array of empty hash table elements. */ /* This function returns an array of empty hash table elements. */

View File

@ -342,9 +342,15 @@ public:
T *release_instance_overhead (void *ptr, size_t size, T *release_instance_overhead (void *ptr, size_t size,
bool remove_from_map = false); bool remove_from_map = false);
/* Release intance object identified by PTR pointer. */ /* Release instance object identified by PTR pointer. */
void release_object_overhead (void *ptr); void release_object_overhead (void *ptr);
/* Unregister a memory allocation descriptor registered with
register_descriptor (remove from reverse map), unless it is
unregistered through release_instance_overhead with
REMOVE_FROM_MAP = true. */
void unregister_descriptor (void *ptr);
/* Get sum value for ORIGIN type of allocation for the descriptor. */ /* Get sum value for ORIGIN type of allocation for the descriptor. */
T get_sum (mem_alloc_origin origin); T get_sum (mem_alloc_origin origin);
@ -522,7 +528,7 @@ mem_alloc_description<T>::release_instance_overhead (void *ptr, size_t size,
return usage; return usage;
} }
/* Release intance object identified by PTR pointer. */ /* Release instance object identified by PTR pointer. */
template <class T> template <class T>
inline void inline void
@ -536,6 +542,17 @@ mem_alloc_description<T>::release_object_overhead (void *ptr)
} }
} }
/* Unregister a memory allocation descriptor registered with
register_descriptor (remove from reverse map), unless it is
unregistered through release_instance_overhead with
REMOVE_FROM_MAP = true. */
template <class T>
inline void
mem_alloc_description<T>::unregister_descriptor (void *ptr)
{
m_reverse_map->remove (ptr);
}
/* Default contructor. */ /* Default contructor. */
template <class T> template <class T>