From: Jason Merrill Date: Tue, 26 Mar 2019 13:38:53 +0000 (-0400) Subject: mem-stats.h (mem_alloc_description::unregister_descriptor): New method. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a6f361669312430748d51e6435da8f0d5c4b34c4;p=gcc.git 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 From-SVN: r269943 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2801b392057..132a8f926b9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-03-26 Jason Merrill + Jakub Jelinek + + * 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 PR tree-optimization/81740 diff --git a/gcc/hash-table.h b/gcc/hash-table.h index e5bbe677cec..37e4b83b876 100644 --- a/gcc/hash-table.h +++ b/gcc/hash-table.h @@ -652,12 +652,13 @@ hash_table::~hash_table () Allocator ::data_free (m_entries); else ggc_free (m_entries); + if (m_gather_mem_stats) + hash_table_usage ().release_instance_overhead (this, + sizeof (value_type) + * m_size, true); } - - if (m_gather_mem_stats) - hash_table_usage ().release_instance_overhead (this, - sizeof (value_type) - * m_size, true); + else if (m_gather_mem_stats) + hash_table_usage ().unregister_descriptor (this); } /* This function returns an array of empty hash table elements. */ diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h index 7612e7de3d2..63ce8712e2b 100644 --- a/gcc/mem-stats.h +++ b/gcc/mem-stats.h @@ -342,9 +342,15 @@ public: T *release_instance_overhead (void *ptr, size_t size, 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); + /* 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. */ T get_sum (mem_alloc_origin origin); @@ -522,7 +528,7 @@ mem_alloc_description::release_instance_overhead (void *ptr, size_t size, return usage; } -/* Release intance object identified by PTR pointer. */ +/* Release instance object identified by PTR pointer. */ template inline void @@ -536,6 +542,17 @@ mem_alloc_description::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 +inline void +mem_alloc_description::unregister_descriptor (void *ptr) +{ + m_reverse_map->remove (ptr); +} + /* Default contructor. */ template