diff --git a/src/coreclr/nativeaot/Runtime/RuntimeInstance.cpp b/src/coreclr/nativeaot/Runtime/RuntimeInstance.cpp index e53a16993eb82..26a8909fdbb34 100644 --- a/src/coreclr/nativeaot/Runtime/RuntimeInstance.cpp +++ b/src/coreclr/nativeaot/Runtime/RuntimeInstance.cpp @@ -149,14 +149,6 @@ PTR_RuntimeInstance GetRuntimeInstance() return g_pTheRuntimeInstance; } -void RuntimeInstance::EnumAllStaticGCRefs(void * pfnCallback, void * pvCallbackData) -{ - for (TypeManagerList::Iterator iter = m_TypeManagerList.Begin(); iter != m_TypeManagerList.End(); iter++) - { - iter->m_pTypeManager->EnumStaticGCRefs(pfnCallback, pvCallbackData); - } -} - RuntimeInstance::OsModuleList* RuntimeInstance::GetOsModuleList() { return dac_cast(dac_cast(this) + offsetof(RuntimeInstance, m_OsModuleList)); diff --git a/src/coreclr/nativeaot/Runtime/RuntimeInstance.h b/src/coreclr/nativeaot/Runtime/RuntimeInstance.h index 245b5dc6278c3..86a0e56c32700 100644 --- a/src/coreclr/nativeaot/Runtime/RuntimeInstance.h +++ b/src/coreclr/nativeaot/Runtime/RuntimeInstance.h @@ -7,8 +7,6 @@ class ThreadStore; typedef DPTR(ThreadStore) PTR_ThreadStore; class ICodeManager; -struct StaticGcDesc; -typedef SPTR(StaticGcDesc) PTR_StaticGcDesc; class TypeManager; enum GenericVarianceType : uint8_t; @@ -109,8 +107,6 @@ class RuntimeInstance static bool Initialize(HANDLE hPalInstance); void Destroy(); - void EnumAllStaticGCRefs(void * pfnCallback, void * pvCallbackData); - bool ShouldHijackCallsiteForGcStress(uintptr_t CallsiteIP); bool ShouldHijackLoopForGcStress(uintptr_t CallsiteIP); }; diff --git a/src/coreclr/nativeaot/Runtime/TypeManager.cpp b/src/coreclr/nativeaot/Runtime/TypeManager.cpp index b57b8639bb53d..36cf419907cd9 100644 --- a/src/coreclr/nativeaot/Runtime/TypeManager.cpp +++ b/src/coreclr/nativeaot/Runtime/TypeManager.cpp @@ -45,10 +45,7 @@ TypeManager::TypeManager(HANDLE osModule, ReadyToRunHeader * pHeader, void** pCl { int length; m_pStaticsGCDataSection = (uint8_t*)GetModuleSection(ReadyToRunSectionType::GCStaticRegion, &length); - m_pStaticsGCInfo = (StaticGcDesc*)GetModuleSection(ReadyToRunSectionType::GCStaticDesc, &length); m_pThreadStaticsDataSection = (uint8_t*)GetModuleSection(ReadyToRunSectionType::ThreadStaticRegion, &length); - m_pThreadStaticsGCInfo = (StaticGcDesc*)GetModuleSection(ReadyToRunSectionType::ThreadStaticGCDescRegion, &length); - m_pTlsIndex = (uint32_t*)GetModuleSection(ReadyToRunSectionType::ThreadStaticIndex, &length); m_pDispatchMapTable = (DispatchMap **)GetModuleSection(ReadyToRunSectionType::InterfaceDispatchTable, &length); } @@ -100,65 +97,6 @@ int TypeManager::ModuleInfoRow::GetLength() } } -void TypeManager::EnumStaticGCRefsBlock(void * pfnCallback, void * pvCallbackData, StaticGcDesc* pStaticGcInfo) -{ - if (pStaticGcInfo == NULL) - return; - - for (uint32_t idxSeries = 0; idxSeries < pStaticGcInfo->m_numSeries; idxSeries++) - { - PTR_StaticGcDescGCSeries pSeries = dac_cast(dac_cast(pStaticGcInfo) + - offsetof(StaticGcDesc, m_series) + (idxSeries * sizeof(StaticGcDesc::GCSeries))); - - // The m_startOffset field is really 32-bit relocation (IMAGE_REL_BASED_RELPTR32) to the GC static base of the type - // the GCSeries is describing for. This makes it tolerable to the symbol sorting that the linker conducts. - PTR_RtuObjectRef pRefLocation = dac_cast(dac_cast(&pSeries->m_startOffset) + (int32_t)pSeries->m_startOffset); - uint32_t numObjects = pSeries->m_size; - - RedhawkGCInterface::BulkEnumGcObjRef(pRefLocation, numObjects, pfnCallback, pvCallbackData); - } -} - -void TypeManager::EnumThreadStaticGCRefsBlock(void * pfnCallback, void * pvCallbackData, StaticGcDesc* pStaticGcInfo, uint8_t* pbThreadStaticData) -{ - if (pStaticGcInfo == NULL) - return; - - for (uint32_t idxSeries = 0; idxSeries < pStaticGcInfo->m_numSeries; idxSeries++) - { - PTR_StaticGcDescGCSeries pSeries = dac_cast(dac_cast(pStaticGcInfo) + - offsetof(StaticGcDesc, m_series) + (idxSeries * sizeof(StaticGcDesc::GCSeries))); - - // The m_startOffset field is really a 32-bit relocation (IMAGE_REL_SECREL) to the TLS section. - uint8_t* pTlsObject = pbThreadStaticData + pSeries->m_startOffset; - PTR_RtuObjectRef pRefLocation = dac_cast(pTlsObject); - uint32_t numObjects = pSeries->m_size; - - RedhawkGCInterface::BulkEnumGcObjRef(pRefLocation, numObjects, pfnCallback, pvCallbackData); - } -} - -void TypeManager::EnumStaticGCRefs(void * pfnCallback, void * pvCallbackData) -{ - // Regular statics. - EnumStaticGCRefsBlock(pfnCallback, pvCallbackData, m_pStaticsGCInfo); - - // Thread local statics. - if (m_pThreadStaticsGCInfo != NULL) - { - FOREACH_THREAD(pThread) - { - // To calculate the address of the data for each thread's TLS fields we need two values: - // 1) The TLS slot index allocated for this module by the OS loader. We keep a pointer to this - // value in the module header. - // 2) The offset into the TLS block at which managed data begins. - EnumThreadStaticGCRefsBlock(pfnCallback, pvCallbackData, m_pThreadStaticsGCInfo, - dac_cast(pThread->GetThreadLocalStorage(*m_pTlsIndex, 0))); - } - END_FOREACH_THREAD - } -} - HANDLE TypeManager::GetOsModuleHandle() { return m_osModule; diff --git a/src/coreclr/nativeaot/Runtime/TypeManager.h b/src/coreclr/nativeaot/Runtime/TypeManager.h index 4dbce218b8714..84d1ead3de344 100644 --- a/src/coreclr/nativeaot/Runtime/TypeManager.h +++ b/src/coreclr/nativeaot/Runtime/TypeManager.h @@ -4,7 +4,6 @@ #include "ModuleHeaders.h" #include "ICodeManager.h" -struct StaticGcDesc; class DispatchMap; class TypeManager @@ -13,11 +12,8 @@ class TypeManager HANDLE m_osModule; ReadyToRunHeader * m_pHeader; DispatchMap** m_pDispatchMapTable; - StaticGcDesc* m_pStaticsGCInfo; - StaticGcDesc* m_pThreadStaticsGCInfo; uint8_t* m_pStaticsGCDataSection; uint8_t* m_pThreadStaticsDataSection; - uint32_t* m_pTlsIndex; // Pointer to TLS index if this module uses thread statics void** m_pClasslibFunctions; uint32_t m_nClasslibFunctions; @@ -26,10 +22,8 @@ class TypeManager public: static TypeManager * Create(HANDLE osModule, void * pModuleHeader, void** pClasslibFunctions, uint32_t nClasslibFunctions); void * GetModuleSection(ReadyToRunSectionType sectionId, int * length); - void EnumStaticGCRefs(void * pfnCallback, void * pvCallbackData); HANDLE GetOsModuleHandle(); void* GetClasslibFunction(ClasslibFunctionId functionId); - uint32_t* GetPointerToTlsIndex() { return m_pTlsIndex; } private: @@ -43,9 +37,6 @@ class TypeManager bool HasEndPointer(); int GetLength(); }; - - void EnumStaticGCRefsBlock(void * pfnCallback, void * pvCallbackData, StaticGcDesc* pStaticGcInfo); - void EnumThreadStaticGCRefsBlock(void * pfnCallback, void * pvCallbackData, StaticGcDesc* pStaticGcInfo, uint8_t* pbThreadStaticData); }; // TypeManagerHandle represents an AOT module in MRT based runtimes. diff --git a/src/coreclr/nativeaot/Runtime/gcrhenv.cpp b/src/coreclr/nativeaot/Runtime/gcrhenv.cpp index 8119fd42ffa5e..85f82f0ed1538 100644 --- a/src/coreclr/nativeaot/Runtime/gcrhenv.cpp +++ b/src/coreclr/nativeaot/Runtime/gcrhenv.cpp @@ -681,16 +681,8 @@ void RedhawkGCInterface::ScanStackRoots(Thread *pThread, GcScanRootFunction pfnS // static void RedhawkGCInterface::ScanStaticRoots(GcScanRootFunction pfnScanCallback, void *pContext) { -#ifndef DACCESS_COMPILE - ScanRootsContext sContext; - sContext.m_pfnCallback = pfnScanCallback; - sContext.m_pContext = pContext; - - GetRuntimeInstance()->EnumAllStaticGCRefs(reinterpret_cast(ScanRootsCallbackWrapper), &sContext); -#else UNREFERENCED_PARAMETER(pfnScanCallback); UNREFERENCED_PARAMETER(pContext); -#endif // !DACCESS_COMPILE } // Enumerate all the object roots located in handle tables. It is only safe to call this from the context of a diff --git a/src/coreclr/nativeaot/Runtime/gcrhscan.cpp b/src/coreclr/nativeaot/Runtime/gcrhscan.cpp index 3f7e7a7d52505..d98e24256855a 100644 --- a/src/coreclr/nativeaot/Runtime/gcrhscan.cpp +++ b/src/coreclr/nativeaot/Runtime/gcrhscan.cpp @@ -30,11 +30,6 @@ void GcEnumObjectsConservatively(PTR_PTR_Object ppLowerBound, PTR_PTR_Object ppUpperBound, EnumGcRefCallbackFunc * fnGcEnumRef, EnumGcRefScanContext * pSc); -void EnumAllStaticGCRefs(EnumGcRefCallbackFunc * fn, EnumGcRefScanContext * sc) -{ - GetRuntimeInstance()->EnumAllStaticGCRefs(reinterpret_cast(fn), sc); -} - /* * Scan all stack and statics roots */ @@ -75,14 +70,6 @@ void GCToEEInterface::GcScanRoots(EnumGcRefCallbackFunc * fn, int condemned, in END_FOREACH_THREAD sc->thread_under_crawl = NULL; - - if ((!GCHeapUtilities::IsServerHeap() || sc->thread_number == 0) ||(condemned == max_gen && sc->promotion)) - { -#if defined(FEATURE_EVENT_TRACE) && !defined(DACCESS_COMPILE) - sc->dwEtwRootKind = kEtwGCRootKindHandle; -#endif - EnumAllStaticGCRefs(fn, sc); - } } void GCToEEInterface::GcEnumAllocContexts (enum_alloc_context_func* fn, void* param) diff --git a/src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h b/src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h index a16086d1cc36d..1c22d33890d5c 100644 --- a/src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h +++ b/src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h @@ -46,10 +46,10 @@ enum class ReadyToRunSectionType TypeManagerIndirection = 204, EagerCctor = 205, FrozenObjectRegion = 206, - GCStaticDesc = 207, + // 207 is unused - it was used by GCStaticDesc ThreadStaticOffsetRegion = 208, - ThreadStaticGCDescRegion = 209, - ThreadStaticIndex = 210, + // 209 is unused - it was used by ThreadStaticGCDescRegion + // 210 is unused - it was used by ThreadStaticIndex // 211 is unused - it was used by LoopHijackFlag ImportAddressTables = 212, diff --git a/src/coreclr/nativeaot/Runtime/inc/TargetPtrs.h b/src/coreclr/nativeaot/Runtime/inc/TargetPtrs.h index f581705c85db7..e4778f94db18f 100644 --- a/src/coreclr/nativeaot/Runtime/inc/TargetPtrs.h +++ b/src/coreclr/nativeaot/Runtime/inc/TargetPtrs.h @@ -4,7 +4,6 @@ #define _TARGETPTRS_H_ typedef DPTR(class MethodTable) PTR_EEType; -typedef SPTR(struct StaticGcDesc) PTR_StaticGcDesc; #ifdef TARGET_AMD64 typedef uint64_t UIntTarget; @@ -26,6 +25,5 @@ typedef void * TgtPTR_Void; typedef PTR_EEType TgtPTR_EEType; typedef class Thread * TgtPTR_Thread; typedef struct CORINFO_Object * TgtPTR_CORINFO_Object; -typedef PTR_StaticGcDesc TgtPTR_StaticGcDesc; #endif // !_TARGETPTRS_H_ diff --git a/src/coreclr/nativeaot/Runtime/inc/rhbinder.h b/src/coreclr/nativeaot/Runtime/inc/rhbinder.h index 1cedebde0d10a..9d5e676efe1fe 100644 --- a/src/coreclr/nativeaot/Runtime/inc/rhbinder.h +++ b/src/coreclr/nativeaot/Runtime/inc/rhbinder.h @@ -8,104 +8,6 @@ // #include "TargetPtrs.h" -class GcPollInfo -{ -public: - static const uint32_t indirCellsPerBitmapBit = 64 / POINTER_SIZE; // one cache line per bit - - static const uint32_t cbChunkCommonCode_X64 = 17; - static const uint32_t cbChunkCommonCode_X86 = 16; - static const uint32_t cbChunkCommonCode_ARM = 32; -#ifdef TARGET_ARM - // on ARM, the index of the indirection cell can be computed - // from the pointer to the indirection cell left in R12, - // thus we need only one entry point on ARM, - // thus entries take no space, and you can have as many as you want - static const uint32_t cbEntry = 0; - static const uint32_t cbBundleCommonCode = 0; - static const uint32_t entriesPerBundle = 0x7fffffff; - static const uint32_t bundlesPerChunk = 0x7fffffff; - static const uint32_t entriesPerChunk = 0x7fffffff; -#else - static const uint32_t cbEntry = 4; // push imm8 / jmp rel8 - static const uint32_t cbBundleCommonCode = 5; // jmp rel32 - - static const uint32_t entriesPerSubBundlePos = 32; // for the half with forward jumps - static const uint32_t entriesPerSubBundleNeg = 30; // for the half with negative jumps - static const uint32_t entriesPerBundle = entriesPerSubBundlePos + entriesPerSubBundleNeg; - static const uint32_t bundlesPerChunk = 4; - static const uint32_t entriesPerChunk = bundlesPerChunk * entriesPerBundle; -#endif - - static const uint32_t cbFullBundle = cbBundleCommonCode + - (entriesPerBundle * cbEntry); - - static uint32_t EntryIndexToStubOffset(uint32_t entryIndex) - { -# if defined(TARGET_ARM) - return EntryIndexToStubOffset(entryIndex, cbChunkCommonCode_ARM); -# elif defined(TARGET_AMD64) - return EntryIndexToStubOffset(entryIndex, cbChunkCommonCode_X64); -# else - return EntryIndexToStubOffset(entryIndex, cbChunkCommonCode_X86); -# endif - } - - static uint32_t EntryIndexToStubOffset(uint32_t entryIndex, uint32_t cbChunkCommonCode) - { -# if defined(TARGET_ARM) - UNREFERENCED_PARAMETER(entryIndex); - UNREFERENCED_PARAMETER(cbChunkCommonCode); - - return 0; -# else - uint32_t cbFullChunk = cbChunkCommonCode + - (bundlesPerChunk * cbBundleCommonCode) + - (entriesPerChunk * cbEntry); - - uint32_t numFullChunks = entryIndex / entriesPerChunk; - uint32_t numEntriesInLastChunk = entryIndex - (numFullChunks * entriesPerChunk); - - uint32_t numFullBundles = numEntriesInLastChunk / entriesPerBundle; - uint32_t numEntriesInLastBundle = numEntriesInLastChunk - (numFullBundles * entriesPerBundle); - - uint32_t offset = (numFullChunks * cbFullChunk) + - cbChunkCommonCode + - (numFullBundles * cbFullBundle) + - (numEntriesInLastBundle * cbEntry); - - if (numEntriesInLastBundle >= entriesPerSubBundlePos) - offset += cbBundleCommonCode; - - return offset; -# endif - } -}; - -struct StaticGcDesc -{ - struct GCSeries - { - uint32_t m_size; - uint32_t m_startOffset; - }; - - uint32_t m_numSeries; - GCSeries m_series[1]; - - uint32_t GetSize() - { - return (uint32_t)(offsetof(StaticGcDesc, m_series) + (m_numSeries * sizeof(GCSeries))); - } - -#ifdef DACCESS_COMPILE - static uint32_t DacSize(TADDR addr); -#endif -}; - -typedef SPTR(StaticGcDesc) PTR_StaticGcDesc; -typedef DPTR(StaticGcDesc::GCSeries) PTR_StaticGcDescGCSeries; - class MethodTable; #ifdef FEATURE_CACHED_INTERFACE_DISPATCH diff --git a/src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs b/src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs index d9671ef058ae1..ab9029c056d5f 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs @@ -78,10 +78,10 @@ public enum ReadyToRunSectionType TypeManagerIndirection = 204, EagerCctor = 205, FrozenObjectRegion = 206, - GCStaticDesc = 207, + // 207 is unused - it was used by GCStaticDesc ThreadStaticOffsetRegion = 208, - ThreadStaticGCDescRegion = 209, - ThreadStaticIndex = 210, + // 209 is unused - it was used by ThreadStaticGCDescRegion + // 210 is unused - it was used by ThreadStaticIndex // 211 is unused - it was used by LoopHijackFlag ImportAddressTables = 212, ModuleInitializerList = 213,