internal static void Initialize(UIntPtr systemMemorySize) { allocPtr = MemoryManager.AllocateMemory(systemMemorySize); limitPtr = allocPtr + systemMemorySize; if (GC.gcType != GCType.NullCollector) { PageManager.SetStaticDataPages(allocPtr, systemMemorySize); #if !SINGULARITY PageTable.SetProcess(PageTable.Page(allocPtr), PageTable.PageCount(systemMemorySize)); #endif } }
internal static void Initialize() { for (int section = 0; section < sectionCount; section++) { UIntPtr startAddr = (UIntPtr)dataSectionBase[section]; startAddr = PageTable.PageAlign(startAddr); UIntPtr size = (UIntPtr)dataSectionEnd[section] - startAddr; size = PageTable.PagePad(size); PageManager.SetStaticDataPages(startAddr, size); } for (int section = 0; section < sectionCount; section++) { UIntPtr startAddr = (UIntPtr)roDataSectionBase[section]; startAddr = PageTable.PageAlign(startAddr); UIntPtr size = (UIntPtr)roDataSectionEnd[section] - startAddr; size = PageTable.PagePad(size); PageManager.SetStaticDataPages(startAddr, size); } }
public static unsafe void Initialize() { maxEntries = 1 << 16; VTable UIntPtrArrayVtable = ((RuntimeType)typeof(UIntPtr[])).classVtable; tableSize = ObjectLayout.ArraySize(UIntPtrArrayVtable, maxEntries); // Allocate a pool for ZCT BumpAllocator entryPool = new BumpAllocator(PageType.NonGC); UIntPtr memStart = MemoryManager.AllocateMemory(tableSize); entryPool.SetZeroedRange(memStart, tableSize); PageManager.SetStaticDataPages(memStart, tableSize); // Initialize ZCT zeroCountTable = (UIntPtr[]) DeferredReferenceCountingCollector. AllocateArray(ref entryPool, UIntPtrArrayVtable, tableSize); VTable.Assert(zeroCountTable != null, @"zeroCountTable != null"); *(uint *)(Magic.addressOf(zeroCountTable) + PostHeader.Size) = maxEntries; VTable.Assert(zeroCountTable.Length == maxEntries, @"zeroCountTable.Length == maxEntries"); // Build ZCT freeEntries list freeHead = 1; for (uint i = 1; i < maxEntries - 1; i++) { zeroCountTable[i] = (UIntPtr)(((i + 1) << 2) | 0x01); } zeroCountTable[maxEntries - 1] = (UIntPtr)0x01; zctGarbagePicker = (ZCTGarbagePicker)BootstrapMemory. Allocate(typeof(ZCTGarbagePicker)); }
internal static unsafe bool AccumulateRCUpdates(String methodName, int methodIndex, uint maxIndex, AcctRecord rec) { VTable.Assert(RCCollector.ProfilingMode, @"RCCollector.ProfilingMode"); // Return if the page table hasn't been set up yet. if (PageTable.pageTableCount == UIntPtr.Zero) { return(false); } if (methods == null) { // Allocate up front storage for the accounting records. // // This is requisitioned directly from the memory // manager. Care should be taken to ensure that // AccumulateRCUpdates does not indirectly call // methods that may have compiler-inserted RC updates. VTable vtable = ((RuntimeType)typeof(AcctRecord[])).classVtable; UIntPtr size = ObjectLayout.ArraySize(vtable, maxIndex + 1); BumpAllocator profileData = new BumpAllocator(PageType.NonGC); UIntPtr profileDataStart = MemoryManager.AllocateMemory(size); profileData.SetRange(profileDataStart, size); PageManager.SetStaticDataPages(profileDataStart, size); methods = (AcctRecord[])Allocate(ref profileData, vtable, size); VTable.Assert(methods != null, @"methods != null"); *(uint *)(Magic.addressOf(methods) + PostHeader.Size) = maxIndex + 1; } VTable.Assert(methods.Length == maxIndex + 1, @"methods.Length == maxIndex+1"); if (methods[methodIndex].methodName == null) { methodNames[methodIndex].methodName = methodName; } // Not "methodNames[methodIndex].methodName == methodName" // because the Equality operator carries compiler-inserted // RC updates! VTable.Assert(Magic.addressOf(methodNames[methodIndex]. methodName) == Magic.addressOf(methodName), @"Magic.addressOf(methodNames[methodIndex]. methodName) == Magic.addressOf(methodName)"); methods[methodIndex] += rec; return(true); }