Пример #1
0
        internal static void ConstructHeap()
        {
            PageTable.Initialize();

            MemoryManager.Initialize();
#if OS_WINCE
            UIntPtr heap_commit_size = new UIntPtr(1 << 16);
#elif SINGULARITY
            UIntPtr heap_commit_size = new UIntPtr(1 << 16);
#else
            UIntPtr heap_commit_size = new UIntPtr(1 << 20);
#endif
            UIntPtr os_commit_size = MemoryManager.OperatingSystemCommitSize;
            VTable.Assert(os_commit_size > UIntPtr.Zero);
            VTable.Assert(heap_commit_size >= os_commit_size);
            UIntPtr bootstrapSize;
            if (UIntPtr.Size == 8)
            {
                if (gcType == GCType.ConcurrentMSCollector)
                {
                    // increase bootstrap size so that
                    // the concurrent mark sweep collector will run on
                    // 64-bit Windows
                    bootstrapSize = (UIntPtr)1 << 16;
                }
                else
                {
                    bootstrapSize = (UIntPtr)1 << 15;
                }
            }
            else
            {
                bootstrapSize = (UIntPtr)1 << 14;
            }
            if (bootstrapSize < os_commit_size)
            {
                bootstrapSize = os_commit_size;
            }
            BootstrapMemory.Initialize(bootstrapSize);
            StaticData.Initialize();
            PageManager.Initialize(os_commit_size, heap_commit_size);
            CallStack.Initialize();
        }
Пример #2
0
        static unsafe Thread()
        {
            threadIndexGenerator = 1;

            // Enable Thread.CurrentThread as soon as we can!
            initialThread             = Magic.toThread(BootstrapMemory.Allocate(typeof(Thread)));
            initialThread.threadState = ThreadState.Running;
            initialThread.threadIndex = 0;

            // Allocate tables for thread management
            threadTable = (Thread[])
                          BootstrapMemory.Allocate(typeof(Thread[]), maxThreads);

            // Initialize the thread and event tables
            threadTable[initialThread.threadIndex] = initialThread;
            initialThread.context = Processor.GetCurrentThreadContext();
            initialThread.context->threadIndex =
                unchecked ((ushort)initialThread.threadIndex);
            initialThread.context->UpdateAfterGC(initialThread);

            Tracing.Log(Tracing.Debug, "InitialThread={0:x8}",
                        Magic.addressOf(initialThread));
        }
Пример #3
0
        static GC() // Class Constructor (cctor)
        {
            GC.Initialize();
            switch (gcType)
            {
#if !SINGULARITY || ADAPTIVE_COPYING_COLLECTOR
            case GCType.AdaptiveCopyingCollector: {
                AdaptiveCopyingCollector.Initialize();
                GC.installedGC = AdaptiveCopyingCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || MARK_SWEEP_COLLECTOR
            case GCType.MarkSweepCollector: {
                MarkSweepCollector.Initialize();
                GC.installedGC = MarkSweepCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || TABLE_MARK_SWEEP_COLLECTOR
            case GCType.TableMarkSweepCollector: {
                SimpleMarkSweepCollector.Initialize();
                GC.installedGC = SimpleMarkSweepCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || SEMISPACE_COLLECTOR
            case GCType.SemispaceCollector: {
                SemispaceCollector.Initialize();
                GC.installedGC = SemispaceCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || SLIDING_COLLECTOR
            case GCType.SlidingCollector: {
                SlidingCollector.Initialize();
                GC.installedGC = SlidingCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || CONCURRENT_MS_COLLECTOR
            case GCType.ConcurrentMSCollector: {
                ConcurrentMSCollector.Initialize();
                GC.installedGC = ConcurrentMSCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || ATOMIC_RC_COLLECTOR
            case GCType.AtomicRCCollector: {
                AtomicRCCollector.Initialize();
                GC.installedGC = AtomicRCCollector.instance;
                break;
            }
#endif
#if !SINGULARITY
            case GCType.ReferenceCountingCollector: {
                ReferenceCountingCollector.Initialize();
                GC.installedGC = ReferenceCountingCollector.instance;
                break;
            }
#endif
#if !SINGULARITY
            case GCType.DeferredReferenceCountingCollector: {
                DeferredReferenceCountingCollector.Initialize();
                GC.installedGC = DeferredReferenceCountingCollector.instance;
                break;
            }
#endif
#if !SINGULARITY || NULL_COLLECTOR
            case GCType.NullCollector: {
                VTable.Assert(wbType == 0, "No need for a write barrier");
                GC.installedGC =
                    (NullCollector)
                    BootstrapMemory.Allocate(typeof(NullCollector));
                break;
            }
#endif
#if !SINGULARITY
            case GCType.CoCoMSCollector: {
                CoCoMSCollector.Initialize();
                GC.installedGC = CoCoMSCollector.instance;
                break;
            }
#endif
            default: {
                VTable.NotReached("Unknown GC type: " + gcType);
                break;
            }
            }
            GC.installedGC.NewThreadNotification(Thread.initialThread, true);
            GC.installedGC.ThreadStartNotification(Thread.initialThread.threadIndex);
        }