[llvm-commits] CVS: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp PoolAllocator.h
John Criswell
criswell at cs.uiuc.edu
Fri Nov 14 10:04:01 PST 2003
Changes in directory poolalloc/runtime/FreeListAllocator:
PoolAllocator.cpp updated: 1.20 -> 1.21
PoolAllocator.h updated: 1.7 -> 1.8
---
Log message:
Calculate the maximum number of nodes per page once for each pool instead
of every time we create a slab.
This provides minor performance improvement, I think.
---
Diffs of the changes: (+7 -6)
Index: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp
diff -u poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.20 poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.21
--- poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.20 Fri Nov 14 09:35:14 2003
+++ poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp Fri Nov 14 10:03:39 2003
@@ -39,7 +39,7 @@
createSlab (PoolTy * Pool, unsigned int NodesPerSlab = 0)
{
// Maximum number of nodes per page
- unsigned int MaxNodesPerPage;
+ unsigned int MaxNodesPerPage = Pool->MaxNodesPerPage;
// Pointer to the new Slab
struct SlabHeader * NewSlab;
@@ -48,11 +48,6 @@
unsigned int NodeSize = Pool->NodeSize;
//
- // Determine how many nodes can exist within a regular slab.
- //
- MaxNodesPerPage = (PageSize - sizeof (struct SlabHeader)) / (sizeof (NodePointer) + NodeSize);
-
- //
// If we can't fit a node into a page, give up.
//
if (NodeSize > PageSize)
@@ -166,6 +161,9 @@
#if 0
Pool->FreeablePool = 1;
#endif /* 0 */
+
+ // Calculate once for this pool the maximum number of nodes per page
+ Pool->MaxNodesPerPage = (PageSize - sizeof (struct SlabHeader)) / (sizeof (NodePointer) + NodeSize);
//
// Initialize the page manager.
Index: poolalloc/runtime/FreeListAllocator/PoolAllocator.h
diff -u poolalloc/runtime/FreeListAllocator/PoolAllocator.h:1.7 poolalloc/runtime/FreeListAllocator/PoolAllocator.h:1.8
--- poolalloc/runtime/FreeListAllocator/PoolAllocator.h:1.7 Thu Nov 13 18:16:30 2003
+++ poolalloc/runtime/FreeListAllocator/PoolAllocator.h Fri Nov 14 10:03:39 2003
@@ -26,6 +26,9 @@
// NodeSize - Keep track of the object size tracked by this pool
unsigned NodeSize;
+ // Maximum number of nodes per page
+ unsigned int MaxNodesPerPage;
+
// Pointer to the list of slabs allocated for this pool
struct SlabHeader * Slabs;
More information about the llvm-commits
mailing list