Class ManagedObjectHeap
- Namespace
- Echo.Platforms.AsmResolver.Emulation.Heap
- Assembly
- Echo.Platforms.AsmResolver.dll
Represents a heap of managed objects.
public class ManagedObjectHeap : IMemorySpace
- Inheritance
-
ManagedObjectHeap
- Implements
- Inherited Members
Constructors
ManagedObjectHeap(IHeap, ValueFactory)
Creates a new empty heap for managed objects.
public ManagedObjectHeap(IHeap backingHeap, ValueFactory factory)
Parameters
backingHeapIHeapThe backing heap to use for allocating raw memory.
factoryValueFactoryThe object responsible for managing type information.
ManagedObjectHeap(int, ValueFactory)
Creates a new empty heap for managed objects.
public ManagedObjectHeap(int size, ValueFactory factory)
Parameters
sizeintThe maximum size the heap can grow.
factoryValueFactoryThe object responsible for managing type information.
Properties
AddressRange
Gets the range that this memory space spans.
public AddressRange AddressRange { get; }
Property Value
Methods
AllocateFlat(uint, bool)
Allocates flat unmanaged memory in the heap (i.e., without any object header).
public long AllocateFlat(uint size, bool initialize)
Parameters
sizeuintThe size in bytes of the memory region to allocate.
initializeboolA value indicating whether the object should be initialized with zeroes.
Returns
- long
The address of the memory that was allocated.
AllocateObject(ITypeDescriptor, bool)
Allocates a managed object of the provided type in the heap.
public long AllocateObject(ITypeDescriptor type, bool initialize)
Parameters
typeITypeDescriptorThe type of object to allocate.
initializeboolA value indicating whether the object should be initialized with zeroes.
Returns
- long
The address of the object that was allocated.
Exceptions
- InvalidOperationException
Occurs when the provided type's size is unknown (e.g. when the type is an array or string type).
AllocateString(BitVector)
Allocates a string into the virtual managed heap.
public long AllocateString(BitVector contents)
Parameters
contentsBitVectorThe string data.
Returns
- long
The address of the string that was allocated.
AllocateString(int, bool)
Allocates a string into the virtual managed heap.
public long AllocateString(int length, bool initialize)
Parameters
lengthintThe number of characters in the string.
initializeboolA value indicating whether all characters should be initialized with zeroes.
Returns
- long
The address of the string that was allocated.
AllocateString(string)
Allocates a string into the virtual managed heap.
public long AllocateString(string value)
Parameters
valuestringThe string literal.
Returns
- long
The address of the string that was allocated.
AllocateSzArray(TypeSignature, int, bool)
Allocates a single dimension, zero-based array on the heap.
public long AllocateSzArray(TypeSignature elementType, int elementCount, bool initialize)
Parameters
elementTypeTypeSignatureThe type of elements the array stores.
elementCountintThe number of elements in the array.
initializeboolA value indicating whether the elements should be initialized with zeroes.
Returns
- long
The address of the array that was allocated.
Free(long)
Releases an object from the heap.
public void Free(long address)
Parameters
addresslongThe address of the object.
GetInternedString(string)
Gets the address to an interned string in the virtual managed heap.
public long GetInternedString(string value)
Parameters
valuestringThe string.
Returns
- long
The address of the interned string.
GetObjectRanges()
Obtains a collection of address ranges of all managed objects currently in the heap.
public IEnumerable<AddressRange> GetObjectRanges()
Returns
- IEnumerable<AddressRange>
The ranges.
GetObjectSize(long)
Gets the size of the object at the provided address.
public uint GetObjectSize(long address)
Parameters
addresslongThe address of the object.
Returns
- uint
The size in bytes.
GetObjectSpan(BitVectorSpan)
Gets a bit vector slice that spans the contents of the object at the provided address.
public BitVectorSpan GetObjectSpan(BitVectorSpan address)
Parameters
addressBitVectorSpanThe address of the object.
Returns
- BitVectorSpan
The object slice.
GetObjectSpan(long)
Gets a bit vector slice that spans the contents of the object at the provided address.
public BitVectorSpan GetObjectSpan(long address)
Parameters
addresslongThe address of the object.
Returns
- BitVectorSpan
The object slice.
IsValidAddress(long)
Gets a value indicating whether the provided address is a valid address, and can be used to read and/or write to.
public bool IsValidAddress(long address)
Parameters
addresslongThe address to query.
Returns
- bool
trueif the address was valid,falseotherwise.
Read(long, BitVectorSpan)
Copies data at the provided address into the provided buffer.
public void Read(long address, BitVectorSpan buffer)
Parameters
addresslongThe address to start reading at.
bufferBitVectorSpanThe buffer to write into.
Rebase(long)
Relocates the memory to a new base address.
public void Rebase(long baseAddress)
Parameters
baseAddresslongThe new base address.
Write(long, BitVectorSpan)
Writes the provided buffer of data at the provided address.
public void Write(long address, BitVectorSpan buffer)
Parameters
addresslongThe address to start writing at.
bufferBitVectorSpanThe data to write.
Write(long, ReadOnlySpan<byte>)
Writes the provided buffer of data at the provided address.
public void Write(long address, ReadOnlySpan<byte> buffer)
Parameters
addresslongThe address to start writing at.
bufferReadOnlySpan<byte>The data to write.