Add FAST_ALLOC_DEBUG and FAST_ALLOC_STATS as SConstruct options.
--HG-- extra : convert_revision : 56a7f646f2ac87019c78ba7fa62c5f4bdc00ba44
This commit is contained in:
parent
407710d387
commit
627592c2f2
3 changed files with 20 additions and 19 deletions
|
@ -537,6 +537,10 @@ sticky_opts.AddOptions(
|
|||
# scons 0.96.90 or later.
|
||||
ListOption('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list),
|
||||
BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
|
||||
BoolOption('FAST_ALLOC_DEBUG', 'Enable fast object allocator debugging',
|
||||
False),
|
||||
BoolOption('FAST_ALLOC_STATS', 'Enable fast object allocator statistics',
|
||||
False),
|
||||
BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
|
||||
False),
|
||||
BoolOption('SS_COMPATIBLE_FP',
|
||||
|
@ -561,7 +565,8 @@ nonsticky_opts.AddOptions(
|
|||
|
||||
# These options get exported to #defines in config/*.hh (see src/SConscript).
|
||||
env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
|
||||
'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
|
||||
'USE_MYSQL', 'NO_FAST_ALLOC', 'FAST_ALLOC_DEBUG', \
|
||||
'FAST_ALLOC_STATS', 'SS_COMPATIBLE_FP', \
|
||||
'USE_CHECKER', 'PYTHONHOME', 'TARGET_ISA']
|
||||
|
||||
# Define a handy 'no-op' action
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
void *FastAlloc::freeLists[Num_Buckets];
|
||||
|
||||
#ifdef FAST_ALLOC_STATS
|
||||
#if FAST_ALLOC_STATS
|
||||
unsigned FastAlloc::newCount[Num_Buckets];
|
||||
unsigned FastAlloc::deleteCount[Num_Buckets];
|
||||
unsigned FastAlloc::allocCount[Num_Buckets];
|
||||
|
@ -59,7 +59,7 @@ void *FastAlloc::moreStructs(int bucket)
|
|||
const int nstructs = Num_Structs_Per_New; // how many to allocate?
|
||||
char *p = ::new char[nstructs * sz];
|
||||
|
||||
#ifdef FAST_ALLOC_STATS
|
||||
#if FAST_ALLOC_STATS
|
||||
++allocCount[bucket];
|
||||
#endif
|
||||
|
||||
|
@ -72,7 +72,7 @@ void *FastAlloc::moreStructs(int bucket)
|
|||
}
|
||||
|
||||
|
||||
#ifdef FAST_ALLOC_DEBUG
|
||||
#if FAST_ALLOC_DEBUG
|
||||
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
|
@ -167,9 +167,9 @@ FastAlloc::dump_oldest(int n)
|
|||
return;
|
||||
}
|
||||
|
||||
for (FastAlloc *p = inUseHead.inUsePrev;
|
||||
for (FastAlloc *p = inUseHead.inUseNext;
|
||||
p != &inUseHead && n > 0;
|
||||
p = p->inUsePrev, --n)
|
||||
p = p->inUseNext, --n)
|
||||
{
|
||||
cout << p << " " << typeid(*p).name() << endl;
|
||||
}
|
||||
|
@ -180,11 +180,13 @@ FastAlloc::dump_oldest(int n)
|
|||
// C interfaces to FastAlloc::dump_summary() and FastAlloc::dump_oldest().
|
||||
// gdb seems to have trouble with calling C++ functions directly.
|
||||
//
|
||||
void
|
||||
fast_alloc_summary()
|
||||
{
|
||||
FastAlloc::dump_summary();
|
||||
}
|
||||
|
||||
void
|
||||
fast_alloc_oldest(int n)
|
||||
{
|
||||
FastAlloc::dump_oldest(n);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue