174 uintptr_t allocate();
177 void free(uintptr_t
object);
180 size_t recovery(
size_t maxSlabs);
182 bool isPointerValid(uintptr_t
object)
const;
184#if defined(PEDIGREE_BUILDUTILS)
186 void setListForTest(
size_t list);
189 inline size_t objectSize()
const {
193 inline size_t slabSize()
const {
197 inline size_t slabObjectCount()
const {
198 return m_SlabObjectCount;
201 void trackSlab(uintptr_t slab);
219 static constexpr const int NUM_LISTS =
220#if defined(PEDIGREE_BUILDUTILS)
223 MULTIPROCESSOR ? 256 : 1;
226 Slab* m_PartialLists[NUM_LISTS];
227 Slab* m_FastSlabs[NUM_LISTS];
228 Node* m_LargeFreeList;
230 void addSlab(
Slab* slab,
size_t list);
231 void removeSlab(
Slab* slab);
232 bool beginFastPath();
235 void pushFreeObject(
Slab* slab,
Node* node);
236 Node* objectAt(uintptr_t slab,
size_t index)
const;
237 Slab* slabForObject(uintptr_t
object)
const;
240 void freeSlab(uintptr_t slab);
242 Node* initialiseSlab(uintptr_t slab);
243 size_t currentList()
const;
247 size_t m_SlabObjectOffset;
248 size_t m_SlabObjectCount;
254 uintptr_t m_FirstSlab;
255 size_t m_FastPathState;
269#if defined(PEDIGREE_BUILDUTILS)
270 size_t m_TestList = 0;
284 uintptr_t allocate(
size_t nBytes);
285 void free(uintptr_t
mem);
287#if HOSTED && PEDIGREE_HOSTED_SMOKE_TESTS
289 static EXPORTED_PUBLIC uintptr_t guardedAllocateForTest(
size_t nBytes);
290 static EXPORTED_PUBLIC
void guardedFreeForTest(uintptr_t
mem);
293 size_t recovery(
size_t maxSlabs = 1);
295 bool isPointerValid(uintptr_t
mem)
300 bool isWithinHeap(uintptr_t
mem)
const;
302 size_t allocSize(uintptr_t
mem);
306 size_t heapPageCount()
const {
307 return m_HeapPageCount;
310 uintptr_t getSlab(
size_t fullSize);
311 void freeSlab(uintptr_t address,
size_t length);
313#if defined(PEDIGREE_BUILDUTILS)
314 enum class SlabTransitionForTest { Reserved, Mapped, Unmapped };
315 using SlabTransitionHookForTest = void (*)(SlabTransitionForTest transition, uintptr_t address,
319 void setSlabTransitionHookForTest(SlabTransitionHookForTest hook,
void* context);
325 void freeSlabUnlocked(uintptr_t address,
size_t length);
328 size_t headerSize()
const {
331 size_t footerSize()
const {
335 void setVigilance(
bool b) {
338 bool getVigilance()
const {
354 bool isAllocatedPage(uintptr_t address)
const;
357 void markSlabReady(uintptr_t address,
size_t length);
364 uintptr_t backtrace[SLAM_BT_FRAMES];
370 : pedigree_std::conditional<VIGILANT_OVERRUN_CHECK, AllocHeader_VigilantOverrunCheck,
371 AllocHeader_VigilantOverrunCheck_Empty>::type {
377 struct AllocHeader : pedigree_std::conditional<OVERRUN_CHECK, OverrunCheck_Magic,
378 OverrunCheck_Magic_Empty>::type {
384 struct AllocFooter : pedigree_std::conditional<OVERRUN_CHECK, OverrunCheck_Magic,
385 OverrunCheck_Magic_Empty>::type {
395 size_t m_HeapPageCount;
398 size_t m_SlabRegionBitmapEntries;
399 size_t m_SlabRegionPages;
403#if defined(PEDIGREE_BUILDUTILS)
404 SlabTransitionHookForTest m_SlabTransitionHook =
nullptr;
405 void* m_SlabTransitionHookContext =
nullptr;