summaryrefslogtreecommitdiff
path: root/gcc/vec.h
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-11-05 14:35:56 +0100
committerMartin Liska <marxin@gcc.gnu.org>2018-11-05 13:35:56 +0000
commit00e6775a5faa43702e96e315e7a1c22297983f2a (patch)
treebcf3354f255012a40df5a04906022748690bab09 /gcc/vec.h
parent93ef36dc6987e424e775ced165d9011c9b2477a8 (diff)
Fix vector memory statistics.
2018-11-05 Martin Liska <mliska@suse.cz> * mem-stats.h (mem_alloc_description::release_instance_overhead): Return T *. * vec.c (struct vec_usage): Register m_element_size. (vec_prefix::register_overhead): New arguments: elements and element_size. (vec_prefix::release_overhead): Subtract elements. * vec.h (struct vec_prefix): Change signature. (va_heap::reserve): Pass proper arguments. (va_heap::release): Likewise. From-SVN: r265799
Diffstat (limited to 'gcc/vec.h')
-rw-r--r--gcc/vec.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/vec.h b/gcc/vec.h
index 0af5187782e..f8c039754d2 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -195,7 +195,7 @@ struct vec_prefix
/* Memory allocation support routines in vec.c. */
void register_overhead (void *, size_t, size_t CXX_MEM_STAT_INFO);
- void release_overhead (void *, size_t, bool CXX_MEM_STAT_INFO);
+ void release_overhead (void *, size_t, size_t, bool CXX_MEM_STAT_INFO);
static unsigned calculate_allocation (vec_prefix *, unsigned, bool);
static unsigned calculate_allocation_1 (unsigned, unsigned);
@@ -276,12 +276,14 @@ inline void
va_heap::reserve (vec<T, va_heap, vl_embed> *&v, unsigned reserve, bool exact
MEM_STAT_DECL)
{
+ size_t elt_size = sizeof (T);
unsigned alloc
= vec_prefix::calculate_allocation (v ? &v->m_vecpfx : 0, reserve, exact);
gcc_checking_assert (alloc);
if (GATHER_STATISTICS && v)
- v->m_vecpfx.release_overhead (v, v->allocated (), false);
+ v->m_vecpfx.release_overhead (v, elt_size * v->allocated (),
+ v->allocated (), false);
size_t size = vec<T, va_heap, vl_embed>::embedded_size (alloc);
unsigned nelem = v ? v->length () : 0;
@@ -289,7 +291,7 @@ va_heap::reserve (vec<T, va_heap, vl_embed> *&v, unsigned reserve, bool exact
v->embedded_init (alloc, nelem);
if (GATHER_STATISTICS)
- v->m_vecpfx.register_overhead (v, alloc, nelem PASS_MEM_STAT);
+ v->m_vecpfx.register_overhead (v, alloc, elt_size PASS_MEM_STAT);
}
@@ -299,11 +301,13 @@ template<typename T>
void
va_heap::release (vec<T, va_heap, vl_embed> *&v)
{
+ size_t elt_size = sizeof (T);
if (v == NULL)
return;
if (GATHER_STATISTICS)
- v->m_vecpfx.release_overhead (v, v->allocated (), true);
+ v->m_vecpfx.release_overhead (v, elt_size * v->allocated (),
+ v->allocated (), true);
::free (v);
v = NULL;
}