예제 #1
0
 private unsafe void CompactHeapObjects(UIntPtr previousEnd)
 {
     while (!this.relocationQueue.IsEmpty)
     {
         UIntPtr sourceAddress      = this.relocationQueue.Read();
         UIntPtr destinationAddress = this.relocationQueue.Read();
         UIntPtr runLength          = this.relocationQueue.Read();
         if (previousEnd != destinationAddress)
         {
             VTable.Assert(previousEnd < destinationAddress);
             if (PageTable.Page(destinationAddress) !=
                 PageTable.Page(previousEnd + PreHeader.Size))
             {
                 if (!PageTable.PageAligned(previousEnd))
                 {
                     UIntPtr pageLimit = PageTable.PagePad(previousEnd);
                     BumpAllocator.WriteUnusedMarker(previousEnd);
                     previousEnd += UIntPtr.Size;
                     Util.MemClear(previousEnd,
                                   pageLimit - previousEnd);
                 }
                 if (!PageTable.PageAligned(destinationAddress))
                 {
                     // This only happens before pinned objects and
                     // large objects
                     UIntPtr start =
                         PageTable.PageAlign(destinationAddress);
                     VTable.Assert(previousEnd <= start);
                     while (start < destinationAddress)
                     {
                         Allocator.WriteAlignment(start);
                         start += UIntPtr.Size;
                     }
                 }
                 UIntPtr objAddr = destinationAddress + PreHeader.Size;
                 InteriorPtrTable.SetFirst(objAddr);
             }
             else
             {
                 VTable.Assert(previousEnd < destinationAddress);
                 UIntPtr start = previousEnd;
                 while (start < destinationAddress)
                 {
                     Allocator.WriteAlignment(start);
                     start += UIntPtr.Size;
                 }
             }
         }
         Util.MemCopy(destinationAddress, sourceAddress, runLength);
         previousEnd = destinationAddress + runLength;
     }
     // Zero out the end of the allocation page
     if (!PageTable.PageAligned(previousEnd))
     {
         UIntPtr pageLimit = PageTable.PagePad(previousEnd);
         Util.MemClear(previousEnd, pageLimit - previousEnd);
     }
     this.relocationQueue.Cleanup(true);
 }
예제 #2
0
 internal Enumerator(ref UIntPtrQueue queue)
 {
     this.pageEnumerator =
         new UnmanagedPageList.Enumerator(ref queue.pageList);
     this.lastPageLimit = queue.writeCursor.cursor;
     this.lastPageStart =
         PageTable.PageAlign((UIntPtr)lastPageLimit);
     this.currentCursor = new PageCursor(null, null);
     if (this.pageEnumerator.MoveNext())
     {
         UIntPtr currentPage = this.pageEnumerator.Current;
         this.SetCursor(currentPage);
     }
 }
예제 #3
0
        internal static unsafe void MarkThreadStack(Thread thread)
        {
            int     stackVariable;
            UIntPtr stackBase = PageTable.PagePad(new UIntPtr(&stackVariable));

            CallStack.SetStackBase(thread, stackBase);
            UIntPtr topPageAddr =
                PageTable.PageAlign(CallStack.StackBase(thread) - 1);

            SetStackPages(topPageAddr, CallStack.StackBase(thread), thread);
            UIntPtr regionAddr, regionSize;
            bool    fUsed = MemoryManager.QueryMemory(topPageAddr,
                                                      out regionAddr,
                                                      out regionSize);

            VTable.Assert(fUsed);
            SetStackPages(regionAddr, topPageAddr, thread);
        }
예제 #4
0
 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);
     }
 }
예제 #5
0
 internal static UIntPtr PageAddrOfCard(UIntPtr c)
 {
     return(PageTable.PageAlign(CardAddr(c)));
 }