25 #ifndef _JIT_COMPILER2_MEMORY_MEMSTAT
26 #define _JIT_COMPILER2_MEMORY_MEMSTAT
30 #if defined(ENABLE_STATISTICS)
31 #define ENABLE_MEMORY_MANAGER_STATISTICS
34 #if defined(ENABLE_MEMORY_MANAGER_STATISTICS)
36 #include <unordered_map>
46 STAT_DECLARE_SUM_GROUP(comp2_allocated)
47 STAT_DECLARE_SUM_GROUP(comp2_deallocated)
48 STAT_DECLARE_SUM_GROUP(comp2_max)
50 inline std::unordered_map<
void*,std::
size_t>& mem_map() {
51 static std::unordered_map<void*,std::size_t> mm;
57 static std::size_t t = 0;
62 inline const char* get_class_name() {
68 inline StatVar<std::size_t,0>& get_comp2_allocated() {
74 inline StatVar<std::
size_t,0>& get_comp2_deallocated() {
75 STAT_REGISTER_GROUP_VAR(std::size_t,comp2_deallocated,0,get_class_name<T>(),get_class_name<T>(),comp2_deallocated)
80 inline StatVar<std::
size_t,0>& get_comp2_max() {
86 inline
void stat_new(std::
size_t size,
void* p) {
87 current_heap_size<T>()+=size;
88 get_comp2_allocated<T>()+=size;
89 get_comp2_max<T>().
max(current_heap_size<T>());
93 inline void stat_delete(
void* p) {
94 std::size_t size = mem_map()[p];
95 current_heap_size<T>() -= size;
96 get_comp2_deallocated<T>() += size;
105 #define MM_STAT(x) do { x; } while(0)
107 #define MM_CLASS_NAME(x) \
110 inline const char* get_class_name<x>() { \
115 #define MM_MAKE_NAME(x) \
118 namespace compiler2 { \
127 #define MM_CLASS_NAME(x)
128 #define MM_MAKE_NAME(x)
JNIEnv jthread jobject jclass jlong size
This file contains the statistics framework.
#define STAT_REGISTER_GROUP_VAR(type, var, init, name, description, group)
Register an statistics variable and add it to a group.
std::size_t & current_heap_size()