SmallLeafHeapBlock.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace Memory
  7. {
  8. template <class TBlockAttributes>
  9. class SmallLeafHeapBlockT : public SmallHeapBlockT<TBlockAttributes>
  10. {
  11. typedef SmallHeapBlockT<TBlockAttributes> Base;
  12. friend class HeapBucketT<SmallLeafHeapBlockT>;
  13. public:
  14. static const ObjectInfoBits RequiredAttributes = LeafBit;
  15. typedef TBlockAttributes HeapBlockAttributes;
  16. SmallLeafHeapBlockT * GetNextBlock() const
  17. {
  18. HeapBlock* block = Base::GetNextBlock();
  19. return block ? block->template AsLeafBlock<TBlockAttributes>() : nullptr;
  20. }
  21. void SetNextBlock(SmallLeafHeapBlockT * next) { Base::SetNextBlock(next); }
  22. void ScanNewImplicitRoots(Recycler * recycler);
  23. static SmallLeafHeapBlockT * New(HeapBucketT<SmallLeafHeapBlockT> * bucket);
  24. static void Delete(SmallLeafHeapBlockT * block);
  25. #ifdef RECYCLER_SLOW_CHECK_ENABLED
  26. virtual bool GetFreeObjectListOnAllocator(FreeObject ** freeObjectList) override;
  27. #endif
  28. virtual bool FindHeapObject(void* objectAddress, Recycler * recycler, FindHeapObjectFlags flags, RecyclerHeapObjectInfo& heapObject) override sealed
  29. {
  30. return this->template FindHeapObjectImpl<SmallLeafHeapBlockT<TBlockAttributes>>(objectAddress, recycler, flags, heapObject);
  31. }
  32. private:
  33. SmallLeafHeapBlockT(HeapBucketT<SmallLeafHeapBlockT> * bucket, ushort objectSize, ushort objectCount);
  34. };
  35. typedef SmallLeafHeapBlockT<SmallAllocationBlockAttributes> SmallLeafHeapBlock;
  36. typedef SmallLeafHeapBlockT<MediumAllocationBlockAttributes> MediumLeafHeapBlock;
  37. }