summaryrefslogtreecommitdiff
path: root/indra/llcommon/lltrace.h
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-09-07 21:54:03 -0700
committerRichard Linden <none@none>2013-09-07 21:54:03 -0700
commitc6b6ae7a45f7ab473dd839515a1717bae68af03a (patch)
tree74bc548852a9ea3cf350096b55182761362a3f6d /indra/llcommon/lltrace.h
parent3fd68662f267a3fd96d101834b3a9563bde3f61e (diff)
parente4cacda5a0cf3918bdc8091997b988235e9d4f3d (diff)
merge
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