summaryrefslogtreecommitdiff
path: root/indra/llcommon/lltrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/lltrace.h')
-rw-r--r--indra/llcommon/lltrace.h80
1 files changed, 72 insertions, 8 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index cda15c0de5..6436570492 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -38,8 +38,6 @@
#include <list>
-#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::TimeBlock::Recorder LL_GLUE_TOKENS(block_time_recorder, __COUNTER__)(block_timer);
-
namespace LLTrace
{
class Recording;
@@ -89,7 +87,7 @@ public:
size_t getIndex() const { return mAccumulatorIndex; }
static size_t getNumIndices() { return AccumulatorBuffer<ACCUMULATOR>::getNumIndices(); }
-private:
+protected:
const size_t mAccumulatorIndex;
};
@@ -344,7 +342,7 @@ class MemTrackable
struct TrackMemImpl;
typedef MemTrackable<DERIVED, ALIGNMENT> mem_trackable_t;
-
+ static MemStatHandle sMemStat;
public:
typedef void mem_trackable_tag_t;
@@ -359,7 +357,22 @@ public:
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size);
accumulator.mAllocatedCount++;
- return ::operator new(size);
+ if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
+ {
+ return ::operator new(size);
+ }
+ else if (ALIGNMENT == 16)
+ {
+ return ll_aligned_malloc_16(size);
+ }
+ else if (ALIGNMENT == 32)
+ {
+ return ll_aligned_malloc_32(size);
+ }
+ else
+ {
+ return ll_aligned_malloc(size, ALIGNMENT);
+ }
}
void operator delete(void* ptr, size_t size)
@@ -368,7 +381,23 @@ public:
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size);
accumulator.mAllocatedCount--;
accumulator.mDeallocatedCount++;
- ::operator delete(ptr);
+
+ if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
+ {
+ ::operator delete(ptr);
+ }
+ else if (ALIGNMENT == 16)
+ {
+ ll_aligned_free_16(ptr);
+ }
+ else if (ALIGNMENT == 32)
+ {
+ return ll_aligned_free_32(ptr);
+ }
+ else
+ {
+ return ll_aligned_free(ptr);
+ }
}
void *operator new [](size_t size)
@@ -377,7 +406,22 @@ public:
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size);
accumulator.mAllocatedCount++;
- return ::operator new[](size);
+ if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
+ {
+ return ::operator new[](size);
+ }
+ else if (ALIGNMENT == 16)
+ {
+ return ll_aligned_malloc_16(size);
+ }
+ else if (ALIGNMENT == 32)
+ {
+ return ll_aligned_malloc_32(size);
+ }
+ else
+ {
+ return ll_aligned_malloc(size, ALIGNMENT);
+ }
}
void operator delete[](void* ptr, size_t size)
@@ -386,7 +430,23 @@ public:
accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size);
accumulator.mAllocatedCount--;
accumulator.mDeallocatedCount++;
- ::operator delete[](ptr);
+
+ if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
+ {
+ ::operator delete[](ptr);
+ }
+ else if (ALIGNMENT == 16)
+ {
+ ll_aligned_free_16(ptr);
+ }
+ else if (ALIGNMENT == 32)
+ {
+ return ll_aligned_free_32(ptr);
+ }
+ else
+ {
+ return ll_aligned_free(ptr);
+ }
}
// claim memory associated with other objects/data as our own, adding to our calculated footprint
@@ -477,5 +537,9 @@ private:
};
};
+// pretty sure typeid of containing class in static object constructor doesn't work in gcc
+template<typename DERIVED, size_t ALIGNMENT>
+MemStatHandle MemTrackable<DERIVED, ALIGNMENT>::sMemStat(typeid(DERIVED).name());
+
}
#endif // LL_LLTRACE_H