+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>
PR tree-optimization/81740
Allocator <value_type> ::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. */
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);
return usage;
}
-/* Release intance object identified by PTR pointer. */
+/* Release instance object identified by PTR pointer. */
template <class T>
inline void
}
}
+/* 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. */
template <class T>