From a6f361669312430748d51e6435da8f0d5c4b34c4 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 26 Mar 2019 09:38:53 -0400 Subject: [PATCH] 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 --- gcc/ChangeLog | 10 ++++++++++ gcc/hash-table.h | 11 ++++++----- gcc/mem-stats.h | 21 +++++++++++++++++++-- 3 files changed, 35 insertions(+), 7 deletions(-) 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