SmallLeafHeapBlock.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. friend class HeapBucketT<SmallLeafHeapBlockT>;
  12. public:
  13. static const ObjectInfoBits RequiredAttributes = LeafBit;
  14. typedef TBlockAttributes HeapBlockAttributes;
  15. SmallLeafHeapBlockT * GetNextBlock() const { return __super::GetNextBlock()->AsLeafBlock<TBlockAttributes>(); }
  16. void SetNextBlock(SmallLeafHeapBlockT * next) { __super::SetNextBlock(next); }
  17. void ScanNewImplicitRoots(Recycler * recycler);
  18. static SmallLeafHeapBlockT * New(HeapBucketT<SmallLeafHeapBlockT> * bucket);
  19. static void Delete(SmallLeafHeapBlockT * block);
  20. #ifdef RECYCLER_SLOW_CHECK_ENABLED
  21. virtual bool GetFreeObjectListOnAllocator(FreeObject ** freeObjectList) override;
  22. #endif
  23. virtual bool FindHeapObject(void* objectAddress, Recycler * recycler, FindHeapObjectFlags flags, RecyclerHeapObjectInfo& heapObject) override sealed
  24. {
  25. return FindHeapObjectImpl<SmallLeafHeapBlockT>(objectAddress, recycler, flags, heapObject);
  26. }
  27. private:
  28. SmallLeafHeapBlockT(HeapBucketT<SmallLeafHeapBlockT> * bucket, ushort objectSize, ushort objectCount);
  29. };
  30. // Declare the class templates
  31. extern template class SmallLeafHeapBlockT<SmallAllocationBlockAttributes>;
  32. extern template class SmallLeafHeapBlockT<MediumAllocationBlockAttributes>;
  33. typedef SmallLeafHeapBlockT<SmallAllocationBlockAttributes> SmallLeafHeapBlock;
  34. typedef SmallLeafHeapBlockT<MediumAllocationBlockAttributes> MediumLeafHeapBlock;
  35. }