// static bool RedhawkGCInterface::InitializeSubsystems(GCType gcType) { g_pConfig->Construct(); #ifdef FEATURE_ETW MICROSOFT_WINDOWS_REDHAWK_GC_PRIVATE_PROVIDER_Context.IsEnabled = FALSE; MICROSOFT_WINDOWS_REDHAWK_GC_PUBLIC_PROVIDER_Context.IsEnabled = FALSE; // Register the Redhawk event provider with the system. RH_ETW_REGISTER_Microsoft_Windows_Redhawk_GC_Private(); RH_ETW_REGISTER_Microsoft_Windows_Redhawk_GC_Public(); MICROSOFT_WINDOWS_REDHAWK_GC_PRIVATE_PROVIDER_Context.RegistrationHandle = Microsoft_Windows_Redhawk_GC_PrivateHandle; MICROSOFT_WINDOWS_REDHAWK_GC_PUBLIC_PROVIDER_Context.RegistrationHandle = Microsoft_Windows_Redhawk_GC_PublicHandle; #endif // FEATURE_ETW if (!InitializeSystemInfo()) { return false; } // Initialize the special EEType used to mark free list entries in the GC heap. g_FreeObjectEEType.InitializeAsGcFreeType(); // Place the pointer to this type in a global cell (typed as the structurally equivalent MethodTable // that the GC understands). g_pFreeObjectMethodTable = (MethodTable *)&g_FreeObjectEEType; g_pFreeObjectEEType = &g_FreeObjectEEType; if (!g_SuspendEELock.InitNoThrow(CrstSuspendEE)) return false; // Set the GC heap type. bool fUseServerGC = (gcType == GCType_Server); GCHeap::InitializeHeapType(fUseServerGC); // Create the GC heap itself. GCHeap *pGCHeap = GCHeap::CreateGCHeap(); if (!pGCHeap) return false; // Initialize the GC subsystem. HRESULT hr = pGCHeap->Initialize(); if (FAILED(hr)) return false; if (!FinalizerThread::Initialize()) return false; // Initialize HandleTable. if (!Ref_Initialize()) return false; return true; }
// One time initialization of interface dispatch. bool InitializeInterfaceDispatch() { g_pAllocHeap = new AllocHeap(); if (g_pAllocHeap == NULL) return false; if (!g_pAllocHeap->Init()) return false; g_sListLock.Init(CrstInterfaceDispatchGlobalLists, CRST_DEFAULT); return true; }
static bool InitDLL(HANDLE hPalInstance) { CheckForPalFallback(); #ifdef FEATURE_CACHED_INTERFACE_DISPATCH // // Initialize interface dispatch. // if (!InitializeInterfaceDispatch()) return false; #endif // // Initialize support for registering GC and HandleTable callouts. // if (!RestrictedCallouts::Initialize()) return false; #if !defined(APP_LOCAL_RUNTIME) && !defined(USE_PORTABLE_HELPERS) #ifndef PLATFORM_UNIX PalAddVectoredExceptionHandler(1, RhpVectoredExceptionHandler); #else PalSetHardwareExceptionHandler(RhpHardwareExceptionHandler); #endif #endif // !APP_LOCAL_RUNTIME && !USE_PORTABLE_HELPERS // // init per-instance state // if (!RuntimeInstance::Initialize(hPalInstance)) return false; STARTUP_TIMELINE_EVENT(NONGC_INIT_COMPLETE); RedhawkGCInterface::GCType gcType = g_pRhConfig->GetUseServerGC() ? RedhawkGCInterface::GCType_Server : RedhawkGCInterface::GCType_Workstation; if (!RedhawkGCInterface::InitializeSubsystems(gcType)) return false; STARTUP_TIMELINE_EVENT(GC_INIT_COMPLETE); #ifdef STRESS_LOG UInt32 dwTotalStressLogSize = g_pRhConfig->GetTotalStressLogSize(); UInt32 dwStressLogLevel = g_pRhConfig->GetStressLogLevel(); unsigned facility = (unsigned)LF_ALL; unsigned dwPerThreadChunks = (dwTotalStressLogSize / 24) / STRESSLOG_CHUNK_SIZE; if (dwTotalStressLogSize != 0) { StressLog::Initialize(facility, dwStressLogLevel, dwPerThreadChunks * STRESSLOG_CHUNK_SIZE, (unsigned)dwTotalStressLogSize, hPalInstance); } #endif // STRESS_LOG DetectCPUFeatures(); if (!g_CastCacheLock.InitNoThrow(CrstType::CrstCastCache)) return false; if (!g_ThunkPoolLock.InitNoThrow(CrstType::CrstCastCache)) return false; return true; }
bool InitDLL(HANDLE hPalInstance) { CheckForPalFallback(); #ifdef FEATURE_CACHED_INTERFACE_DISPATCH // // Initialize interface dispatch. // if (!InitializeInterfaceDispatch()) return false; #endif // // Initialize support for registering GC and HandleTable callouts. // if (!RestrictedCallouts::Initialize()) return false; #ifndef APP_LOCAL_RUNTIME #ifndef PLATFORM_UNIX PalAddVectoredExceptionHandler(1, RhpVectoredExceptionHandler); #else PalSetHardwareExceptionHandler(RhpHardwareExceptionHandler); #endif #endif // // init per-instance state // HANDLE hRuntimeInstance = RtuCreateRuntimeInstance(hPalInstance); if (NULL == hRuntimeInstance) return false; STARTUP_TIMELINE_EVENT(NONGC_INIT_COMPLETE); // @TODO: currently we're always forcing a workstation GC. // @TODO: GC per-instance vs per-DLL state separation if (!RedhawkGCInterface::InitializeSubsystems(RedhawkGCInterface::GCType_Workstation)) return false; STARTUP_TIMELINE_EVENT(GC_INIT_COMPLETE); #ifdef STRESS_LOG UInt32 dwTotalStressLogSize = g_pRhConfig->GetTotalStressLogSize(); UInt32 dwStressLogLevel = g_pRhConfig->GetStressLogLevel(); unsigned facility = (unsigned)LF_ALL; unsigned dwPerThreadChunks = (dwTotalStressLogSize / 24) / STRESSLOG_CHUNK_SIZE; if (dwTotalStressLogSize != 0) { StressLog::Initialize(facility, dwStressLogLevel, dwPerThreadChunks * STRESSLOG_CHUNK_SIZE, (unsigned)dwTotalStressLogSize, hPalInstance); } #endif // STRESS_LOG DetectCPUFeatures(); if (!g_CastCacheLock.InitNoThrow(CrstType::CrstCastCache)) return false; return true; }