[llvm-commits] CVS: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Nov 10 21:46:52 PST 2004



Changes in directory poolalloc/runtime/FL2Allocator:

FreeListAllocator.cpp updated: 1.28 -> 1.29

---
Log message:

Fix some serious bugs infering pool desired size (don't infer a size that
we can never match!)


---
Diffs of the changes:  (+13 -3)

Index: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
diff -u poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.28 poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.29
--- poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.28	Wed Nov 10 19:43:54 2004
+++ poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp	Wed Nov 10 23:46:41 2004
@@ -179,8 +179,14 @@
 
 // create - Create a new (empty) slab and add it to the end of the Pools list.
 void PoolSlab::create(PoolTy *Pool, unsigned SizeHint) {
-  if (Pool->DeclaredSize == 0)
+  if (Pool->DeclaredSize == 0) {
+    unsigned Align = Pool->Alignment;
+    if (SizeHint < sizeof(FreedNodeHeader)-sizeof(NodeHeader))
+      SizeHint = sizeof(FreedNodeHeader)-sizeof(NodeHeader);
+    SizeHint = SizeHint+sizeof(FreedNodeHeader)+(Align-1);
+    SizeHint = (SizeHint & ~(Align-1))-sizeof(FreedNodeHeader);
     Pool->DeclaredSize = SizeHint;
+  }
 
   unsigned Size = Pool->AllocSize;
   Pool->AllocSize <<= 1;
@@ -350,8 +356,12 @@
 
   // Round the declared size up to an alignment boundary-header size, just like
   // we have to do for objects.
-  DeclaredSize = DeclaredSize+sizeof(FreedNodeHeader)+(ObjAlignment-1);
-  DeclaredSize = (DeclaredSize & ~(ObjAlignment-1))-sizeof(FreedNodeHeader);
+  if (DeclaredSize) {
+    if (DeclaredSize < sizeof(FreedNodeHeader)-sizeof(NodeHeader))
+      DeclaredSize = sizeof(FreedNodeHeader)-sizeof(NodeHeader);
+    DeclaredSize = DeclaredSize+sizeof(FreedNodeHeader)+(ObjAlignment-1);
+    DeclaredSize = (DeclaredSize & ~(ObjAlignment-1))-sizeof(FreedNodeHeader);
+  }
 
   Pool->DeclaredSize = DeclaredSize;
 





More information about the llvm-commits mailing list