[llvm-commits] CVS: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Nov 6 22:44:19 PST 2004
Changes in directory poolalloc/runtime/FL2Allocator:
FreeListAllocator.cpp updated: 1.17 -> 1.18
---
Log message:
The page size is really used for two parameters, neither of which have
anything to do with memory pages.
Also, fix a bug in rounding allocations.
---
Diffs of the changes: (+9 -6)
Index: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
diff -u poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.17 poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.18
--- poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.17 Fri Nov 5 01:18:42 2004
+++ poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Sun Nov 7 00:44:08 2004
@@ -23,6 +23,10 @@
//#define PRINT_NUM_POOLS
+#define INITIAL_SLAB_SIZE 4096
+#define LARGE_SLAB_SIZE 4096
+
+
//===----------------------------------------------------------------------===//
// Pool Debugging stuff.
//===----------------------------------------------------------------------===//
@@ -97,8 +101,6 @@
// PoolSlab implementation
//===----------------------------------------------------------------------===//
-#define PageSize (4*1024U)
-
static inline unsigned getSizeClass(unsigned NumBytes) {
if (NumBytes <= FreeListOneSize)
return NumBytes > FreeListZeroSize;
@@ -141,8 +143,9 @@
void PoolSlab::create(PoolTy *Pool, unsigned SizeHint) {
unsigned Size = Pool->AllocSize;
Pool->AllocSize <<= 1;
- Size = Size / SizeHint * SizeHint;
- PoolSlab *PS = (PoolSlab*)malloc(Size+sizeof(PoolSlab)+ 2*sizeof(NodeHeader));
+ Size = (Size+SizeHint-1) / SizeHint * SizeHint;
+ PoolSlab *PS = (PoolSlab*)malloc(Size+sizeof(PoolSlab) + sizeof(NodeHeader) +
+ sizeof(FreedNodeHeader));
// Add the body of the slab to the free list...
FreedNodeHeader *SlabBody = (FreedNodeHeader*)(PS+1);
@@ -176,7 +179,7 @@
void poolinit(PoolTy *Pool, unsigned DeclaredSize) {
assert(Pool && "Null pool pointer passed into poolinit!\n");
memset(Pool, 0, sizeof(PoolTy));
- Pool->AllocSize = PageSize;
+ Pool->AllocSize = INITIAL_SLAB_SIZE;
Pool->DeclaredSize = DeclaredSize;
DO_IF_TRACE(fprintf(stderr, "[%d] poolinit(0x%X, %d)\n", addPoolNumber(Pool),
@@ -277,7 +280,7 @@
// Perform a search of the free list, taking the front of the first free chunk
// that is big enough.
- if (NumBytes <= PageSize-sizeof(PoolSlab)-sizeof(NodeHeader)) {
+ if (NumBytes <= LARGE_SLAB_SIZE-sizeof(PoolSlab)-sizeof(NodeHeader)) {
do {
FreedNodeHeader **FN = &Pool->FreeNodeLists[SizeClass];
FreedNodeHeader *FNN = *FN;
More information about the llvm-commits
mailing list