summaryrefslogtreecommitdiff
path: root/src/base/fast_alloc.hh
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@gmail.com>2008-03-24 01:08:02 -0400
committerSteve Reinhardt <stever@gmail.com>2008-03-24 01:08:02 -0400
commit627592c2f2a9d2774df50b2b5039efcb71432bc7 (patch)
treefe2cd42b91630181f7dfd9e595c885c42f56d4a5 /src/base/fast_alloc.hh
parent407710d387497f44de53baf0ae60a2c426c1bb74 (diff)
downloadgem5-627592c2f2a9d2774df50b2b5039efcb71432bc7.tar.xz
Add FAST_ALLOC_DEBUG and FAST_ALLOC_STATS as SConstruct options.
--HG-- extra : convert_revision : 56a7f646f2ac87019c78ba7fa62c5f4bdc00ba44
Diffstat (limited to 'src/base/fast_alloc.hh')
-rw-r--r--src/base/fast_alloc.hh20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/base/fast_alloc.hh b/src/base/fast_alloc.hh
index 3e22e59c1..50b761c9c 100644
--- a/src/base/fast_alloc.hh
+++ b/src/base/fast_alloc.hh
@@ -62,15 +62,9 @@
// collapse the destructor call chain back up the inheritance
// hierarchy.
-// Uncomment this #define to track in-use objects
-// (for debugging memory leaks).
-//#define FAST_ALLOC_DEBUG
-
-// Uncomment this #define to count news, deletes, and chunk allocations
-// (by bucket).
-// #define FAST_ALLOC_STATS
-
#include "config/no_fast_alloc.hh"
+#include "config/fast_alloc_debug.hh"
+#include "config/fast_alloc_stats.hh"
#if NO_FAST_ALLOC
@@ -88,7 +82,7 @@ class FastAlloc {
void *operator new(size_t);
void operator delete(void *, size_t);
-#ifdef FAST_ALLOC_DEBUG
+#if FAST_ALLOC_DEBUG
FastAlloc();
FastAlloc(FastAlloc*,FastAlloc*); // for inUseHead, see below
virtual ~FastAlloc();
@@ -121,13 +115,13 @@ class FastAlloc {
static void *freeLists[Num_Buckets];
-#ifdef FAST_ALLOC_STATS
+#if FAST_ALLOC_STATS
static unsigned newCount[Num_Buckets];
static unsigned deleteCount[Num_Buckets];
static unsigned allocCount[Num_Buckets];
#endif
-#ifdef FAST_ALLOC_DEBUG
+#if FAST_ALLOC_DEBUG
// per-object debugging fields
bool inUse; // in-use flag
FastAlloc *inUsePrev; // ptrs to build list of in-use objects
@@ -170,7 +164,7 @@ void *FastAlloc::allocate(size_t sz)
else
p = moreStructs(b);
-#ifdef FAST_ALLOC_STATS
+#if FAST_ALLOC_STATS
++newCount[b];
#endif
@@ -192,7 +186,7 @@ void FastAlloc::deallocate(void *p, size_t sz)
b = bucketFor(sz);
*(void **)p = freeLists[b];
freeLists[b] = p;
-#ifdef FAST_ALLOC_STATS
+#if FAST_ALLOC_STATS
++deleteCount[b];
#endif
}