[llvm-commits] CVS: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Mar 7 17:37:53 PST 2004
Changes in directory poolalloc/runtime/FL2Allocator:
FreeListAllocator.cpp updated: 1.10 -> 1.11
---
Log message:
Add the ability to print out the number of dynamic pools allocated. This
is disabled by default, cause it breaks the diffs
---
Diffs of the changes: (+29 -6)
Index: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
diff -u poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.10 poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.11
--- poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.10 Fri Mar 5 04:53:26 2004
+++ poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Fri Mar 5 13:40:38 2004
@@ -18,6 +18,22 @@
#include <stdio.h>
#include <string.h>
+//#define DEBUG(X) X
+
+#ifndef DEBUG
+#define DEBUG(X)
+#endif
+
+//#define PRINT_NUM_POOLS
+
+#ifdef PRINT_NUM_POOLS
+static unsigned PoolCounter = 0;
+static void PoolCountPrinter() {
+ fprintf(stderr, "\n\n*** %d DYNAMIC POOLS ***\n\n", PoolCounter);
+}
+
+#endif
+
//===----------------------------------------------------------------------===//
//
// PoolSlab implementation
@@ -26,12 +42,6 @@
#define PageSize (4*1024U)
-//#define DEBUG(X) X
-
-#ifndef DEBUG
-#define DEBUG(X)
-#endif
-
static inline unsigned getSizeClass(unsigned NumBytes) {
if (NumBytes <= FreeListOneSize)
return NumBytes > FreeListZeroSize;
@@ -112,6 +122,16 @@
Pool->AllocSize = PageSize;
Pool->DeclaredSize = DeclaredSize;
DEBUG(printf("init pool 0x%X\n", Pool));
+
+ static bool Initialized = 0;
+ if (!Initialized) {
+ Initialized = 1;
+
+#ifdef PRINT_NUM_POOLS
+ atexit(PoolCountPrinter);
+#endif
+ }
+
}
// pooldestroy - Release all memory allocated for a pool
@@ -151,6 +171,9 @@
// they are freed.
if (NumBytes < 8) NumBytes = 8;
+#ifdef PRINT_NUM_POOLS
+ if (Pool->NumObjects == 0) ++PoolCounter; // Track # pools.
+#endif
++Pool->NumObjects;
Pool->BytesAllocated += NumBytes;
More information about the llvm-commits
mailing list