[llvm-commits] CVS: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp PoolAllocator.h
John Criswell
criswell at cs.uiuc.edu
Fri Nov 14 15:53:01 PST 2003
Changes in directory poolalloc/runtime/FreeListAllocator:
PoolAllocator.cpp updated: 1.26 -> 1.27
PoolAllocator.h updated: 1.8 -> 1.9
---
Log message:
Fixed the faster allocation of arrays.
With Chris's new numbers, performance is looking better.
Half of the Olden tests show a speed improvement.
---
Diffs of the changes: (+19 -13)
Index: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp
diff -u poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.26 poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.27
--- poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.26 Fri Nov 14 15:36:52 2003
+++ poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp Fri Nov 14 15:52:22 2003
@@ -152,7 +152,7 @@
// We must alway return unique pointers, even if they asked for 0 bytes
Pool->NodeSize = NodeSize ? NodeSize : 1;
- Pool->Slabs = Pool->ArraySlabs = NULL;
+ Pool->Slabs = Pool->ArraySlabs = Pool->FastArray = NULL;
Pool->FreeList.Next = NULL;
#if 0
Pool->FreeablePool = 1;
@@ -324,14 +324,13 @@
//
// Scan the list of array slabs to see if there is one that fits.
//
- struct SlabHeader * Slabp = Pool->ArraySlabs;
+ struct SlabHeader * Slabp = Pool->FastArray;
struct SlabHeader ** Prevp = &(Pool->ArraySlabs);
//
// Check to see if we have an array slab that has extra space that we
// can use.
//
-#if 0
if ((Slabp != NULL) &&
((Pool->MaxNodesPerPage - Slabp->NextFreeData) >= ArraySize))
{
@@ -341,24 +340,31 @@
Slabp->LiveNodes++;
//
- // Return the data to the caller.
+ // Find the data for the caller.
//
void * Data = (Slabp->Data + (Pool->NodeSize * Slabp->NextFreeData));
- (Slabp->NextFreeData) += ArraySize;
+
+ //
+ // Disconnect the array slab if it is full.
+ //
+ if (((Slabp->NextFreeData) += ArraySize) >= Pool->MaxNodesPerPage)
+ {
+ Pool->FastArray = NULL;
+ }
+
return (Data);
}
-#endif /* 0 */
//
// Scan through all the free array slabs to see if they are large
// enough.
//
- for (; Slabp != NULL; Slabp=Slabp->Next)
+ for (Slabp = Pool->ArraySlabs; Slabp != NULL; Slabp=Slabp->Next)
{
//
// Check to see if this slab has enough room.
//
- if ((Slabp->NodesPerSlab >= ArraySize) && (Slabp->LiveNodes == 0))
+ if (Slabp->NodesPerSlab >= ArraySize)
{
//
// Make the previous node point to the next node.
@@ -398,13 +404,10 @@
//
// If the array has some space, link it into the array "free" list.
//
-#if 0
if ((Slabp->IsManaged == 1) && (Slabp->NextFreeData != Pool->MaxNodesPerPage))
{
- Slabp->Next = Pool->ArraySlabs;
- Pool->ArraySlabs = Slabp;
+ Pool->FastArray = Slabp;
}
-#endif /* 0 */
//
// Return the list of blocks to the caller.
Index: poolalloc/runtime/FreeListAllocator/PoolAllocator.h
diff -u poolalloc/runtime/FreeListAllocator/PoolAllocator.h:1.8 poolalloc/runtime/FreeListAllocator/PoolAllocator.h:1.9
--- poolalloc/runtime/FreeListAllocator/PoolAllocator.h:1.8 Fri Nov 14 10:03:39 2003
+++ poolalloc/runtime/FreeListAllocator/PoolAllocator.h Fri Nov 14 15:52:22 2003
@@ -32,8 +32,11 @@
// Pointer to the list of slabs allocated for this pool
struct SlabHeader * Slabs;
- // List of slabs used to hold arrays
+ // Linked list of slabs used to hold arrays
struct SlabHeader * ArraySlabs;
+
+ // Pointer to the fast alloc array
+ struct SlabHeader * FastArray;
// Pointer to the free list of nodes
struct NodePointer FreeList;
More information about the llvm-commits
mailing list