GCC Middle and Back End API Reference
mem_alloc_description< T > Class Template Reference

#include <mem-stats.h>

Collaboration diagram for mem_alloc_description< T >:

Data Structures

struct  mem_location_hash
 

Public Types

typedef hash_map< mem_location_hash, T * > mem_map_t
 
typedef hash_map< const void *, mem_usage_pair< T > > reverse_mem_map_t
 
typedef hash_map< const void *, std::pair< T *, size_t > > reverse_object_map_t
 
typedef std::pair< mem_location *, T * > mem_list_t
 

Public Member Functions

 mem_alloc_description ()
 
 ~mem_alloc_description ()
 
bool contains_descriptor_for_instance (const void *ptr)
 
Tget_descriptor_for_instance (const void *ptr)
 
Tregister_descriptor (const void *ptr, mem_location *location)
 
Tregister_descriptor (const void *ptr, mem_alloc_origin origin, bool ggc, const char *name, int line, const char *function)
 
Tregister_instance_overhead (size_t size, const void *ptr)
 
void register_object_overhead (T *usage, size_t size, const void *ptr)
 
Trelease_instance_overhead (void *ptr, size_t size, bool remove_from_map=false)
 
void release_object_overhead (void *ptr)
 
void unregister_descriptor (void *ptr)
 
T get_sum (mem_alloc_origin origin)
 
mem_list_tget_list (mem_alloc_origin origin, unsigned *length)
 
void dump (mem_alloc_origin origin)
 

Data Fields

reverse_object_map_tm_reverse_object_map
 

Private Member Functions

Tregister_overhead (size_t size, mem_alloc_origin origin, const char *name, int line, const char *function, const void *ptr)
 

Private Attributes

mem_location m_location
 
mem_map_tm_map
 
reverse_mem_map_tm_reverse_map
 

Detailed Description

template<class T>
class mem_alloc_description< T >
Memory allocation description.   

Member Typedef Documentation

◆ mem_list_t

template<class T >
typedef std::pair<mem_location *, T *> mem_alloc_description< T >::mem_list_t

◆ mem_map_t

◆ reverse_mem_map_t

template<class T >
typedef hash_map<const void *, mem_usage_pair<T> > mem_alloc_description< T >::reverse_mem_map_t

◆ reverse_object_map_t

template<class T >
typedef hash_map<const void *, std::pair<T *, size_t> > mem_alloc_description< T >::reverse_object_map_t

Constructor & Destructor Documentation

◆ mem_alloc_description()

Default contructor.   

◆ ~mem_alloc_description()

template<class T >
mem_alloc_description< T >::~mem_alloc_description ( )
inline
Default destructor.   

References ggc_alloc().

Member Function Documentation

◆ contains_descriptor_for_instance()

template<class T >
bool mem_alloc_description< T >::contains_descriptor_for_instance ( const void * ptr)
inline
Returns true if instance PTR is registered by the memory description.   

References hash_map< KeyId, Value, Traits >::get().

◆ dump()

template<class T >
void mem_alloc_description< T >::dump ( mem_alloc_origin origin)
inline
Dump all tracked instances of type ORIGIN. If we want to process custom
order, CMP comparator can be provided.   

References mem_location::get_origin_name(), ggc_alloc(), and i.

Referenced by dump_alloc_pool_statistics(), and dump_hash_table_loc_statistics().

◆ get_descriptor_for_instance()

template<class T >
T * mem_alloc_description< T >::get_descriptor_for_instance ( const void * ptr)
inline
Return descriptor for instance PTR.   

References NULL, and usage().

◆ get_list()

template<class T >
mem_alloc_description< T >::mem_list_t * mem_alloc_description< T >::get_list ( mem_alloc_origin origin,
unsigned * length )
inline
Get all tracked instances registered by the description. Items are filtered
by ORIGIN type, LENGTH is return value where we register the number of
elements in the list. If we want to process custom order, CMP comparator
can be provided.   

References ggc_alloc(), i, and qsort.

◆ get_sum()

template<class T >
T mem_alloc_description< T >::get_sum ( mem_alloc_origin origin)
inline
Get sum value for ORIGIN type of allocation for the descriptor.   

References ggc_alloc(), and i.

◆ register_descriptor() [1/2]

template<class T >
T * mem_alloc_description< T >::register_descriptor ( const void * ptr,
mem_alloc_origin origin,
bool ggc,
const char * filename,
int line,
const char * function )
inline
Register memory allocation descriptor for container PTR.  ORIGIN identifies
type of container and GGC identifes if the allocation is handled in GGC
memory.  Each location is identified by file NAME, LINE in source code and
FUNCTION name.   

References ggc_alloc().

◆ register_descriptor() [2/2]

template<class T >
T * mem_alloc_description< T >::register_descriptor ( const void * ptr,
mem_location * location )
inline
Register memory allocation descriptor for container PTR which is
described by a memory LOCATION.   

References NULL, T, and usage().

◆ register_instance_overhead()

template<class T >
T * mem_alloc_description< T >::register_instance_overhead ( size_t size,
const void * ptr )
inline
Register instance overhead identified by PTR pointer. Allocation takes
SIZE bytes.   

References ggc_alloc(), NULL, and usage().

◆ register_object_overhead()

template<class T >
void mem_alloc_description< T >::register_object_overhead ( T * usage,
size_t size,
const void * ptr )
For containers (and GGC) where we want to track every instance object,
we register allocation of SIZE bytes, identified by PTR pointer, belonging
to USAGE descriptor.   

References usage().

◆ register_overhead()

template<class T >
T * mem_alloc_description< T >::register_overhead ( size_t size,
mem_alloc_origin origin,
const char * filename,
int line,
const char * function,
const void * ptr )
inlineprivate
Register overhead of SIZE bytes of ORIGIN type. PTR pointer is allocated
in NAME source file, at LINE in source code, in FUNCTION.   

References usage().

◆ release_instance_overhead()

template<class T >
T * mem_alloc_description< T >::release_instance_overhead ( void * ptr,
size_t size,
bool remove_from_map = false )
inline
Release PTR pointer of SIZE bytes.   

References ggc_alloc(), NULL, and usage().

◆ release_object_overhead()

template<class T >
void mem_alloc_description< T >::release_object_overhead ( void * ptr)
inline
Release instance object identified by PTR pointer.   

◆ unregister_descriptor()

template<class T >
void mem_alloc_description< T >::unregister_descriptor ( void * ptr)
inline
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.   

Field Documentation

◆ m_location

template<class T >
mem_location mem_alloc_description< T >::m_location
private

◆ m_map

template<class T >
mem_map_t* mem_alloc_description< T >::m_map
private

◆ m_reverse_map

template<class T >
reverse_mem_map_t* mem_alloc_description< T >::m_reverse_map
private

◆ m_reverse_object_map

template<class T >
reverse_object_map_t* mem_alloc_description< T >::m_reverse_object_map

The documentation for this class was generated from the following file: