Permalink
Browse files

Initial check-in.

  • Loading branch information...
emeryberger committed Jun 18, 2012
1 parent 474b049 commit 076e9e7ef53b66380b159e40473b930f25cc353b
Showing with 20,365 additions and 0 deletions.
  1. +341 −0 COPYING
  2. +1 −0 TODO
  3. +208 −0 heaplayers.h
  4. +12 −0 heaps/README
  5. +12 −0 heaps/all.h
  6. +93 −0 heaps/buildingblock/adaptheap.h
  7. +6 −0 heaps/buildingblock/all.h
  8. +68 −0 heaps/buildingblock/boundedfreelistheap.h
  9. +105 −0 heaps/buildingblock/chunkheap.h
  10. +136 −0 heaps/buildingblock/coalesceheap.h
  11. +85 −0 heaps/buildingblock/freelistheap.h
  12. +5 −0 heaps/combining/all.h
  13. +93 −0 heaps/combining/hybridheap.h
  14. +248 −0 heaps/combining/segheap.h
  15. +137 −0 heaps/combining/strictsegheap.h
  16. +56 −0 heaps/combining/tryheap.h
  17. +6 −0 heaps/debug/all.h
  18. +63 −0 heaps/debug/checkheap.h
  19. +56 −0 heaps/debug/debugheap.h
  20. +272 −0 heaps/debug/logheap.h
  21. +115 −0 heaps/debug/sanitycheckheap.h
  22. +97 −0 heaps/debug/statsheap.h
  23. +4 −0 heaps/general/all.h
  24. +438 −0 heaps/general/dlheap.h
  25. +125 −0 heaps/general/kingsleyheap.h
  26. +61 −0 heaps/general/leamallocheap.h
  27. +69 −0 heaps/objectrep/addheap.h
  28. +6 −0 heaps/objectrep/all.h
  29. +339 −0 heaps/objectrep/coalesceableheap.h
  30. +93 −0 heaps/objectrep/sizeheap.h
  31. +89 −0 heaps/objectrep/sizeownerheap.h
  32. +152 −0 heaps/special/nestedheap.h
  33. +297 −0 heaps/special/obstack.h
  34. +289 −0 heaps/special/obstackheap.h
  35. +312 −0 heaps/special/obstackreap.h
  36. +122 −0 heaps/special/sbrk.c
  37. +121 −0 heaps/special/xallocheap.h
  38. +152 −0 heaps/special/zoneheap.h
  39. +6 −0 heaps/threads/all.h
  40. +70 −0 heaps/threads/lockedheap.h
  41. +97 −0 heaps/threads/phothreadheap.h
  42. +65 −0 heaps/threads/sizethreadheap.h
  43. +99 −0 heaps/threads/threadheap.h
  44. +109 −0 heaps/threads/threadspecificheap.h
  45. +5 −0 heaps/top/all.h
  46. +82 −0 heaps/top/mallocheap.h
  47. +207 −0 heaps/top/mmapheap.h
  48. +56 −0 heaps/top/sbrkheap.h
  49. +80 −0 heaps/top/staticheap.h
  50. +11 −0 heaps/utility/all.h
  51. +66 −0 heaps/utility/exceptionheap.h
  52. +139 −0 heaps/utility/localmallocheap.h
  53. +51 −0 heaps/utility/nullheap.h
  54. +73 −0 heaps/utility/oneheap.h
  55. +78 −0 heaps/utility/perclassheap.h
  56. +83 −0 heaps/utility/profileheap.h
  57. +113 −0 heaps/utility/slopheap.h
  58. +257 −0 heaps/utility/traceheap.h
  59. +137 −0 heaps/utility/uniqueheap.h
  60. +71 −0 locks/maclock.h
  61. +76 −0 locks/posixlock.h
  62. +90 −0 locks/recursivelock.h
  63. +264 −0 locks/spinlock.h
  64. +88 −0 locks/winlock.h
  65. +2 −0 threads/all.h
  66. +172 −0 threads/cpuinfo.h
  67. +100 −0 threads/fred.h
  68. BIN utility/a.out
  69. +23 −0 utility/align.h
  70. +19 −0 utility/all.h
  71. +12 −0 utility/bins.h
  72. +56 −0 utility/bins16k.h
  73. +62 −0 utility/bins4k.h
  74. +137 −0 utility/bins64k.h
  75. +53 −0 utility/bins8k.h
  76. +114 −0 utility/dllist.h
  77. +142 −0 utility/dynarray.h
  78. +71 −0 utility/freesllist.h
  79. +15 −0 utility/gcd.h
  80. +50 −0 utility/guard.h
  81. +43 −0 utility/hash.h
  82. +49 −0 utility/istrue.h
  83. +11 −0 utility/lcm.h
  84. +139 −0 utility/myhashmap.h
  85. +27 −0 utility/sassert.h
  86. +103 −0 utility/sllist.h
  87. +14 −0 utility/testalign.cpp
  88. +365 −0 utility/timer.h
  89. +341 −0 wrappers/COPYING
  90. +46 −0 wrappers/README.html
  91. +48 −0 wrappers/README.md
  92. +48 −0 wrappers/README.md~
  93. +1 −0 wrappers/TODO
  94. +4 −0 wrappers/all.h
  95. +107 −0 wrappers/ansiwrapper.h
  96. +50 −0 wrappers/arch-specific/mallocinfo.h
  97. +7 −0 wrappers/arch-specific/sparc-interchange.il
  98. +8 −0 wrappers/arch-specific/x86-interchange.il
  99. +7 −0 wrappers/arch-specific/x86_64-interchange.il
  100. +201 −0 wrappers/gnuwrapper.cpp
  101. +208 −0 wrappers/heaplayers.h
  102. +12 −0 wrappers/heaps/README
  103. +12 −0 wrappers/heaps/all.h
  104. +93 −0 wrappers/heaps/buildingblock/adaptheap.h
  105. +6 −0 wrappers/heaps/buildingblock/all.h
  106. +68 −0 wrappers/heaps/buildingblock/boundedfreelistheap.h
  107. +105 −0 wrappers/heaps/buildingblock/chunkheap.h
  108. +136 −0 wrappers/heaps/buildingblock/coalesceheap.h
  109. +85 −0 wrappers/heaps/buildingblock/freelistheap.h
  110. +5 −0 wrappers/heaps/combining/all.h
  111. +93 −0 wrappers/heaps/combining/hybridheap.h
  112. +248 −0 wrappers/heaps/combining/segheap.h
  113. +137 −0 wrappers/heaps/combining/strictsegheap.h
  114. +56 −0 wrappers/heaps/combining/tryheap.h
  115. +6 −0 wrappers/heaps/debug/all.h
  116. +63 −0 wrappers/heaps/debug/checkheap.h
  117. +56 −0 wrappers/heaps/debug/debugheap.h
  118. +272 −0 wrappers/heaps/debug/logheap.h
  119. +115 −0 wrappers/heaps/debug/sanitycheckheap.h
  120. +97 −0 wrappers/heaps/debug/statsheap.h
  121. +4 −0 wrappers/heaps/general/all.h
  122. +438 −0 wrappers/heaps/general/dlheap.h
  123. +125 −0 wrappers/heaps/general/kingsleyheap.h
  124. +61 −0 wrappers/heaps/general/leamallocheap.h
  125. +69 −0 wrappers/heaps/objectrep/addheap.h
  126. +6 −0 wrappers/heaps/objectrep/all.h
  127. +339 −0 wrappers/heaps/objectrep/coalesceableheap.h
  128. +93 −0 wrappers/heaps/objectrep/sizeheap.h
  129. +89 −0 wrappers/heaps/objectrep/sizeownerheap.h
  130. +152 −0 wrappers/heaps/special/nestedheap.h
  131. +297 −0 wrappers/heaps/special/obstack.h
  132. +289 −0 wrappers/heaps/special/obstackheap.h
  133. +312 −0 wrappers/heaps/special/obstackreap.h
  134. +122 −0 wrappers/heaps/special/sbrk.c
  135. +121 −0 wrappers/heaps/special/xallocheap.h
  136. +152 −0 wrappers/heaps/special/zoneheap.h
  137. +6 −0 wrappers/heaps/threads/all.h
  138. +70 −0 wrappers/heaps/threads/lockedheap.h
  139. +97 −0 wrappers/heaps/threads/phothreadheap.h
  140. +65 −0 wrappers/heaps/threads/sizethreadheap.h
  141. +99 −0 wrappers/heaps/threads/threadheap.h
  142. +109 −0 wrappers/heaps/threads/threadspecificheap.h
  143. +5 −0 wrappers/heaps/top/all.h
  144. +82 −0 wrappers/heaps/top/mallocheap.h
  145. +207 −0 wrappers/heaps/top/mmapheap.h
  146. +56 −0 wrappers/heaps/top/sbrkheap.h
  147. +80 −0 wrappers/heaps/top/staticheap.h
  148. +11 −0 wrappers/heaps/utility/all.h
  149. +66 −0 wrappers/heaps/utility/exceptionheap.h
  150. +139 −0 wrappers/heaps/utility/localmallocheap.h
  151. +51 −0 wrappers/heaps/utility/nullheap.h
  152. +73 −0 wrappers/heaps/utility/oneheap.h
  153. +78 −0 wrappers/heaps/utility/perclassheap.h
  154. +83 −0 wrappers/heaps/utility/profileheap.h
  155. +113 −0 wrappers/heaps/utility/slopheap.h
  156. +257 −0 wrappers/heaps/utility/traceheap.h
  157. +137 −0 wrappers/heaps/utility/uniqueheap.h
  158. +71 −0 wrappers/locks/maclock.h
  159. +76 −0 wrappers/locks/posixlock.h
  160. +90 −0 wrappers/locks/recursivelock.h
  161. +264 −0 wrappers/locks/spinlock.h
  162. +88 −0 wrappers/locks/winlock.h
  163. +20 −0 wrappers/macinterpose.h
  164. +487 −0 wrappers/macwrapper.cpp
  165. +154 −0 wrappers/mmapwrapper.h
  166. +164 −0 wrappers/stlallocator.h
  167. +2 −0 wrappers/threads/all.h
  168. +172 −0 wrappers/threads/cpuinfo.h
  169. +100 −0 wrappers/threads/fred.h
  170. BIN wrappers/utility/a.out
  171. +23 −0 wrappers/utility/align.h
  172. +19 −0 wrappers/utility/all.h
  173. +12 −0 wrappers/utility/bins.h
  174. +56 −0 wrappers/utility/bins16k.h
  175. +62 −0 wrappers/utility/bins4k.h
  176. +137 −0 wrappers/utility/bins64k.h
  177. +53 −0 wrappers/utility/bins8k.h
  178. +114 −0 wrappers/utility/dllist.h
  179. +142 −0 wrappers/utility/dynarray.h
  180. +71 −0 wrappers/utility/freesllist.h
  181. +15 −0 wrappers/utility/gcd.h
  182. +50 −0 wrappers/utility/guard.h
  183. +43 −0 wrappers/utility/hash.h
  184. +49 −0 wrappers/utility/istrue.h
  185. +11 −0 wrappers/utility/lcm.h
  186. +139 −0 wrappers/utility/myhashmap.h
  187. +27 −0 wrappers/utility/sassert.h
  188. +103 −0 wrappers/utility/sllist.h
  189. +14 −0 wrappers/utility/testalign.cpp
  190. +365 −0 wrappers/utility/timer.h
  191. +322 −0 wrappers/winwrapper.cpp
  192. +420 −0 wrappers/wrapper.cpp
View
341 COPYING

Large diffs are not rendered by default.

Oops, something went wrong.
View
1 TODO
@@ -0,0 +1 @@
- Make MyHashMap dynamic.
View
@@ -0,0 +1,208 @@
// -*- C++ -*-
/*
Heap Layers: An Extensible Memory Allocation Infrastructure
Copyright (C) 2000-2012 by Emery Berger
http://www.cs.umass.edu/~emery
emery@cs.umass.edu
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file heaplayers.h
* @brief The master Heap Layers include file.
*
* Heap Layers is an extensible memory allocator infrastructure. For
* more information, read the PLDI 2001 paper "Composing
* High-Performance Memory Allocators", by Emery D. Berger, Benjamin
* G. Zorn, and Kathryn S. McKinley.
* (http://citeseer.ist.psu.edu/berger01composing.html)
*/
#ifndef HL_HEAPLAYERS_H
#define HL_HEAPLAYERS_H
namespace HL {};
// Define HL_EXECUTABLE_HEAP as 1 if you want that (i.e., you're doing
// dynamic code generation).
#define HL_EXECUTABLE_HEAP 0
#if defined(_MSC_VER)
// Microsoft Visual Studio
#pragma inline_depth(255)
#define INLINE __forceinline
//#define inline __forceinline
#define NO_INLINE __declspec(noinline)
#pragma warning(disable: 4530)
#define MALLOC_FUNCTION
#define RESTRICT
#elif defined(__GNUC__)
// GNU C
#define NO_INLINE __attribute__ ((noinline))
#define INLINE inline
#define MALLOC_FUNCTION __attribute__((malloc))
#define RESTRICT __restrict__
#else
// All others
#define NO_INLINE
#define INLINE inline
#define MALLOC_FUNCTION
#define RESTRICT
#endif
/**
* @def ALLOCATION_STATS
*
* Defining ALLOCATION_STATS below as 1 enables tracking of allocation
* statistics in a variety of layers. You then must link in
* definitions of the extern variables used therein; stats.cpp
* contains these definitions.
*
* This should be undefined for all but experimental use.
*
*/
#ifndef ALLOCATION_STATS
#define ALLOCATION_STATS 0
#endif
#ifdef _MSC_VER
// 4786: Disable warnings about long (> 255 chars) identifiers.
// 4512: Disable warnings about assignment operators.
#pragma warning( push )
#pragma warning( disable:4786 4512 )
#endif
#include "sassert.h"
// #include "utility.h" // convenient wrappers to replace C++ new & delete operators
#include "dynarray.h" // an array that grows by doubling
#include "myhashmap.h"
// Hiding machine dependencies.
#include "cpuinfo.h"
#include "timer.h" // allows high-resolution timing across a wide range of platforms
#include "guard.h"
#include "fred.h"
// Lock implementations.
#include "spinlock.h" // spin-then-yield
#if defined(_WIN32)
#include "winlock.h" // critical-sections (i.e., for Windows only)
#include "recursivelock.h" // a wrapper for recursive locking
#endif
// Useful utilities.
#include "uniqueheap.h"
#include "tryheap.h"
// Base heaps
#include "zoneheap.h" // a zone allocator (frees all memory when the heap goes out of scope)
// Adapters
#include "perclassheap.h" // make a per-class heap
// Freelist-like heaps ("allocation caches")
// NB: All of these should be used for exactly one size class.
#include "freelistheap.h" // a free list. Never frees memory.
//#include "fifofreelist.h" // a FIFO free list.
//#include "fifodlfreelist.h" // a doubly-linked FIFO free list.
#include "boundedfreelistheap.h" // a free list with a bounded length.
#include "nullheap.h"
#include "coalesceheap.h" // A chunk heap with coalescing.
#include "coalesceableheap.h"
// Utility heap layers
#include "sizethreadheap.h" // Adds size(ptr) & thread(ptr) methods
#include "lockedheap.h" // Code-locks a heap
#include "checkheap.h" // Raises assertions if malloc'ed objects aren't right.
// #include "exceptionheap.h" // Raise an exception if a malloc fails.
#include "sanitycheckheap.h" // Check for multiple frees and mallocs of same locations.
#include "ansiwrapper.h" // Provide ANSI C like behavior for malloc (alignment, etc.)
// Multi-threaded heaps
// hashes the thread id across a number of heaps
//#include "phothreadheap.h" // Private-heaps with ownership
#include "threadheap.h" // Pure-private heaps (sort of)
// Generic heaps
#include "segheap.h" // A *very general* segregated fits allocator.
// "Standard" heap layers
#include "kingsleyheap.h" // A power-of-two size class allocator,
// a la Chris Kingsley's BSD allocator.
// "Top" heaps.
#include "mallocheap.h" // a thin wrapper around the system's malloc/free
#include "mmapheap.h" // a wrapper around the system's virtual memory system
// the rest...
#include "oneheap.h"
#include "debugheap.h"
#include "sizeheap.h"
#include "addheap.h"
#include "profileheap.h"
#include "sizeownerheap.h"
#include "hybridheap.h"
#include "traceheap.h"
#include "stlallocator.h"
#include "adaptheap.h"
#include "dllist.h"
#include "dlheap.h"
// #include "logheap.h"
// #include "obstackheap.h"
// #include "sbrkheap.h"
// #include "xallocHeap.h" // 197.parser's heap
#include "staticheap.h"
#ifdef _MSC_VER
#pragma warning( pop )
#endif
#endif // _HEAPLAYERS_H_
View
@@ -0,0 +1,12 @@
Heap organization:
top/ - "source" heaps that have no superheap.
combining/ - heaps whose purpose is to combine two existing superheaps.
debug/ - heaps whose only purpose is debugging or statistics-gathering.
threads/ - heaps designed to support multiple threads.
special/ - esoteric heaps to support custom allocation schemes like obstacks.
buildingblock/ - layers that cannot be used standalone but rather are useful for building other heaps.
objectrep/ - heaps that change the representation of individual objects (e.g., by adding headers).
(admittedly this is a terrible organizational principle)
utility/ - currently a grab-bag
View
@@ -0,0 +1,12 @@
#include "buildingblock/all.h"
#include "debug/all.h"
#include "objectrep/all.h"
#include "threads/all.h"
#include "utility/all.h"
#include "combining/all.h"
#include "general/all.h"
#include "top/all.h"
// #include "special/"
@@ -0,0 +1,93 @@
// -*- C++ -*-
/*
Heap Layers: An Extensible Memory Allocation Infrastructure
Copyright (C) 2000-2012 by Emery Berger
http://www.cs.umass.edu/~emery
emery@cs.umass.edu
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef HL_ADAPTHEAP_H
#define HL_ADAPTHEAP_H
/**
* @class AdaptHeap
* @brief Maintains dictionary entries through freed objects.
* Sample dictionaries include DLList and SLList.
*/
namespace HL {
template <class Dictionary, class SuperHeap>
class AdaptHeap : public SuperHeap {
public:
enum { Alignment = SuperHeap::Alignment };
/// Allocate an object (remove from the dictionary).
inline void * malloc (const size_t) {
void * ptr = (Entry *) dict.get();
if (ptr) {
assert (SuperHeap::getSize(ptr) >= sizeof(dict));
}
return ptr;
}
/// Deallocate the object (return to the dictionary).
inline void free (void * ptr) {
if (ptr) {
assert (SuperHeap::getSize(ptr) >= sizeof(dict));
Entry * entry = (Entry *) ptr;
dict.insert (entry);
}
}
/// Remove an object from the dictionary.
inline int remove (void * ptr) {
if (ptr) {
assert (SuperHeap::getSize(ptr) >= sizeof(dict));
dict.remove ((Entry *) ptr);
}
return 1;
}
/// Clear the dictionary.
inline void clear (void) {
Entry * ptr;
while ((ptr = (Entry *) dict.get()) != NULL) {
SuperHeap::free (ptr);
}
dict.clear();
SuperHeap::clear();
}
private:
/// The dictionary object.
Dictionary dict;
class Entry : public Dictionary::Entry {};
};
}
#endif // HL_ADAPTHEAP
@@ -0,0 +1,6 @@
#include "adaptheap.h"
#include "boundedfreelistheap.h"
#include "chunkheap.h"
#include "coalesceheap.h"
#include "freelistheap.h"
Oops, something went wrong.

0 comments on commit 076e9e7

Please sign in to comment.