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

John Criswell criswell at cs.uiuc.edu
Thu Nov 13 22:41:01 PST 2003


Changes in directory poolalloc/runtime/FreeListAllocator:

PoolAllocator.cpp updated: 1.18 -> 1.19

---
Log message:

Removed needless pointer deferencing.  This seems to speed up some of the
Olden benchmarks.



---
Diffs of the changes:  (+18 -14)

Index: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp
diff -u poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.18 poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.19
--- poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.18	Thu Nov 13 22:35:10 2003
+++ poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp	Thu Nov 13 22:40:09 2003
@@ -231,6 +231,9 @@
   // Pointer to the data block to return
   void * Data;
 
+  // Slab Pointer
+  struct SlabHeader * Slabp;
+
   assert(Pool && "Null pool pointer passed in to poolalloc!\n");
 
   //
@@ -246,23 +249,24 @@
   // If we don't have a slab, this is our first initialization.  Do some
   // quick stuff.
   //
-  if (Pool->Slabs == NULL)
+  Slabp = Pool->Slabs;
+  if (Slabp == NULL)
   {
-    Pool->Slabs = createSlab (Pool);
-    (Pool->Slabs->NextFreeData)++;
-    return (Pool->Slabs->Data);
+    Pool->Slabs = Slabp = createSlab (Pool);
+    (Slabp->NextFreeData)++;
+    return (Slabp->Data);
   }
 
   //
   // Determine whether we can allocate from the current slab.
   //
-  if (Pool->Slabs->NextFreeData < Pool->Slabs->NodesPerSlab)
+  if (Slabp->NextFreeData < Slabp->NodesPerSlab)
   {
     //
     // Return the block and increment the index of the next free data block.
     //
-    Data = (Pool->Slabs->Data + (Pool->NodeSize * Pool->Slabs->NextFreeData));
-    (Pool->Slabs->NextFreeData)++;
+    Data = (Slabp->Data + (Pool->NodeSize * Slabp->NextFreeData));
+    (Slabp->NextFreeData)++;
     return (Data);
   }
 
@@ -275,27 +279,27 @@
     //
     // Create a new slab and add it to the list.
     //
-    struct SlabHeader * NewSlab = createSlab (Pool);
-    NewSlab->Next = Pool->Slabs;
-    Pool->Slabs = NewSlab;
+    Slabp = createSlab (Pool);
+    Slabp->Next = Pool->Slabs;
+    Pool->Slabs = Slabp;
 
-    (NewSlab->NextFreeData)++;
+    (Slabp->NextFreeData)++;
 
     //
     // Return the block and increment the index of the next free data block.
     //
-    return (Pool->Slabs->Data);
+    return (Slabp->Data);
   }
 
   //
   // Determine which slab owns this block.
   //
-  struct SlabHeader * slabp = BlockOwner (PageSize, Pool->FreeList);
+  Slabp = BlockOwner (PageSize, Pool->FreeList);
 
   //
   // Find the data block that corresponds with this pointer.
   //
-  Data = (slabp->Data + (Pool->NodeSize * (Pool->FreeList.Next - &(slabp->BlockList[0]))));
+  Data = (Slabp->Data + (Pool->NodeSize * (Pool->FreeList.Next - &(Slabp->BlockList[0]))));
 
   //
   // Unlink the first block.





More information about the llvm-commits mailing list