Ejemplo n.º 1
0
        internal static string AllocateString(uint pLength)
        {
            // TODO: Atomic_AquireLock(&sBusy)
            object    obj = Allocate((uint)(sizeof(int) + pLength));
            GCObject *gco = (GCObject *)((byte *)obj.Internal_ReferenceToPointer() - sizeof(GCObject));

            gco->TypeData = typeof(string).GetTypeDataPointer();
            // TODO: Atomic_ReleaseLock(&sBusy)
            return((string)obj);
        }
Ejemplo n.º 2
0
        internal static object AllocateObject(Type.TypeData *typeData)
        {
            // TODO: Atomic_AquireLock(&sBusy)
            object    obj = Allocate(typeData->Size);
            GCObject *gco = (GCObject *)((byte *)obj.Internal_ReferenceToPointer() - sizeof(GCObject));

            gco->TypeData = typeData;
            // TODO: Atomic_ReleaseLock(&sBusy)
            return(obj);
        }
Ejemplo n.º 3
0
        internal static Array AllocateArray(Type.TypeData *typeData, uint count)
        {
            uint elementSize = typeData->ArrayElementType->Size;

            if (!(new RuntimeType(new RuntimeTypeHandle(new IntPtr((void *)typeData->ArrayElementType))).IsValueType))
            {
                elementSize = (uint)sizeof(IntPtr);
            }
            // TODO: Atomic_AquireLock(&sBusy)
            object    obj = Allocate((uint)(sizeof(int) + (elementSize * count)));
            GCObject *gco = (GCObject *)((byte *)obj.Internal_ReferenceToPointer() - sizeof(GCObject));

            gco->TypeData = typeData;
            // TODO: Atomic_ReleaseLock(&sBusy)
            return((Array)obj);
        }
Ejemplo n.º 4
0
        internal static object Allocate(uint objectSize)
        {
            GCObject *gco          = null;
            uint      requiredSize = (uint)(sizeof(GCObject) + objectSize);

            if (!sHeapsReady)
            {
                if (requiredSize <= SmallHeapSize)
                {
                    if (requiredSize > (SmallHeapSize - sReservedSmallHeapUsed))
                    {
                        while (true)
                        {
                            ;
                        }
                    }
                    gco = (GCObject *)(ReservedSmallHeapPointer + sReservedSmallHeapUsed);
                    sReservedSmallHeapUsed += requiredSize;
                }
                else if (requiredSize <= LargeHeapSize)
                {
                    if (requiredSize > (LargeHeapSize - sReservedLargeHeapUsed))
                    {
                        while (true)
                        {
                            ;
                        }
                    }
                    gco = (GCObject *)(ReservedLargeHeapPointer + sReservedLargeHeapUsed);
                    sReservedLargeHeapUsed += requiredSize;
                }
                else
                {
                    while (true)
                    {
                        ;
                    }
                }
            }
            gco->TypeData      = typeof(object).GetTypeDataPointer();
            gco->Flags         = GCObjectFlags.Allocated;
            gco->AllocatedSize = requiredSize;
            gco->ActualSize    = objectSize;
            sReservedObjectPointers[sReservedObjectCount++] = new IntPtr((void *)((byte *)gco + sizeof(GCObject)));
            return(object.Internal_PointerToReference((void *)((byte *)gco + sizeof(GCObject))));
        }
Ejemplo n.º 5
0
			public void UnlinkObjectFromAllocated(GCObject* pObject)
			{
				if (pObject->AllocatedPrev == null) AllocatedFirst = pObject->AllocatedNext;
				else pObject->AllocatedPrev->AllocatedNext = pObject->AllocatedNext;
				if (pObject->AllocatedNext == null) AllocatedLast = pObject->AllocatedPrev;
				else pObject->AllocatedNext->AllocatedPrev = pObject->AllocatedPrev;
			}
Ejemplo n.º 6
0
			public void LinkObjectToAllocated(GCObject* pObject)
			{
				if (AllocatedLast == null)
				{
					pObject->AllocatedPrev = null;
					pObject->AllocatedNext = null;
					AllocatedFirst = pObject;
					AllocatedLast = pObject;
				}
				else
				{
					AllocatedLast->AllocatedNext = pObject;
					pObject->AllocatedPrev = AllocatedLast;
					pObject->AllocatedNext = null;
					AllocatedLast = pObject;
				}
			}