[llvm-commits] CVS: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp
John Criswell
criswell at cs.uiuc.edu
Mon Nov 10 22:33:01 PST 2003
Changes in directory poolalloc/runtime/FreeListAllocator:
PoolAllocator.cpp updated: 1.5 -> 1.6
---
Log message:
Added array support that works but needs much improvement.
---
Diffs of the changes: (+20 -18)
Index: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp
diff -u poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.5 poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.6
--- poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.5 Mon Nov 10 21:45:37 2003
+++ poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp Mon Nov 10 22:32:15 2003
@@ -27,6 +27,9 @@
//===----------------------------------------------------------------------===//
struct SlabHeader
{
+ // Flags whether this is an array
+ unsigned char IsArray;
+
// Number of nodes per slab
unsigned int NodesPerSlab;
@@ -87,6 +90,7 @@
//
// Initialize the contents of the slab.
//
+ NewSlab->IsArray = 0;
NewSlab->NodeSize = NodeSize;
NewSlab->NodesPerSlab = NodesPerSlab;
NewSlab->LiveNodes = 0;
@@ -274,33 +278,20 @@
// This algorithm is not very space efficient. This needs to be fixed.
//
void *
-poolallocarray(PoolTy* Pool, unsigned Size)
+poolallocarray(PoolTy* Pool, unsigned ArraySize)
{
assert(Pool && "Null pool pointer passed into poolallocarray!\n");
- assert (0 && "I don't work yet\n");
-#if 0
//
- // Create a new slab and add it to the list.
+ // Create a new slab and mark it as an array.
//
- struct SlabHeader * NewSlab = createSlab (Pool->NodeSize, Size);
- if (Pool->Slabs == NULL)
- {
- Pool->Slabs = NewSlab;
- }
- else
- {
- NewSlab->Next = Pool->Slabs;
- Pool->Slabs = NewSlab;
- }
+ struct SlabHeader * NewSlab = createSlab (Pool->NodeSize, ArraySize);
+ NewSlab->IsArray = 1;
//
// Return the list of blocks to the caller.
//
- return (&(Pool->Slabs->Data[0]));
-#else /* 0 */
- return NULL;
-#endif /* 0 */
+ return (&(NewSlab->Data[0]));
}
void
@@ -313,6 +304,17 @@
// Find the header of the memory block.
//
struct SlabHeader * slabp = DataOwner (Block);
+
+ //
+ // If the owner is an array, just nuke the whole thing for now.
+ // FIXME: Inefficient! Danger Will Robinson!
+ //
+ if (slabp->IsArray)
+ {
+ FreePage (slabp);
+ return;
+ }
+
NodePointer Node;
Node.Next = &(slabp->BlockList[((unsigned char *)Block - slabp->Data)/Pool->NodeSize]);
More information about the llvm-commits
mailing list