Exemplo n.º 1
0
        internal unsafe static void Initialize(GCType gcType)
        {
            traceablePtrs       = new ManagedPtrAccounting();
            traceablePinnedPtrs = new ManagedPtrAccounting();
            staticPtrs          = new StaticPtrAccounting();

            assertRTypeHeaders       = new AssertRTypeHeaders();
            forGCAssertRTypeHeaders  = assertRTypeHeaders;
            runtimeTypeReckoner      = new RuntimeTypeReckoner();
            forGCRuntimeTypeReckoner = runtimeTypeReckoner;
            runtimeTypeMapper        = new RuntimeTypeMapper();
            forGCRuntimeTypeMapper   = runtimeTypeMapper;
            instanceReckoner         = new InstanceReckoner();
            forGCInstanceReckoner    = instanceReckoner;

            switch (gcType)
            {
            case GCType.MarkSweepCollector: {
                forGCAssertRTypeHeaders  = new SegregatedFreeList.ObjectVisitorWrapper(assertRTypeHeaders);
                forGCRuntimeTypeReckoner = new SegregatedFreeList.ObjectVisitorWrapper(runtimeTypeReckoner);
                forGCRuntimeTypeMapper   = new SegregatedFreeList.ObjectVisitorWrapper(runtimeTypeMapper);
                forGCInstanceReckoner    = new SegregatedFreeList.ObjectVisitorWrapper(instanceReckoner);
                break;
            }
            }

            table = new RuntimeTypeAccounting[TABLE_SIZE];

            MemoryAccounting.initialized = true;
        }
        void VisitObjects(ObjectLayout.ObjectVisitor objectVisitor,
                          UIntPtr lowAddr, UIntPtr highAddr)
        {
            VTable.Assert(PageTable.PageAligned(lowAddr));
            VTable.Assert(PageTable.PageAligned(highAddr));
            UIntPtr lowPage  = PageTable.Page(lowAddr);
            UIntPtr highPage = PageTable.Page(highAddr);

            SegregatedFreeList.VisitObjects(lowPage, highPage, objectVisitor);
        }
Exemplo n.º 3
0
 internal Verifier(NonNullReferenceVisitor referenceVisitor,
                   NonNullReferenceVisitor threadReferenceVisitor,
                   ObjectLayout.ObjectVisitor objectVisitor,
                   StackVerifier stackVerifier)
 {
     this.referenceVisitor       = referenceVisitor;;
     this.threadReferenceVisitor = threadReferenceVisitor;
     this.objectVisitor          = objectVisitor;
     this.stackVerifier          = stackVerifier;
 }
Exemplo n.º 4
0
        internal override void VisitObjects
            (ObjectLayout.ObjectVisitor objVisitor,
            UIntPtr lowAddr,
            UIntPtr highAddr)
        {
            UIntPtr lowPage  = PageTable.Page(lowAddr);
            UIntPtr highPage = PageTable.Page(highAddr);

            SegregatedFreeList.VisitObjects(lowPage,
                                            highPage,
                                            objVisitor);
        }
Exemplo n.º 5
0
 static Verifier()
 {
     genericReferenceVisitor       = new GenericReferenceVisitor();
     genericThreadReferenceVisitor =
         new GenericThreadReferenceVisitor();
     genericObjectVisitor =
         new GenericObjectVisitor(genericReferenceVisitor);
     genericStackVerifier  = new GenericStackVerifier();
     bumpAllocatorVerifier = new Verifier(genericReferenceVisitor,
                                          genericThreadReferenceVisitor,
                                          genericObjectVisitor,
                                          genericStackVerifier);
     segregatedFreeListVerifier =
         new Verifier(genericReferenceVisitor,
                      genericThreadReferenceVisitor,
                      new SegregatedFreeList.ObjectVisitorWrapper(genericObjectVisitor),
                      genericStackVerifier);
 }
Exemplo n.º 6
0
        void VisitObjects(ObjectLayout.ObjectVisitor objectVisitor,
                          UIntPtr lowAddr, UIntPtr highAddr)
        {
            UIntPtr oldAddr    = UIntPtr.Zero;
            UIntPtr objectAddr = lowAddr + PreHeader.Size;

            objectAddr = BumpAllocator.SkipNonObjectData(objectAddr, highAddr);
            while (objectAddr < highAddr)
            {
                if (PageTable.Page(objectAddr) != PageTable.Page(oldAddr))
                {
                    InteriorPtrTable.VerifyFirst(oldAddr, objectAddr);
                }
                oldAddr = objectAddr;
                Object  obj        = Magic.fromAddress(objectAddr);
                UIntPtr objectSize = objectVisitor.Visit(obj);
                objectAddr += objectSize;
                objectAddr  =
                    BumpAllocator.SkipNonObjectData(objectAddr, highAddr);
            }
            VTable.Assert(objectAddr - PreHeader.Size <= highAddr);
        }
Exemplo n.º 7
0
 private static void visitAllObjects(ObjectLayout.ObjectVisitor visitor,
                                     UIntPtr lowPage, UIntPtr highPage)
 {
     for (UIntPtr first = lowPage; first < highPage; first++)
     {
         if (PageTable.IsMyGcPage(first))
         {
             UIntPtr last = first + 1;
             while (last < highPage)
             {
                 if (!PageTable.IsMyGcPage(last))
                 {
                     break;
                 }
                 last++;
             }
             UIntPtr start = PageTable.PageAddr(first);
             UIntPtr end   = PageTable.PageAddr(last);
             GC.installedGC.VisitObjects(visitor, start, end);
             first = last;
         }
     }
 }
Exemplo n.º 8
0
 internal override void VisitObjects
     (ObjectLayout.ObjectVisitor objectVisitor,
     UIntPtr lowAddr,
     UIntPtr highAddr)
 {
 }
Exemplo n.º 9
0
 internal abstract void VisitObjects(ObjectLayout.ObjectVisitor objectVisitor,
                                     UIntPtr lowAddr,
                                     UIntPtr highAddr);
Exemplo n.º 10
0
        void VerifyPages(ObjectLayout.ObjectVisitor objectVisitor)
        {
            UIntPtr page = UIntPtr.Zero;

            while (page < PageTable.pageTableCount)
            {
                UIntPtr startPage = page;
                if (!PageTable.IsMyPage(startPage))
                {
                    page++;
                    continue;
                }
                PageType pageType    = PageTable.Type(page);
                uint     pageProcess = PageTable.Process(page);
                do
                {
                    page++;
                } while (page < PageTable.pageTableCount &&
                         PageTable.Type(page) == pageType &&
                         PageTable.Process(page) == pageProcess);
                UIntPtr endPage = page;
                switch (pageType)
                {
                case PageType.Unallocated:
                case PageType.Unknown:
                case PageType.Shared: {
                    // The region does not belong to us, so there is
                    // nothing to check.
                    break;
                }

                case PageType.UnusedClean:
                case PageType.UnusedDirty: {
                    PageManager.VerifyUnusedRegion(startPage, endPage);
                    break;
                }

                case PageType.System: {
                    // We have looked at the region, but it is off-limits
                    // for the verifier.
                    break;
                }

                case PageType.NonGC: {
                    // Since there may be non-objects in the static data
                    // pages, we cannot apply the heapVerifier to the
                    // region.
                    break;
                }

                case PageType.Stack: {
                    // The page contains (part of) the activation record
                    // stack for one or more threads.
                    break;
                }

                default: {
                    // We have found a data region
                    VTable.Assert(PageTable.IsGcPage(startPage));
                    UIntPtr startAddr = PageTable.PageAddr(startPage);
                    UIntPtr endAddr   = PageTable.PageAddr(endPage);
                    GC.installedGC.VisitObjects(objectVisitor,
                                                startAddr, endAddr);
                    break;
                }
                }
            }
        }