diff options
author | Aditya Mandaleeka <adityam@microsoft.com> | 2017-03-23 16:23:05 -0700 |
---|---|---|
committer | Aditya Mandaleeka <adityam@microsoft.com> | 2017-03-29 12:05:39 -0700 |
commit | 8d02c0786825a27d67fb2af150f751dbda360bef (patch) | |
tree | c702d97c98dbf10da04aa28e89f6a642898e261e /src/vm | |
parent | 066793782f1100b55cf092f50fa15d6901d6be75 (diff) | |
download | coreclr-8d02c0786825a27d67fb2af150f751dbda360bef.tar.gz coreclr-8d02c0786825a27d67fb2af150f751dbda360bef.tar.bz2 coreclr-8d02c0786825a27d67fb2af150f751dbda360bef.zip |
Create a GCHandleTable interface with Init/Shutdown.
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/ceemain.cpp | 31 | ||||
-rw-r--r-- | src/vm/gcheaputilities.cpp | 2 | ||||
-rw-r--r-- | src/vm/gcheaputilities.h | 10 |
3 files changed, 29 insertions, 14 deletions
diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp index c07b24e4ec..602ccc92bd 100644 --- a/src/vm/ceemain.cpp +++ b/src/vm/ceemain.cpp @@ -862,11 +862,14 @@ void EEStartupHelper(COINITIEE fFlags) #ifndef CROSSGEN_COMPILE + InitializeGarbageCollector(); + // Initialize remoting - // weak_short, weak_long, strong; no pin - if (!Ref_Initialize()) + if (!GCHeapUtilities::GetGCHandleTable()->Initialize()) + { IfFailGo(E_OUTOFMEMORY); + } // Initialize contexts Context::Initialize(); @@ -874,8 +877,6 @@ void EEStartupHelper(COINITIEE fFlags) g_pEEShutDownEvent = new CLREvent(); g_pEEShutDownEvent->CreateManualEvent(FALSE); - - #ifdef FEATURE_IPCMAN // Initialize CCLRSecurityAttributeManager CCLRSecurityAttributeManager::ProcessInit(); @@ -885,7 +886,6 @@ void EEStartupHelper(COINITIEE fFlags) GCInterface::m_MemoryPressureLock.Init(CrstGCMemoryPressure); - #endif // CROSSGEN_COMPILE // Setup the domains. Threads are started in a default domain. @@ -908,9 +908,6 @@ void EEStartupHelper(COINITIEE fFlags) // creation requires AppDomains to have been set up. FinalizerThread::FinalizerThreadCreate(); - // Now we really have fully initialized the garbage collector - SetGarbageCollectorFullyInitialized(); - #ifndef FEATURE_PAL // Watson initialization must precede InitializeDebugger() and InstallUnhandledExceptionFilter() // because on CoreCLR when Waston is enabled, debugging service needs to be enabled and UEF will be used. @@ -1014,7 +1011,14 @@ void EEStartupHelper(COINITIEE fFlags) } #endif - InitializeGarbageCollector(); + // This isn't done as part of InitializeGarbageCollector() above because it + // requires write barriers to have been set up on x86, which happens as part + // of InitJITHelpers1. + hr = g_pGCHeap->Initialize(); + IfFailGo(hr); + + // Now we really have fully initialized the garbage collector + SetGarbageCollectorFullyInitialized(); InitializePinHandleTable(); @@ -1852,7 +1856,7 @@ part2: #ifdef SHOULD_WE_CLEANUP if (!g_fFastExitProcess) { - Ref_Shutdown(); // shut down the handle table + GCHeapUtilities::GetGCHandleTable()->Shutdown(); } #endif /* SHOULD_WE_CLEANUP */ @@ -2455,15 +2459,17 @@ void InitializeGarbageCollector() IGCToCLR* gcToClr = nullptr; #endif + IGCHandleTable *pGcHandleTable; IGCHeap *pGCHeap; - if (!InitializeGarbageCollector(gcToClr, &pGCHeap, &g_gc_dac_vars)) + if (!InitializeGarbageCollector(gcToClr, &pGCHeap, &pGcHandleTable, &g_gc_dac_vars)) { ThrowOutOfMemory(); } assert(pGCHeap != nullptr); g_pGCHeap = pGCHeap; + g_pGCHandleTable = pGcHandleTable; g_gcDacGlobals = &g_gc_dac_vars; // Apparently the Windows linker removes global variables if they are never @@ -2471,9 +2477,6 @@ void InitializeGarbageCollector() // only the DAC will read from it. This forces the linker to include // g_gcDacGlobals. volatile void* _dummy = g_gcDacGlobals; - - hr = pGCHeap->Initialize(); - IfFailThrow(hr); } /*****************************************************************************/ diff --git a/src/vm/gcheaputilities.cpp b/src/vm/gcheaputilities.cpp index b260c3d8f4..aa90341159 100644 --- a/src/vm/gcheaputilities.cpp +++ b/src/vm/gcheaputilities.cpp @@ -22,6 +22,8 @@ uint32_t* g_card_bundle_table = nullptr; // This is the global GC heap, maintained by the VM. GPTR_IMPL(IGCHeap, g_pGCHeap); +IGCHandleTable* g_pGCHandleTable = nullptr; + GcDacVars g_gc_dac_vars; GPTR_IMPL(GcDacVars, g_gcDacGlobals); diff --git a/src/vm/gcheaputilities.h b/src/vm/gcheaputilities.h index 0680763e76..1e920127fe 100644 --- a/src/vm/gcheaputilities.h +++ b/src/vm/gcheaputilities.h @@ -26,6 +26,7 @@ GPTR_DECL(uint32_t,g_card_table); // GC will update it when it needs to. extern "C" gc_alloc_context g_global_alloc_context; +extern "C" IGCHandleTable* g_pGCHandleTable; extern "C" uint32_t* g_card_bundle_table; extern "C" uint8_t* g_ephemeral_low; extern "C" uint8_t* g_ephemeral_high; @@ -71,6 +72,15 @@ public: return g_pGCHeap; } + // Retrieves the GC handle table. + static IGCHandleTable* GetGCHandleTable() + { + LIMITED_METHOD_CONTRACT; + + assert(g_pGCHandleTable != nullptr); + return g_pGCHandleTable; + } + // Returns true if the heap has been initialized, false otherwise. inline static bool IsGCHeapInitialized() { |