44 size_t instances,
size_t element_size,
45 const char *pool_name)
46 :
mem_usage (allocated, times, peak, instances),
65 char *location_string = loc->
to_string ();
67 fprintf (stderr,
"%-32s%-48s " PRsa(5)
PRsa(9)
":%5.1f%%"
78 free (location_string);
85 fprintf (stderr,
"%-32s%-48s %6s%11s%16s%17s%12s\n",
"Pool name", name,
86 "Pools",
"Leak",
"Peak",
"Times",
"Elt size");
93 fprintf (stderr,
"%s" PRsa(82)
PRsa(10)
"\n",
"Total",
122template <
size_t BlockSize>
123class custom_block_allocator
126 static const size_t block_size = BlockSize;
129 allocate () ATTRIBUTE_MALLOC
131 return XNEWVEC (
char, BlockSize);
135 release (
void *block)
144template <
typename TBlockAllocator>
188 get_instance (
void *data_ptr)
207 return (((x+7) >> 3) << 3);
243template <
typename TBlockAllocator>
255template <
typename TBlockAllocator>
279 if (GATHER_STATISTICS)
304template <
typename TBlockAllocator>
316 next_block = block->
next;
317 TBlockAllocator::release (block);
335template <
typename TBlockAllocator>
343template <
typename TBlockAllocator>
350template <
typename TBlockAllocator>
358#ifdef ENABLE_VALGRIND_ANNOTATIONS
362 if (GATHER_STATISTICS)
367#ifdef ENABLE_VALGRIND_ANNOTATIONS
380 block =
reinterpret_cast<char *
> (TBlockAllocator::allocate ());
424 allocation_object::get_instance (
header)->id =
m_id;
432template <
typename TBlockAllocator>
446 gcc_assert (
m_id == allocation_object::get_instance (
object)->
id);
449 memset (
object, 0xaf, size);
454 allocation_object::get_instance (
object)->id = 0;
463 if (GATHER_STATISTICS)
471template <
typename TBlockAllocator>
506 template<
typename... Ts>
507 inline ATTRIBUTE_MALLOC
T *
510 return ::new (
m_allocator.allocate ())
T (std::forward<Ts> (args)...);
574 return a.allocate_raw ();
ALLOC_POOL_ID_TYPE last_id
Definition alloc-pool.cc:26
bool after_memory_report
Definition alloc-pool.cc:27
ALLOC_POOL_ID_TYPE last_id
Definition alloc-pool.cc:26
base_pool_allocator< memory_block_pool > pool_allocator
Definition alloc-pool.h:481
hash_map< const char *, alloc_pool_descriptor > * alloc_pool_hash
void dump_alloc_pool_statistics(void)
Definition alloc-pool.cc:31
auto & pool_allocator_usage()
Definition alloc-pool.h:104
bool after_memory_report
Definition alloc-pool.cc:27
unsigned long ALLOC_POOL_ID_TYPE
Definition alloc-pool.h:31
size_t m_elts_free
Definition alloc-pool.h:228
const char * m_name
Definition alloc-pool.h:210
~base_pool_allocator()
Definition alloc-pool.h:344
char * m_virgin_free_list
Definition alloc-pool.h:220
void release_if_empty()
Definition alloc-pool.h:337
size_t m_virgin_elts_remaining
Definition alloc-pool.h:224
ALLOC_POOL_ID_TYPE m_id
Definition alloc-pool.h:211
allocation_pool_list * m_block_list
Definition alloc-pool.h:232
allocation_pool_list * m_returned_free_list
Definition alloc-pool.h:216
void initialize()
Definition alloc-pool.h:257
size_t m_size
Definition alloc-pool.h:236
base_pool_allocator(const char *name, size_t size CXX_MEM_STAT_INFO)
Definition alloc-pool.h:245
size_t m_elts_per_block
Definition alloc-pool.h:212
size_t num_elts_current()
size_t m_blocks_allocated
Definition alloc-pool.h:230
void remove(void *object)
static size_t align_eight(size_t x)
Definition alloc-pool.h:205
size_t m_elt_size
Definition alloc-pool.h:234
size_t m_elts_allocated
Definition alloc-pool.h:226
void release()
Definition alloc-pool.h:306
mem_location m_location
Definition alloc-pool.h:240
void * allocate() ATTRIBUTE_MALLOC
Definition alloc-pool.h:352
bool m_initialized
Definition alloc-pool.h:238
static auto & instance()
Definition mem-stats.h:290
Definition mem-stats.h:35
char * to_string()
Definition mem-stats.h:93
mem_usage()
Definition mem-stats.h:131
size_t m_allocated
Definition mem-stats.h:253
size_t m_peak
Definition mem-stats.h:257
size_t m_instances
Definition mem-stats.h:259
size_t m_times
Definition mem-stats.h:255
static float get_percent(size_t nominator, size_t denominator)
Definition mem-stats.h:230
Definition alloc-pool.h:486
ATTRIBUTE_MALLOC T * allocate(Ts... args)
Definition alloc-pool.h:508
pool_allocator m_allocator
Definition alloc-pool.h:545
void * allocate_raw() ATTRIBUTE_MALLOC
Definition alloc-pool.h:518
void remove_raw(void *object)
Definition alloc-pool.h:533
void remove(T *object)
Definition alloc-pool.h:524
object_allocator(const char *name CXX_MEM_STAT_INFO)
Definition alloc-pool.h:489
void release()
Definition alloc-pool.h:493
void release_if_empty()
Definition alloc-pool.h:498
size_t num_elts_current()
Definition alloc-pool.h:539
Definition alloc-pool.h:38
const char * m_pool_name
Definition alloc-pool.h:100
pool_usage()
Definition alloc-pool.h:41
pool_usage operator+(const pool_usage &second)
Definition alloc-pool.h:52
void dump(mem_location *loc, const mem_usage &total) const
Definition alloc-pool.h:63
pool_usage(size_t allocated, size_t times, size_t peak, size_t instances, size_t element_size, const char *pool_name)
Definition alloc-pool.h:43
size_t m_element_size
Definition alloc-pool.h:98
static void dump_header(const char *name)
Definition alloc-pool.h:83
void dump_footer()
Definition alloc-pool.h:91
static struct token T
Definition gengtype-parse.cc:45
FILE * header
Definition genrecog.cc:5393
#define PRIu64
Definition hwint.h:93
@ ALLOC_POOL_ORIGIN
Definition mem-stats-traits.h:33
Ca & a
Definition poly-int.h:770
#define PASS_MEM_STAT
Definition statistics.h:54
#define MEM_STAT_DECL
Definition statistics.h:52
#define CXX_MEM_STAT_INFO
Definition statistics.h:58
Definition alloc-pool.h:555
unsigned long current
Definition alloc-pool.h:561
unsigned long allocated
Definition alloc-pool.h:559
int elt_size
Definition alloc-pool.h:565
unsigned long created
Definition alloc-pool.h:557
unsigned long peak
Definition alloc-pool.h:563
Definition alloc-pool.h:167
static void * get_data(void *instance_ptr)
Definition alloc-pool.h:197
int64_t align_i
Definition alloc-pool.h:183
union base_pool_allocator::allocation_object::@267103222306076073205270232113306207323151343062 u
char data[1]
Definition alloc-pool.h:176
char * align_p
Definition alloc-pool.h:182
Definition alloc-pool.h:159
allocation_pool_list * next
Definition alloc-pool.h:160
Definition collect2.cc:168
#define NULL
Definition system.h:50
#define gcc_assert(EXPR)
Definition system.h:820
#define offsetof(TYPE, MEMBER)
Definition system.h:751
#define false
Definition system.h:894
#define VALGRIND_DISCARD(x)
Definition system.h:1171
#define SIZE_AMOUNT(size)
Definition system.h:1239
#define PRsa(n)
Definition system.h:1243
#define gcc_checking_assert(EXPR)
Definition system.h:827