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

Andrew Lenharth alenhar2 at cs.uiuc.edu
Thu Apr 27 08:50:26 PDT 2006



Changes in directory llvm-poolalloc/runtime/FL2Allocator:

PoolAllocator.cpp updated: 1.51 -> 1.52
PoolAllocator.h updated: 1.25 -> 1.26
---
Log message:

realloc_pc

---
Diffs of the changes:  (+16 -7)

 PoolAllocator.cpp |   20 ++++++++++++++------
 PoolAllocator.h   |    3 ++-
 2 files changed, 16 insertions(+), 7 deletions(-)


Index: llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.cpp
diff -u llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.cpp:1.51 llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.cpp:1.52
--- llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.cpp:1.51	Thu Feb 16 09:50:09 2006
+++ llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.cpp	Thu Apr 27 10:50:02 2006
@@ -538,9 +538,11 @@
 }
 
 template<typename PoolTraits>
-static void *poolalloc_internal(PoolTy<PoolTraits> *Pool, unsigned NumBytes) {
+static void *poolalloc_internal(PoolTy<PoolTraits> *Pool, unsigned NumBytesA) {
   DO_IF_TRACE(fprintf(stderr, "[%d] poolalloc%s(%d) -> ",
-                      getPoolNumber(Pool), PoolTraits::getSuffix(), NumBytes));
+                      getPoolNumber(Pool), PoolTraits::getSuffix(), NumBytesA));
+
+  int NumBytes = NumBytesA;
 
   // If a null pool descriptor is passed in, this is not a pool allocated data
   // structure.  Hand off to the system malloc.
@@ -783,9 +785,9 @@
     DO_IF_TRACE(fprintf(stderr, "0x%X (system realloc)\n", Result));
     return Result;
   }
-  if (Node == 0) return poolalloc(Pool, NumBytes);
+  if (Node == 0) return poolalloc_internal(Pool, NumBytes);
   if (NumBytes == 0) {
-    poolfree(Pool, Node);
+    poolfree_internal(Pool, Node);
     DO_IF_TRACE(fprintf(stderr, "freed\n"));
     return 0;
   }
@@ -797,12 +799,12 @@
   if (Size != ~1U) {
     // FIXME: This is obviously much worse than it could be.  In particular, we
     // never try to expand something in a pool.  This might hurt some programs!
-    void *New = poolalloc(Pool, NumBytes);
+    void *New = poolalloc_internal(Pool, NumBytes);
     assert(New != 0 && "Our poolalloc doesn't ever return null for failure!");
     
     // Copy the min of the new and old sizes over.
     memcpy(New, Node, Size < NumBytes ? Size : NumBytes);
-    poolfree(Pool, Node);
+    poolfree_internal(Pool, Node);
     DO_IF_TRACE(fprintf(stderr, "0x%X (moved)\n", New));
     return New;
   }
@@ -972,6 +974,12 @@
   poolfree_internal(Pool, (char*)Pool->Slabs+Node);
 }
 
+unsigned long long poolrealloc_pc(PoolTy<CompressedPoolTraits> *Pool,
+                                  unsigned long long Node, unsigned NumBytes) {
+  void *Result = poolrealloc_internal(Pool, (char*)Pool->Slabs+Node, NumBytes);
+  return (char*)Result-(char*)Pool->Slabs;
+}
+
 
 //===----------------------------------------------------------------------===//
 // Access Tracing Runtime Library Support


Index: llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h
diff -u llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.25 llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.26
--- llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.25	Wed May 18 14:56:30 2005
+++ llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h	Thu Apr 27 10:50:02 2006
@@ -212,7 +212,8 @@
                                   unsigned NumBytes);
   void poolfree_pc(PoolTy<CompressedPoolTraits> *Pool, unsigned long long Node);
   //void *poolmemalign_pc(PoolTy *Pool, unsigned Alignment, unsigned NumBytes);
-
+  unsigned long long poolrealloc_pc(PoolTy<CompressedPoolTraits> *Pool,
+                                  unsigned long long Node, unsigned NumBytes);
 
   // Access tracing runtime library support.
   void poolaccesstraceinit(void);






More information about the llvm-commits mailing list