Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete .NET Native leftovers #71474

Merged
merged 3 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/coreclr/nativeaot/Runtime/RuntimeInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DPTR(OsModuleList)>(dac_cast<TADDR>(this) + offsetof(RuntimeInstance, m_OsModuleList));
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/nativeaot/Runtime/RuntimeInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
};
Expand Down
62 changes: 0 additions & 62 deletions src/coreclr/nativeaot/Runtime/TypeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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<PTR_StaticGcDescGCSeries>(dac_cast<TADDR>(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<PTR_RtuObjectRef>(dac_cast<PTR_UInt8>(&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<PTR_StaticGcDescGCSeries>(dac_cast<TADDR>(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<PTR_RtuObjectRef>(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<uint8_t*>(pThread->GetThreadLocalStorage(*m_pTlsIndex, 0)));
}
END_FOREACH_THREAD
}
}

HANDLE TypeManager::GetOsModuleHandle()
{
return m_osModule;
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/nativeaot/Runtime/TypeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "ModuleHeaders.h"
#include "ICodeManager.h"

struct StaticGcDesc;
class DispatchMap;

class TypeManager
Expand All @@ -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;

Expand All @@ -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:

Expand All @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/nativeaot/Runtime/gcrhenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*>(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
Expand Down
13 changes: 0 additions & 13 deletions src/coreclr/nativeaot/Runtime/gcrhscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*>(fn), sc);
}

/*
* Scan all stack and statics roots
*/
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/nativeaot/Runtime/inc/TargetPtrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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_
24 changes: 0 additions & 24 deletions src/coreclr/nativeaot/Runtime/inc/rhbinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,6 @@ class GcPollInfo
}
};

MichalStrehovsky marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down