15 #include "typeHandle.h"
16 #include "typeRegistryNode.h"
17 #include "atomicAdjust.h"
22 #ifdef DO_MEMORY_USAGE
32 get_memory_usage(MemoryClass memory_class)
const {
33 assert((
int)memory_class >= 0 && (
int)memory_class < (
int)MC_limit);
42 #endif // DO_MEMORY_USAGE
44 #ifdef DO_MEMORY_USAGE
52 inc_memory_usage(MemoryClass memory_class,
int size) {
53 assert((
int)memory_class >= 0 && (
int)memory_class < (
int)MC_limit);
57 AtomicAdjust::add(rnode->_memory_usage[memory_class], (AtomicAdjust::Integer)size);
59 if (rnode->_memory_usage[memory_class] < 0) {
60 cerr <<
"Memory usage overflow for type " << *
this <<
".\n";
65 #endif // DO_MEMORY_USAGE
67 #ifdef DO_MEMORY_USAGE
75 dec_memory_usage(MemoryClass memory_class,
int size) {
76 assert((
int)memory_class >= 0 && (
int)memory_class < (
int)MC_limit);
80 AtomicAdjust::add(rnode->_memory_usage[memory_class], -(AtomicAdjust::Integer)size);
82 assert(rnode->_memory_usage[memory_class] >= 0);
85 #endif // DO_MEMORY_USAGE
88 operator << (ostream &out, TypeHandle::MemoryClass mem_class) {
90 case TypeHandle::MC_singleton:
91 return out <<
"singleton";
93 case TypeHandle::MC_array:
94 return out <<
"array";
96 case TypeHandle::MC_deleted_chain_active:
97 return out <<
"deleted_chain_active";
99 case TypeHandle::MC_deleted_chain_inactive:
100 return out <<
"deleted_chain_inactive";
102 case TypeHandle::MC_limit:
103 return out <<
"limit";
107 <<
"**invalid TypeHandle::MemoryClass (" << (int)mem_class
static TypeHandle none()
Returns a special zero-valued TypeHandle that is used to indicate no type.
static void add(Integer &var, Integer delta)
Atomically computes var += delta.
This is a single entry in the TypeRegistry.
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
static TypeRegistry * ptr()
Returns the pointer to the global TypeRegistry object.
TypeHandle is the identifier used to differentiate C++ class types.