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

Chris Lattner lattner at cs.uiuc.edu
Mon Nov 1 21:56:34 PST 2004



Changes in directory poolalloc/runtime/FL2Allocator:

FreeListAllocator.cpp updated: 1.14 -> 1.15
PoolAllocator.h updated: 1.8 -> 1.9

---
Log message:

add support for getting sizes from large array objects


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

Index: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
diff -u poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.14 poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.15
--- poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.14	Mon Nov  1 23:34:16 2004
+++ poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp	Mon Nov  1 23:56:24 2004
@@ -265,6 +265,7 @@
     LAH->Next->Prev = &LAH->Next;
   Pool->LargeArrays = LAH;
   LAH->Prev = &Pool->LargeArrays;
+  LAH->Size = NumBytes;
   LAH->Marker = ~0U;
   DEBUG(printf("alloc large Pool:0x%X NumBytes:%d -> 0x%X\n", Pool,
                NumBytes, LAH+1));
@@ -341,11 +342,6 @@
   if (Size != ~1U) return Size;
 
   // Otherwise, we have a large array.
-  //LargeArrayHeader *LAH = ((LargeArrayHeader*)Node)-1;
-
-  // Note that we don't have a size for this object either, because we got it
-  // from malloc. :(
-  fprintf(stderr, "ERROR: Cannot call poolobjsize on a large array object.  "
-          "Sorry!\n");
-  abort();
+  LargeArrayHeader *LAH = ((LargeArrayHeader*)Node)-1;
+  return LAH->Size;
 }


Index: poolalloc/runtime/FL2Allocator/PoolAllocator.h
diff -u poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.8 poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.9
--- poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.8	Mon Nov  1 23:28:10 2004
+++ poolalloc/runtime/FL2Allocator/PoolAllocator.h	Mon Nov  1 23:56:24 2004
@@ -40,10 +40,13 @@
 
 
 // Large Arrays are passed on to directly malloc, and are not necessarily page
-// aligned.  These arrays are marked by setting the object size preheader to ~0.
+// aligned.  These arrays are marked by setting the object size preheader to ~1.
 // LargeArrays are on their own list to allow for efficient deletion.
 struct LargeArrayHeader {
   LargeArrayHeader **Prev, *Next;
+
+  // Size - This contains the size of the object.
+  unsigned long Size;
   
   // Marker: this is the ObjectSize marker which MUST BE THE LAST ELEMENT of
   // this header!





More information about the llvm-commits mailing list