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

template<class T>
typedef hash_map<mem_location_hash, T *> mem_alloc_description< 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()

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

References m_map, m_reverse_map, and m_reverse_object_map.

◆ ~mem_alloc_description()

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

References m_map, m_reverse_map, and m_reverse_object_map.

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 m_reverse_map.

◆ 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 get_list(), mem_location::get_origin_name(), get_sum(), i, and T.

◆ 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 m_reverse_map, and NULL.

◆ 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 i, m_map, and qsort.

Referenced by dump(), and get_sum().

◆ 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 get_list(), i, and T.

Referenced by dump().

◆ 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 register_descriptor().

◆ 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 m_map, m_reverse_map, NULL, T, and usage().

Referenced by register_descriptor(), and register_overhead().

◆ 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 m_reverse_map, NULL, T, 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 m_reverse_object_map, T, and 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 register_descriptor(), T, and 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 m_reverse_map, NULL, T, 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.   

References m_reverse_object_map.

◆ 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.   

References m_reverse_map.

Field Documentation

◆ m_location

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

◆ m_map

◆ m_reverse_map

◆ m_reverse_object_map


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