diff options
Diffstat (limited to 'src/gc/gccommon.cpp')
-rw-r--r-- | src/gc/gccommon.cpp | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/src/gc/gccommon.cpp b/src/gc/gccommon.cpp index 779aac7296..d1ccddd205 100644 --- a/src/gc/gccommon.cpp +++ b/src/gc/gccommon.cpp @@ -15,17 +15,16 @@ #include "gc.h" #ifdef FEATURE_SVR_GC -SVAL_IMPL_INIT(uint32_t,GCHeap,gcHeapType,GCHeap::GC_HEAP_INVALID); +SVAL_IMPL_INIT(uint32_t,IGCHeap,gcHeapType,IGCHeap::GC_HEAP_INVALID); #endif // FEATURE_SVR_GC -GPTR_IMPL(GCHeap,g_pGCHeap); +SVAL_IMPL_INIT(uint32_t,IGCHeap,maxGeneration,2); -/* global versions of the card table and brick table */ -GPTR_IMPL(uint32_t,g_card_table); +IGCHeapInternal* g_theGCHeap; -/* absolute bounds of the GC memory */ -GPTR_IMPL_INIT(uint8_t,g_lowest_address,0); -GPTR_IMPL_INIT(uint8_t,g_highest_address,0); +#ifdef FEATURE_STANDALONE_GC +IGCToCLR* g_theGCToCLR; +#endif // FEATURE_STANDALONE_GC #ifdef GC_CONFIG_DRIVEN GARY_IMPL(size_t, gc_global_mechanisms, MAX_GLOBAL_GC_MECHANISMS_COUNT); @@ -33,15 +32,18 @@ GARY_IMPL(size_t, gc_global_mechanisms, MAX_GLOBAL_GC_MECHANISMS_COUNT); #ifndef DACCESS_COMPILE -uint8_t* g_ephemeral_low = (uint8_t*)1; -uint8_t* g_ephemeral_high = (uint8_t*)~0; - #ifdef WRITE_BARRIER_CHECK uint8_t* g_GCShadow; uint8_t* g_GCShadowEnd; uint8_t* g_shadow_lowest_address = NULL; #endif +uint32_t* g_gc_card_table; +uint8_t* g_gc_lowest_address = 0; +uint8_t* g_gc_highest_address = 0; +uint8_t* g_gc_ephemeral_low = (uint8_t*)1; +uint8_t* g_gc_ephemeral_high = (uint8_t*)~0; + VOLATILE(int32_t) m_GCLock = -1; #ifdef GC_CONFIG_DRIVEN @@ -112,4 +114,49 @@ void record_changed_seg (uint8_t* start, uint8_t* end, } } +// The runtime needs to know whether we're using workstation or server GC +// long before the GCHeap is created. +void InitializeHeapType(bool bServerHeap) +{ + LIMITED_METHOD_CONTRACT; +#ifdef FEATURE_SVR_GC + IGCHeap::gcHeapType = bServerHeap ? IGCHeap::GC_HEAP_SVR : IGCHeap::GC_HEAP_WKS; +#ifdef WRITE_BARRIER_CHECK + if (IGCHeap::gcHeapType == IGCHeap::GC_HEAP_SVR) + { + g_GCShadow = 0; + g_GCShadowEnd = 0; + } +#endif // WRITE_BARRIER_CHECK +#else // FEATURE_SVR_GC + UNREFERENCED_PARAMETER(bServerHeap); + CONSISTENCY_CHECK(bServerHeap == false); +#endif // FEATURE_SVR_GC +} + +IGCHeap* InitializeGarbageCollector(IGCToCLR* clrToGC) +{ + LIMITED_METHOD_CONTRACT; + + IGCHeapInternal* heap; +#ifdef FEATURE_SVR_GC + assert(IGCHeap::gcHeapType != IGCHeap::GC_HEAP_INVALID); + heap = IGCHeap::gcHeapType == IGCHeap::GC_HEAP_SVR ? SVR::CreateGCHeap() : WKS::CreateGCHeap(); +#else + heap = WKS::CreateGCHeap(); +#endif + + g_theGCHeap = heap; + +#ifdef FEATURE_STANDALONE_GC + assert(clrToGC != nullptr); + g_theGCToCLR = clrToGC; +#else + UNREFERENCED_PARAMETER(clrToGC); + assert(clrToGC == nullptr); +#endif + + return heap; +} + #endif // !DACCESS_COMPILE |