Photon Fusion 2.0.4

Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
DynamicHeap Struct Reference

A dynamic heap for allocating and tracking unmanaged objects. More...

Classes

class  Ignore
 Ignore this field when scanning for pointers. More...
 

Public Types

enum class  ObjectFlags : byte
 

Public Member Functions

delegate void CollectGarbageDelegate (DynamicHeap *heap, void **dynamicRoots, int dynamicRootsLength)
 Collect garbage delegate More...
 

Static Public Member Functions

static void AllocateBlock (DynamicHeap *heap)
 
static byte * AllocateInternal (DynamicHeap *heap, int size, out byte block)
 
static Page * AllocatePage (DynamicHeap *heap)
 
static Page * AllocatePage_Internal (DynamicHeap *heap, bool mustSucceed)
 
static int BitScan (uint v)
 
static int BlocksWithAvailablePages (DynamicHeap *heap)
 
static void CollectGarbage (DynamicHeap *heap, void **dynamicRoots, int dynamicRootsLength)
 Collect garbage More...
 
static void Destroy (Block *block)
 
static void ExpandStack (DynamicHeap *heap)
 
static void Free (DynamicHeap *heap, void *ptr)
 Free up an object More...
 
static void FreeInternal (DynamicHeap *heap, void *ptr, Object objData)
 
static int GetBin (int size)
 
static Bin * GetBinByIndex (DynamicHeap *heap, int binIndex)
 
static int GetBinIndexForSize (DynamicHeap *heap, int size)
 
static Page * GetPageForPtr (DynamicHeap *heap, Block *block, void *ptr)
 
static int GetPageOffset (Page *page, ObjectFree *obj)
 
static ushort GetTypeOffset< T > ()
 
static void InitObj (DynamicHeap *heap, Object *obj, ushort type, ushort array, byte block)
 
static void InitRoot (DynamicHeap *heap, Object *obj)
 
static bool IsPtrInBlock (DynamicHeap *heap, Block *block, void *p)
 
static ushort NextGen (DynamicHeap *heap)
 
static int ObjectsFreeCount (Page *p)
 
static int PagesWithAvailableObjectsInBin (Bin *bin)
 
static ObjectFree * ResolvePageOffset (Page *page, int offset)
 
static T * SetForcedAlive< T > (T *ptr)
 Mark an object with ObjectFlags.ForceAlive More...
 
static void ThrowHeapCorrupted ()
 
static byte * TryAllocateFromPage (DynamicHeap *heap, Page *page, int size, out byte block)
 
static int WordCount (int size)
 

Public Attributes

Bin * _bins
 
Block ** _blocks
 
BlockList _blocksFreePages
 
int _blocksUsed
 
Config _config
 
int _gcBlock
 
int _gcBlockPage
 
ushort _gcGen
 
Phase _gcPhase
 
Object ** _gcStack
 
int _gcStackCapacity
 
int _gcStackCount
 
int _memoryAllocated
 
int _objectsAllocated
 
Object ** _rootList
 
int _rootListCapacity
 
int _rootListCount
 
int * _typeMap
 
int _typeMapLength
 
int * _typeMapStrides
 

Static Public Attributes

static byte[] _debruijnTable
 
static Dictionary< Type, TypeData > _types = null
 
static Dictionary< ushort, TypeData > _typesByOffset = null
 

Detailed Description

A dynamic heap for allocating and tracking unmanaged objects.

Member Function Documentation

◆ CollectGarbage()

static void CollectGarbage ( DynamicHeap heap,
void **  dynamicRoots,
int  dynamicRootsLength 
)
static

Collect garbage

Parameters
heapDynamic heap to collect from
dynamicRootsDynamic roots
dynamicRootsLengthDynamic roots length

◆ CollectGarbageDelegate()

delegate void CollectGarbageDelegate ( DynamicHeap heap,
void **  dynamicRoots,
int  dynamicRootsLength 
)

Collect garbage delegate

◆ Free()

static void Free ( DynamicHeap heap,
void *  ptr 
)
static

Free up an object

Parameters
heapHeap to free from
ptrPointer to object
Exceptions
InvalidOperationExceptionThrown if ptr is not a tracked object

◆ SetForcedAlive< T >()

static T* SetForcedAlive< T > ( T *  ptr)
static

Mark an object with ObjectFlags.ForceAlive

Parameters
ptrPointer Object to mark
Template Parameters
TType of object
Returns
Pointer to object
Type Constraints
T :unmanaged 

Member Data Documentation

◆ _debruijnTable

byte [] _debruijnTable
static
Initial value:
= {
0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
}