[llvm-commits] CVS: poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 7 12:10:00 PST 2003


Changes in directory poolalloc/runtime/PoolAllocator:

PoolAllocatorChained.cpp updated: 1.23 -> 1.24

---
Log message:

Implement PoolSlab::getSlabSize(PoolTy *) correctly.


---
Diffs of the changes:  (+9 -1)

Index: poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp
diff -u poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp:1.23 poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp:1.24
--- poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp:1.23	Fri Nov  7 11:29:46 2003
+++ poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp	Fri Nov  7 12:09:00 2003
@@ -95,7 +95,15 @@
 
   // getSlabSize - Return the number of nodes that each slab should contain.
   static unsigned getSlabSize(PoolTy *Pool) {
-    return 325;
+    // We need space for the header...
+    unsigned NumNodes = PageSize-sizeof(PoolSlab);
+    
+    // We need space for the NodeFlags...
+    unsigned NodeFlagsBytes = NumNodes/Pool->NodeSize * 2 / 8;
+    NumNodes -= (NodeFlagsBytes+3) & ~3;  // Round up to int boundaries.
+
+    // Divide the remainder among the nodes!
+    return NumNodes / Pool->NodeSize;
   }
 
   void addToList(PoolSlab **PrevPtrPtr) {





More information about the llvm-commits mailing list