diff options
Diffstat (limited to 'src/vm/ceemain.cpp')
-rw-r--r-- | src/vm/ceemain.cpp | 115 |
1 files changed, 3 insertions, 112 deletions
diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp index 9dbe2b9dff..f3b72e01e2 100644 --- a/src/vm/ceemain.cpp +++ b/src/vm/ceemain.cpp @@ -175,7 +175,6 @@ #include "finalizerthread.h" #include "threadsuspend.h" #include "disassembler.h" -#include "gcenv.ee.h" #ifndef FEATURE_PAL #include "dwreport.h" @@ -2447,103 +2446,6 @@ BOOL ExecuteDLL_ReturnOrThrow(HRESULT hr, BOOL fFromThunk) // Initialize the Garbage Collector // -// Prototype for the function that initialzes the garbage collector. -// Should only be called once: here, during EE startup. -// Returns true if the initialization was successful, false otherwise. -// -// When using a standalone GC, this function is loaded dynamically using -// GetProcAddress. -extern "C" bool InitializeGarbageCollector(IGCToCLR* clrToGC, IGCHeap** gcHeap, IGCHandleManager** gcHandleManager, GcDacVars* gcDacVars); - -#ifdef FEATURE_STANDALONE_GC - -void LoadGarbageCollector() -{ - CONTRACTL { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - } CONTRACTL_END; - - TCHAR *standaloneGc = nullptr; - CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_GCStandaloneLocation, &standaloneGc); - HMODULE hMod; - if (!standaloneGc) - { -#ifdef FEATURE_STANDALONE_GC_ONLY - // if the user has set GCUseStandalone but has not given us a standalone location, - // try and load the initialization symbol from the current module. - hMod = GetModuleInst(); -#else - ThrowHR(E_FAIL); -#endif // FEATURE_STANDALONE_GC_ONLY - } - else - { - hMod = CLRLoadLibrary(standaloneGc); - } - - if (!hMod) - { - ThrowHR(E_FAIL); - } - - InitializeGarbageCollectorFunction igcf = (InitializeGarbageCollectorFunction)GetProcAddress(hMod, INITIALIZE_GC_FUNCTION_NAME); - if (!igcf) - { - ThrowHR(E_FAIL); - } - - // at this point we are committing to using the standalone GC - // given to us. - IGCToCLR* gcToClr = new (nothrow) standalone::GCToEEInterface(); - if (!gcToClr) - { - ThrowOutOfMemory(); - } - - IGCHandleManager *pGcHandleManager; - IGCHeap *pGCHeap; - if (!igcf(gcToClr, &pGCHeap, &pGcHandleManager, &g_gc_dac_vars)) - { - ThrowOutOfMemory(); - } - - assert(pGCHeap != nullptr); - assert(pGcHandleManager != nullptr); - g_pGCHeap = pGCHeap; - g_pGCHandleManager = pGcHandleManager; - g_gcDacGlobals = &g_gc_dac_vars; -} - -#endif // FEATURE_STANDALONE_GC - -#ifndef FEATURE_STANDALONE_GC_ONLY -void LoadStaticGarbageCollector() -{ - CONTRACTL{ - THROWS; - GC_TRIGGERS; - MODE_ANY; - } CONTRACTL_END; - - IGCHandleManager *pGcHandleManager; - IGCHeap *pGCHeap; - - if (!InitializeGarbageCollector(nullptr, &pGCHeap, &pGcHandleManager, &g_gc_dac_vars)) - { - ThrowOutOfMemory(); - } - - assert(pGCHeap != nullptr); - assert(pGcHandleManager != nullptr); - g_pGCHeap = pGCHeap; - g_pGCHandleManager = pGcHandleManager; - g_gcDacGlobals = &g_gc_dac_vars; -} -#endif // FEATURE_STANDALONE_GC_ONLY - - void InitializeGarbageCollector() { CONTRACTL{ @@ -2566,21 +2468,10 @@ void InitializeGarbageCollector() g_pFreeObjectMethodTable->SetBaseSize(ObjSizeOf (ArrayBase)); g_pFreeObjectMethodTable->SetComponentSize(1); -#ifdef FEATURE_STANDALONE_GC - if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_GCUseStandalone) -#ifdef FEATURE_STANDALONE_GC_ONLY - || true -#endif // FEATURE_STANDALONE_GC_ONLY - ) - { - LoadGarbageCollector(); - } - else -#endif // FEATURE_STANDALONE_GC + hr = GCHeapUtilities::LoadAndInitialize(); + if (hr != S_OK) { -#ifndef FEATURE_STANDALONE_GC_ONLY - LoadStaticGarbageCollector(); -#endif // FEATURE_STANDALONE_GC_ONLY + ThrowHR(hr); } // Apparently the Windows linker removes global variables if they are never |