HotHeap.h 920 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "DebugCommon.h"
  3. #include "BeefySysLib/util/Dictionary.h"
  4. #include "BeefySysLib/util/Array.h"
  5. NS_BF_DBG_BEGIN
  6. class HotHeap
  7. {
  8. public:
  9. enum HotUseFlags
  10. {
  11. HotUseFlags_None,
  12. HotUseFlags_Allocated,
  13. HotUseFlags_Referenced
  14. };
  15. public:
  16. static const int BLOCK_SIZE = 4096;
  17. addr_target mHotAreaStart;
  18. int mHotAreaSize;
  19. Beefy::Array<HotUseFlags> mHotAreaUsed;
  20. int mCurBlockIdx;
  21. int mBlockAllocIdx; // Total blocks allocated, doesn't decrease with frees
  22. Beefy::Dictionary<addr_target, int> mTrackedMap;
  23. public:
  24. HotHeap(addr_target hotStart, int size);
  25. HotHeap();
  26. void AddTrackedRegion(addr_target hotStart, int size);
  27. addr_target Alloc(int size);
  28. void Release(addr_target addr, int size);
  29. void MarkBlockReferenced(addr_target addr);
  30. bool IsReferenced(addr_target addr, int size);
  31. bool IsBlockUsed();
  32. void ClearReferencedFlags();
  33. intptr_target GetUsedSize();
  34. };
  35. NS_BF_DBG_END