diff options
author | David Wrighton <davidwr@microsoft.com> | 2019-05-15 18:28:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-15 18:28:42 -0700 |
commit | bdb995987178231ba541f22143cb3cab56309daa (patch) | |
tree | 655d0d0bfaee70a56c5a2b33e52fc27965314049 /src/vm | |
parent | c2533b6c3f715b6964de5ffe0b2a2feaac42b079 (diff) | |
download | coreclr-bdb995987178231ba541f22143cb3cab56309daa.tar.gz coreclr-bdb995987178231ba541f22143cb3cab56309daa.tar.bz2 coreclr-bdb995987178231ba541f22143cb3cab56309daa.zip |
Remove concept of AppDomains from the GC (#24536)
* Remove concept of AppDomains from the GC
- Leave constructs allowing for multiple handle tables, as scenarios for that have been proposed
- Remove FEATURE_APPDOMAIN_RESOURCE_MONITORING
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/appdomain.cpp | 174 | ||||
-rw-r--r-- | src/vm/appdomain.hpp | 126 | ||||
-rw-r--r-- | src/vm/eeconfig.cpp | 5 | ||||
-rw-r--r-- | src/vm/eepolicy.cpp | 1 | ||||
-rw-r--r-- | src/vm/eventtrace.cpp | 17 | ||||
-rw-r--r-- | src/vm/frames.cpp | 4 | ||||
-rw-r--r-- | src/vm/gcenv.ee.common.cpp | 9 | ||||
-rw-r--r-- | src/vm/gcenv.ee.cpp | 44 | ||||
-rw-r--r-- | src/vm/gcenv.ee.h | 6 | ||||
-rw-r--r-- | src/vm/gcenv.h | 18 | ||||
-rw-r--r-- | src/vm/gctoclreventsink.cpp | 8 | ||||
-rw-r--r-- | src/vm/gctoclreventsink.h | 4 | ||||
-rw-r--r-- | src/vm/siginfo.cpp | 6 | ||||
-rw-r--r-- | src/vm/threads.cpp | 84 | ||||
-rw-r--r-- | src/vm/threads.h | 11 | ||||
-rw-r--r-- | src/vm/util.cpp | 43 | ||||
-rw-r--r-- | src/vm/util.hpp | 5 | ||||
-rw-r--r-- | src/vm/vars.cpp | 2 | ||||
-rw-r--r-- | src/vm/vars.hpp | 1 |
19 files changed, 13 insertions, 555 deletions
diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index ed6d05fc87..2d92d3f952 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -115,10 +115,6 @@ GlobalStringLiteralMap* SystemDomain::m_pGlobalStringLiteralMap = NULL; DECLSPEC_ALIGN(16) static BYTE g_pSystemDomainMemory[sizeof(SystemDomain)]; -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING -size_t SystemDomain::m_totalSurvivedBytes = 0; -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - CrstStatic SystemDomain::m_SystemDomainCrst; CrstStatic SystemDomain::m_DelayedUnloadCrst; @@ -1949,12 +1945,6 @@ void SystemDomain::LazyInitGlobalStringLiteralMap() AppDomain* pAppDomain = ::GetAppDomain(); if (pAppDomain && pAppDomain->IsActive()) { -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - if (g_fEnableARM) - { - sc->pCurrentDomain = pAppDomain; - } -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING pAppDomain->EnumStaticGCRefs(fn, sc); } } @@ -1962,83 +1952,6 @@ void SystemDomain::LazyInitGlobalStringLiteralMap() RETURN; } -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING -void SystemDomain::ResetADSurvivedBytes() -{ - CONTRACT_VOID - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACT_END; - - _ASSERTE(GCHeapUtilities::IsGCInProgress()); - - SystemDomain* sysDomain = SystemDomain::System(); - if (sysDomain) - { - AppDomain* pAppDomain = ::GetAppDomain(); - if (pAppDomain && pAppDomain->IsUserActive()) - { - pAppDomain->ResetSurvivedBytes(); - } - } - - RETURN; -} - -ULONGLONG SystemDomain::GetADSurvivedBytes() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - SystemDomain* sysDomain = SystemDomain::System(); - ULONGLONG ullTotalADSurvived = 0; - if (sysDomain) - { - AppDomain* pAppDomain = ::GetAppDomain(); - if (pAppDomain && pAppDomain->IsUserActive()) - { - ULONGLONG ullSurvived = pAppDomain->GetSurvivedBytes(); - ullTotalADSurvived += ullSurvived; - } - } - - return ullTotalADSurvived; -} - -void SystemDomain::RecordTotalSurvivedBytes(size_t totalSurvivedBytes) -{ - CONTRACT_VOID - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACT_END; - - m_totalSurvivedBytes = totalSurvivedBytes; - - SystemDomain* sysDomain = SystemDomain::System(); - if (sysDomain) - { - AppDomain* pAppDomain = ::GetAppDomain(); - if (pAppDomain && pAppDomain->IsUserActive()) - { - FireEtwAppDomainMemSurvived((ULONGLONG)pAppDomain, pAppDomain->GetSurvivedBytes(), totalSurvivedBytes, GetClrInstanceId()); - } - } - - RETURN; -} -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - // Only called when EE is suspended. DWORD SystemDomain::GetTotalNumSizedRefHandles() { @@ -2977,12 +2890,6 @@ AppDomain::AppDomain() m_dwCreationHolders=0; #endif -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - m_ullTotalProcessorUsage = 0; - m_pullAllocBytes = NULL; - m_pullSurvivedBytes = NULL; -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - #ifdef FEATURE_TYPEEQUIVALENCE m_pTypeEquivalenceTable = NULL; #endif // FEATURE_TYPEEQUIVALENCE @@ -3080,27 +2987,6 @@ void AppDomain::Init() #ifndef CROSSGEN_COMPILE -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - // NOTE: it's important that we initialize ARM data structures before calling - // IGCHandleManager::CreateHandleStore, this is because AD::Init() can race with GC - // and once we add ourselves to the handle table map the GC can start walking - // our handles and calling AD::RecordSurvivedBytes() which touches ARM data. - if (GCHeapUtilities::IsServerHeap()) - m_dwNumHeaps = CPUGroupInfo::CanEnableGCCPUGroups() ? - CPUGroupInfo::GetNumActiveProcessors() : - GetCurrentProcessCpuCount(); - else - m_dwNumHeaps = 1; - m_pullAllocBytes = new ULONGLONG [m_dwNumHeaps * ARM_CACHE_LINE_SIZE_ULL]; - m_pullSurvivedBytes = new ULONGLONG [m_dwNumHeaps * ARM_CACHE_LINE_SIZE_ULL]; - for (DWORD i = 0; i < m_dwNumHeaps; i++) - { - m_pullAllocBytes[i * ARM_CACHE_LINE_SIZE_ULL] = 0; - m_pullSurvivedBytes[i * ARM_CACHE_LINE_SIZE_ULL] = 0; - } - m_ullLastEtwAllocBytes = 0; -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - // Default domain reuses the handletablemap that was created during EEStartup m_handleStore = GCHandleUtilities::GetGCHandleManager()->GetGlobalHandleStore(); @@ -7070,66 +6956,6 @@ PTR_LoaderAllocator SystemDomain::GetGlobalLoaderAllocator() return PTR_LoaderAllocator(PTR_HOST_MEMBER_TADDR(SystemDomain,System(),m_GlobalAllocator)); } -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - -#ifndef CROSSGEN_COMPILE -// Return the total processor time (user and kernel) used by threads executing in this AppDomain so far. The -// result is in 100ns units. -ULONGLONG AppDomain::QueryProcessorUsage() -{ - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - -#ifndef DACCESS_COMPILE - Thread *pThread = NULL; - - // Need to update our accumulated processor time count with current values from each thread that is - // currently executing in this domain. - - // Take the thread store lock while we enumerate threads. - ThreadStoreLockHolder tsl; - while ((pThread = ThreadStore::GetThreadList(pThread)) != NULL) - { - // Skip unstarted and dead threads and those that are currently executing in a different AppDomain. - if (pThread->IsUnstarted() || pThread->IsDead() || pThread->GetDomain(INDEBUG(TRUE)) != this) - continue; - - // Add the amount of time spent by the thread in the AppDomain since the last time we asked (calling - // Thread::QueryThreadProcessorUsage() will reset the thread's counter). - UpdateProcessorUsage(pThread->QueryThreadProcessorUsage()); - } -#endif // !DACCESS_COMPILE - - // Return the updated total. - return m_ullTotalProcessorUsage; -} - -// Add to the current count of processor time used by threads within this AppDomain. This API is called by -// threads transitioning between AppDomains. -void AppDomain::UpdateProcessorUsage(ULONGLONG ullAdditionalUsage) -{ - LIMITED_METHOD_CONTRACT; - - // Need to be careful to synchronize here, multiple threads could be racing to update this count. - ULONGLONG ullOldValue; - ULONGLONG ullNewValue; - do - { - ullOldValue = m_ullTotalProcessorUsage; - ullNewValue = ullOldValue + ullAdditionalUsage; - } while (InterlockedCompareExchange64((LONGLONG*)&m_ullTotalProcessorUsage, - (LONGLONG)ullNewValue, - (LONGLONG)ullOldValue) != (LONGLONG)ullOldValue); -} -#endif // CROSSGEN_COMPILE - -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING - #if defined(FEATURE_TYPEEQUIVALENCE) #ifndef DACCESS_COMPILE diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp index 5bc45d7943..b2f2269771 100644 --- a/src/vm/appdomain.hpp +++ b/src/vm/appdomain.hpp @@ -2512,103 +2512,6 @@ public: PTR_LoaderHeap GetLowFrequencyHeap(); PTR_LoaderHeap GetHighFrequencyHeap(); -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - #define ARM_ETW_ALLOC_THRESHOLD (4 * 1024 * 1024) - // cache line size in ULONGLONG - 128 bytes which are 16 ULONGLONG's - #define ARM_CACHE_LINE_SIZE_ULL 16 - - inline ULONGLONG GetAllocBytes() - { - LIMITED_METHOD_CONTRACT; - ULONGLONG ullTotalAllocBytes = 0; - - // Ensure that m_pullAllocBytes is non-null to avoid an AV in a race between GC and AD unload. - // A race can occur when a new appdomain is created, but an OOM is thrown when allocating for m_pullAllocBytes, causing the AD unload. - if(NULL != m_pullAllocBytes) - { - for (DWORD i = 0; i < m_dwNumHeaps; i++) - { - ullTotalAllocBytes += m_pullAllocBytes[i * ARM_CACHE_LINE_SIZE_ULL]; - } - } - return ullTotalAllocBytes; - } - - void RecordAllocBytes(size_t allocatedBytes, DWORD dwHeapNumber) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(dwHeapNumber < m_dwNumHeaps); - - // Ensure that m_pullAllocBytes is non-null to avoid an AV in a race between GC and AD unload. - // A race can occur when a new appdomain is created, but an OOM is thrown when allocating for m_pullAllocBytes, causing the AD unload. - if(NULL != m_pullAllocBytes) - { - m_pullAllocBytes[dwHeapNumber * ARM_CACHE_LINE_SIZE_ULL] += allocatedBytes; - } - - ULONGLONG ullTotalAllocBytes = GetAllocBytes(); - - if ((ullTotalAllocBytes - m_ullLastEtwAllocBytes) >= ARM_ETW_ALLOC_THRESHOLD) - { - m_ullLastEtwAllocBytes = ullTotalAllocBytes; - FireEtwAppDomainMemAllocated((ULONGLONG)this, ullTotalAllocBytes, GetClrInstanceId()); - } - } - - inline ULONGLONG GetSurvivedBytes() - { - LIMITED_METHOD_CONTRACT; - ULONGLONG ullTotalSurvivedBytes = 0; - - // Ensure that m_pullSurvivedBytes is non-null to avoid an AV in a race between GC and AD unload. - // A race can occur when a new appdomain is created, but an OOM is thrown when allocating for m_pullSurvivedBytes, causing the AD unload. - if(NULL != m_pullSurvivedBytes) - { - for (DWORD i = 0; i < m_dwNumHeaps; i++) - { - ullTotalSurvivedBytes += m_pullSurvivedBytes[i * ARM_CACHE_LINE_SIZE_ULL]; - } - } - return ullTotalSurvivedBytes; - } - - void RecordSurvivedBytes(size_t promotedBytes, DWORD dwHeapNumber) - { - WRAPPER_NO_CONTRACT; - _ASSERTE(dwHeapNumber < m_dwNumHeaps); - - // Ensure that m_pullSurvivedBytes is non-null to avoid an AV in a race between GC and AD unload. - // A race can occur when a new appdomain is created, but an OOM is thrown when allocating for m_pullSurvivedBytes, causing the AD unload. - if(NULL != m_pullSurvivedBytes) - { - m_pullSurvivedBytes[dwHeapNumber * ARM_CACHE_LINE_SIZE_ULL] += promotedBytes; - } - } - - inline void ResetSurvivedBytes() - { - LIMITED_METHOD_CONTRACT; - - // Ensure that m_pullSurvivedBytes is non-null to avoid an AV in a race between GC and AD unload. - // A race can occur when a new appdomain is created, but an OOM is thrown when allocating for m_pullSurvivedBytes, causing the AD unload. - if(NULL != m_pullSurvivedBytes) - { - for (DWORD i = 0; i < m_dwNumHeaps; i++) - { - m_pullSurvivedBytes[i * ARM_CACHE_LINE_SIZE_ULL] = 0; - } - } - } - - // Return the total processor time (user and kernel) used by threads executing in this AppDomain so far. - // The result is in 100ns units. - ULONGLONG QueryProcessorUsage(); - - // Add to the current count of processor time used by threads within this AppDomain. This API is called by - // threads transitioning between AppDomains. - void UpdateProcessorUsage(ULONGLONG ullAdditionalUsage); -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - private: size_t EstimateSize(); EEClassFactoryInfoHashTable* SetupClassFactHash(); @@ -2749,17 +2652,6 @@ private: // The thread-pool index of this app domain among existing app domains (starting from 1) TPIndex m_tpIndex; -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - ULONGLONG* m_pullAllocBytes; - ULONGLONG* m_pullSurvivedBytes; - DWORD m_dwNumHeaps; - ULONGLONG m_ullLastEtwAllocBytes; - // Total processor time (user and kernel) utilized by threads running in this AppDomain so far. May not - // account for threads currently executing in the AppDomain until a call to QueryProcessorUsage() is - // made. - Volatile<ULONGLONG> m_ullTotalProcessorUsage; -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - Volatile<Stage> m_Stage; ArrayList m_failedAssemblies; @@ -3220,19 +3112,6 @@ public: #endif // DACCESS_COMPILE -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - // The *AD* methods are what we got from tracing through EE roots. - // RecordTotalSurvivedBytes is the total promoted from a GC. - static void ResetADSurvivedBytes(); - static ULONGLONG GetADSurvivedBytes(); - static void RecordTotalSurvivedBytes(size_t totalSurvivedBytes); - static ULONGLONG GetTotalSurvivedBytes() - { - LIMITED_METHOD_CONTRACT; - return m_totalSurvivedBytes; - } -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - //**************************************************************************************** // Routines to deal with the base library (currently mscorlib.dll) LPCWSTR BaseLibrary() @@ -3341,11 +3220,6 @@ private: LoaderAllocator * m_pDelayedUnloadListOfLoaderAllocators; -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - // This is what gets promoted for the whole GC heap. - static size_t m_totalSurvivedBytes; -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - #ifndef DACCESS_COMPILE static CrstStatic m_DelayedUnloadCrst; static CrstStatic m_SystemDomainCrst; diff --git a/src/vm/eeconfig.cpp b/src/vm/eeconfig.cpp index a4b8e1d196..87e7467f23 100644 --- a/src/vm/eeconfig.cpp +++ b/src/vm/eeconfig.cpp @@ -712,11 +712,6 @@ HRESULT EEConfig::sync() iGCLatencyMode = GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_GCLatencyMode, iGCLatencyMode); #endif - if (CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_ARMEnabled)) - { - g_fEnableARM = TRUE; - } - bool gcConcurrentWasForced = false; // The CLRConfig value for UNSUPPORTED_gcConcurrent defaults to -1, and treats any // positive value as 'forcing' concurrent GC to be on. Because the standard logic diff --git a/src/vm/eepolicy.cpp b/src/vm/eepolicy.cpp index 2da1c70f70..66ec5c6be2 100644 --- a/src/vm/eepolicy.cpp +++ b/src/vm/eepolicy.cpp @@ -1249,7 +1249,6 @@ void EEPolicy::HandleCodeContractFailure(LPCWSTR pMessage, LPCWSTR pCondition, L // GetActionOnFailure will notify the host for us. EPolicyAction action = pPolicy->GetActionOnFailure(FAIL_CodeContract); Thread* pThread = GetThread(); - AppDomain* pCurrentDomain = ::GetAppDomain(); switch(action) { case eThrowException: diff --git a/src/vm/eventtrace.cpp b/src/vm/eventtrace.cpp index a4e7d6ffe4..25f5273a05 100644 --- a/src/vm/eventtrace.cpp +++ b/src/vm/eventtrace.cpp @@ -3844,9 +3844,6 @@ VOID ETW::EnumerationLog::StartRundown() EX_TRY { - BOOL bIsArmRundownEnabled = ETW_TRACING_CATEGORY_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_Context, - TRACE_LEVEL_INFORMATION, - CLR_RUNDOWNAPPDOMAINRESOURCEMANAGEMENT_KEYWORD); BOOL bIsPerfTrackRundownEnabled = ETW_TRACING_CATEGORY_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_RUNDOWN_PROVIDER_Context, TRACE_LEVEL_INFORMATION, CLR_RUNDOWNPERFTRACK_KEYWORD); @@ -3869,8 +3866,6 @@ VOID ETW::EnumerationLog::StartRundown() TRACE_LEVEL_INFORMATION, CLR_RUNDOWNJITTEDMETHODILTONATIVEMAP_KEYWORD) || - bIsArmRundownEnabled - || bIsPerfTrackRundownEnabled || bIsThreadingRundownEnabled) @@ -3909,17 +3904,7 @@ VOID ETW::EnumerationLog::StartRundown() ETW::EnumerationLog::EnumerationHelper(NULL, NULL, enumerationOptions); - if (bIsArmRundownEnabled) - { - // When an ETW event consumer asks for ARM rundown, that not only enables - // the ETW events, but also causes some minor behavioral changes in the - // CLR, such as gathering CPU usage baselines for each thread right now, - // and also gathering resource usage information later on (keyed off of - // g_fEnableARM, which we'll set right now). - EnableARM(); - } - - if (bIsArmRundownEnabled || bIsThreadingRundownEnabled) + if (bIsThreadingRundownEnabled) { SendThreadRundownEvent(); } diff --git a/src/vm/frames.cpp b/src/vm/frames.cpp index 312efe9f3b..8d49702cef 100644 --- a/src/vm/frames.cpp +++ b/src/vm/frames.cpp @@ -1111,7 +1111,7 @@ void HijackFrame::GcScanRoots(promote_func *fn, ScanContext* sc) case RT_ByRef: LOG((LF_GC, INFO3, "Hijack Frame Carefully Promoting pointer" FMT_ADDR "to", DBG_ADDR(OBJECTREF_TO_UNCHECKED_OBJECTREF(*objPtr)))); - PromoteCarefully(fn, objPtr, sc, GC_CALL_INTERIOR | GC_CALL_CHECK_APP_DOMAIN); + PromoteCarefully(fn, objPtr, sc, GC_CALL_INTERIOR); LOG((LF_GC, INFO3, FMT_ADDR "\n", DBG_ADDR(OBJECTREF_TO_UNCHECKED_OBJECTREF(*objPtr)))); break; @@ -1340,7 +1340,7 @@ void TransitionFrame::PromoteCallerStackUsingGCRefMap(promote_func* fn, ScanCont fn(dac_cast<PTR_PTR_Object>(ppObj), sc, CHECK_APP_DOMAIN); break; case GCREFMAP_INTERIOR: - PromoteCarefully(fn, dac_cast<PTR_PTR_Object>(ppObj), sc, GC_CALL_INTERIOR | GC_CALL_CHECK_APP_DOMAIN); + PromoteCarefully(fn, dac_cast<PTR_PTR_Object>(ppObj), sc, GC_CALL_INTERIOR); break; case GCREFMAP_METHOD_PARAM: if (sc->promotion) diff --git a/src/vm/gcenv.ee.common.cpp b/src/vm/gcenv.ee.common.cpp index 6915ec8bda..1411853218 100644 --- a/src/vm/gcenv.ee.common.cpp +++ b/src/vm/gcenv.ee.common.cpp @@ -158,7 +158,7 @@ void GcEnumObject(LPVOID pData, OBJECTREF *pObj, uint32_t flags) // // Sanity check that the flags contain only these three values // - assert((flags & ~(GC_CALL_INTERIOR|GC_CALL_PINNED|GC_CALL_CHECK_APP_DOMAIN)) == 0); + assert((flags & ~(GC_CALL_INTERIOR|GC_CALL_PINNED)) == 0); // for interior pointers, we optimize the case in which // it points into the current threads stack area @@ -205,13 +205,6 @@ StackWalkAction GcStackCrawlCallBack(CrawlFrame* pCF, VOID* pData) GCCONTEXT *gcctx = (GCCONTEXT*) pData; -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - if (g_fEnableARM) - { - gcctx->sc->pCurrentDomain = pCF->GetAppDomain(); - } -#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING - MethodDesc *pMD = pCF->GetFunction(); #ifdef GC_PROFILING diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp index 8e47caee94..ebbc7929a6 100644 --- a/src/vm/gcenv.ee.cpp +++ b/src/vm/gcenv.ee.cpp @@ -1013,15 +1013,6 @@ void GCToEEInterface::HandleFatalError(unsigned int exitCode) EEPOLICY_HANDLE_FATAL_ERROR(exitCode); } -bool GCToEEInterface::ShouldFinalizeObjectForUnload(void* pDomain, Object* obj) -{ - // CoreCLR does not have appdomains, so this code path is dead. Other runtimes may - // choose to inspect the object being finalized here. - // [DESKTOP TODO] Desktop looks for "agile and finalizable" objects and may choose - // to move them to a new app domain instead of finalizing them here. - return true; -} - bool GCToEEInterface::EagerFinalized(Object* obj) { MethodTable* pMT = obj->GetGCSafeMethodTable(); @@ -1486,34 +1477,6 @@ IGCToCLREventSink* GCToEEInterface::EventSink() return &g_gcToClrEventSink; } -uint32_t GCToEEInterface::GetDefaultDomainIndex() -{ - LIMITED_METHOD_CONTRACT; - - return DefaultADID; -} - -void *GCToEEInterface::GetAppDomainAtIndex(uint32_t appDomainIndex) -{ - LIMITED_METHOD_CONTRACT; - - return ::GetAppDomain(); -} - -bool GCToEEInterface::AppDomainCanAccessHandleTable(uint32_t appDomainID) -{ - LIMITED_METHOD_CONTRACT; - - return appDomainID == DefaultADID; -} - -uint32_t GCToEEInterface::GetIndexOfAppDomainBeingUnloaded() -{ - LIMITED_METHOD_CONTRACT; - - return 0xFFFFFFFF; -} - uint32_t GCToEEInterface::GetTotalNumSizedRefHandles() { LIMITED_METHOD_CONTRACT; @@ -1522,13 +1485,6 @@ uint32_t GCToEEInterface::GetTotalNumSizedRefHandles() } -bool GCToEEInterface::AppDomainIsRudeUnload(void *appDomain) -{ - LIMITED_METHOD_CONTRACT; - - return false; -} - bool GCToEEInterface::AnalyzeSurvivorsRequested(int condemnedGeneration) { LIMITED_METHOD_CONTRACT; diff --git a/src/vm/gcenv.ee.h b/src/vm/gcenv.ee.h index 383c0796f6..de6ad5a542 100644 --- a/src/vm/gcenv.ee.h +++ b/src/vm/gcenv.ee.h @@ -62,7 +62,6 @@ public: void EnableFinalization(bool foundFinalizers); void HandleFatalError(unsigned int exitCode); - bool ShouldFinalizeObjectForUnload(void* pDomain, Object* obj); bool EagerFinalized(Object* obj); MethodTable* GetFreeObjectMethodTable(); bool GetBooleanConfigValue(const char* key, bool* value); @@ -76,12 +75,7 @@ public: void WalkAsyncPinned(Object* object, void* context, void(*callback)(Object*, Object*, void*)); IGCToCLREventSink* EventSink(); - uint32_t GetDefaultDomainIndex(); - void *GetAppDomainAtIndex(uint32_t appDomainIndex); - bool AppDomainCanAccessHandleTable(uint32_t appDomainID); - uint32_t GetIndexOfAppDomainBeingUnloaded(); uint32_t GetTotalNumSizedRefHandles(); - bool AppDomainIsRudeUnload(void *appDomain); bool AnalyzeSurvivorsRequested(int condemnedGeneration); void AnalyzeSurvivorsFinished(int condemnedGeneration); diff --git a/src/vm/gcenv.h b/src/vm/gcenv.h index 162c14557e..767adb892c 100644 --- a/src/vm/gcenv.h +++ b/src/vm/gcenv.h @@ -68,22 +68,4 @@ namespace ETW #define _tfopen _wfopen #endif -// ----------------------------------------------------------------------------------------------------------- -// -// AppDomain emulation. We don't have these in the CLR anymore so instead we emulate the bare minimum of the API -// touched by the GC/HandleTable and pretend we have precisely one (default) appdomain. -// - -#define RH_DEFAULT_DOMAIN_ID 1 - -struct ADIndex -{ - DWORD m_dwIndex; - - ADIndex () : m_dwIndex(RH_DEFAULT_DOMAIN_ID) {} - explicit ADIndex (DWORD id) : m_dwIndex(id) {} - BOOL operator==(const ADIndex& ad) const { return m_dwIndex == ad.m_dwIndex; } - BOOL operator!=(const ADIndex& ad) const { return m_dwIndex != ad.m_dwIndex; } -}; - #endif // GCENV_H_ diff --git a/src/vm/gctoclreventsink.cpp b/src/vm/gctoclreventsink.cpp index d95a187c1d..4d64a49555 100644 --- a/src/vm/gctoclreventsink.cpp +++ b/src/vm/gctoclreventsink.cpp @@ -319,14 +319,14 @@ void GCToCLREventSink::FireGCFullNotify_V1(uint32_t genNumber, uint32_t isAlloc) FireEtwGCFullNotify_V1(genNumber, isAlloc, GetClrInstanceId()); } -void GCToCLREventSink::FireSetGCHandle(void *handleID, void *objectID, uint32_t kind, uint32_t generation, uint64_t appDomainID) +void GCToCLREventSink::FireSetGCHandle(void *handleID, void *objectID, uint32_t kind, uint32_t generation) { - FireEtwSetGCHandle(handleID, objectID, kind, generation, appDomainID, GetClrInstanceId()); + FireEtwSetGCHandle(handleID, objectID, kind, generation, (uint64_t)dac_cast<TADDR>(AppDomain::GetCurrentDomain()), GetClrInstanceId()); } -void GCToCLREventSink::FirePrvSetGCHandle(void *handleID, void *objectID, uint32_t kind, uint32_t generation, uint64_t appDomainID) +void GCToCLREventSink::FirePrvSetGCHandle(void *handleID, void *objectID, uint32_t kind, uint32_t generation) { - FireEtwPrvSetGCHandle(handleID, objectID, kind, generation, appDomainID, GetClrInstanceId()); + FireEtwPrvSetGCHandle(handleID, objectID, kind, generation, (uint64_t)dac_cast<TADDR>(AppDomain::GetCurrentDomain()), GetClrInstanceId()); } void GCToCLREventSink::FireDestroyGCHandle(void *handleID) diff --git a/src/vm/gctoclreventsink.h b/src/vm/gctoclreventsink.h index 1e2edfccc2..12f5ae3cc5 100644 --- a/src/vm/gctoclreventsink.h +++ b/src/vm/gctoclreventsink.h @@ -76,8 +76,8 @@ public: void FireBGCAllocWaitBegin(uint32_t reason); void FireBGCAllocWaitEnd(uint32_t reason); void FireGCFullNotify_V1(uint32_t genNumber, uint32_t isAlloc); - void FireSetGCHandle(void *handleID, void *objectID, uint32_t kind, uint32_t generation, uint64_t appDomainID); - void FirePrvSetGCHandle(void *handleID, void *objectID, uint32_t kind, uint32_t generation, uint64_t appDomainID); + void FireSetGCHandle(void *handleID, void *objectID, uint32_t kind, uint32_t generation); + void FirePrvSetGCHandle(void *handleID, void *objectID, uint32_t kind, uint32_t generation); void FireDestroyGCHandle(void *handleID); void FirePrvDestroyGCHandle(void *handleID); }; diff --git a/src/vm/siginfo.cpp b/src/vm/siginfo.cpp index 353abf48cb..0397b5aa8b 100644 --- a/src/vm/siginfo.cpp +++ b/src/vm/siginfo.cpp @@ -4871,7 +4871,7 @@ void PromoteCarefully(promote_func fn, // // Sanity check that the flags contain only these three values // - assert((flags & ~(GC_CALL_INTERIOR|GC_CALL_PINNED|GC_CALL_CHECK_APP_DOMAIN)) == 0); + assert((flags & ~(GC_CALL_INTERIOR|GC_CALL_PINNED)) == 0); // // Sanity check that GC_CALL_INTERIOR FLAG is set @@ -5010,7 +5010,7 @@ VOID MetaSig::GcScanRoots(ArgDestination *pValue, #ifdef _DEBUG pOldLocation = *pArgPtr; #endif - (*fn)(pArgPtr, sc, GC_CALL_CHECK_APP_DOMAIN ); + (*fn)(pArgPtr, sc, 0 ); // !!! Do not cast to (OBJECTREF*) // !!! If we are in the relocate phase, we may have updated root, @@ -5038,7 +5038,7 @@ VOID MetaSig::GcScanRoots(ArgDestination *pValue, pOldLocation = *pArgPtr; #endif - (*fnc)(fn, pArgPtr, sc, GC_CALL_INTERIOR|GC_CALL_CHECK_APP_DOMAIN); + (*fnc)(fn, pArgPtr, sc, GC_CALL_INTERIOR); // !!! Do not cast to (OBJECTREF*) // !!! If we are in the relocate phase, we may have updated root, diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp index 020f318684..07ea78f8a0 100644 --- a/src/vm/threads.cpp +++ b/src/vm/threads.cpp @@ -808,13 +808,6 @@ Thread* SetupThread(BOOL fInternal) FastInterlockOr((ULONG *) &pThread->m_State, Thread::TS_TPWorkerThread); } -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - if (g_fEnableARM) - { - pThread->QueryThreadProcessorUsage(); - } -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING - #ifdef FEATURE_EVENT_TRACE ETW::ThreadLog::FireThreadCreated(pThread); #endif // FEATURE_EVENT_TRACE @@ -865,15 +858,6 @@ void DestroyThread(Thread *th) _ASSERTE(g_fEEShutDown || th->m_dwLockCount == 0 || th->m_fRudeAborted); -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - if (g_fEnableARM) - { - AppDomain* pDomain = th->GetDomain(); - pDomain->UpdateProcessorUsage(th->QueryThreadProcessorUsage()); - FireEtwThreadTerminated((ULONGLONG)th, (ULONGLONG)pDomain, GetClrInstanceId()); - } -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING - th->FinishSOWork(); GCX_PREEMP_NO_DTOR(); @@ -966,14 +950,6 @@ HRESULT Thread::DetachThread(BOOL fDLLThreadDetach) _ASSERTE (this == GetThread()); -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - if (g_fEnableARM && m_pDomain) - { - m_pDomain->UpdateProcessorUsage(QueryThreadProcessorUsage()); - FireEtwThreadTerminated((ULONGLONG)this, (ULONGLONG)m_pDomain, GetClrInstanceId()); - } -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING - FinishSOWork(); FastInterlockIncrement(&Thread::m_DetachCount); @@ -1555,10 +1531,6 @@ Thread::Thread() contextHolder.SuppressRelease(); savedRedirectContextHolder.SuppressRelease(); -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - m_ullProcessorUsageBaseline = 0; -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING - #ifdef FEATURE_COMINTEROP m_uliInitializeSpyCookie.QuadPart = 0ul; m_fInitializeSpyRegistered = false; @@ -1825,12 +1797,6 @@ BOOL Thread::HasStarted(BOOL bRequiresTSL) ThreadStore::TransferStartedThread(this, bRequiresTSL); -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - if (g_fEnableARM) - { - QueryThreadProcessorUsage(); - } -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING #ifdef FEATURE_EVENT_TRACE ETW::ThreadLog::FireThreadCreated(this); #endif // FEATURE_EVENT_TRACE @@ -8918,56 +8884,6 @@ ThreadStore::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) #endif // #ifdef DACCESS_COMPILE - -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING -// For the purposes of tracking resource usage we implement a simple cpu resource usage counter on each -// thread. Every time QueryThreadProcessorUsage() is invoked it returns the amount of cpu time (a combination -// of user and kernel mode time) used since the last call to QueryThreadProcessorUsage(). The result is in 100 -// nanosecond units. -ULONGLONG Thread::QueryThreadProcessorUsage() -{ - LIMITED_METHOD_CONTRACT; - - // Get current values for the amount of kernel and user time used by this thread over its entire lifetime. - FILETIME sCreationTime, sExitTime, sKernelTime, sUserTime; - HANDLE hThread = GetThreadHandle(); - BOOL fResult = GetThreadTimes(hThread, - &sCreationTime, - &sExitTime, - &sKernelTime, - &sUserTime); - if (!fResult) - { -#ifdef _DEBUG - ULONG error = GetLastError(); - printf("GetThreadTimes failed: %d; handle is %p\n", error, hThread); - _ASSERTE(FALSE); -#endif - return 0; - } - - // Combine the user and kernel times into a single value (FILETIME is just a structure representing an - // unsigned int64 in two 32-bit pieces). - _ASSERTE(sizeof(FILETIME) == sizeof(UINT64)); - ULONGLONG ullCurrentUsage = *(ULONGLONG*)&sKernelTime + *(ULONGLONG*)&sUserTime; - - // Store the current processor usage as the new baseline, and retrieve the previous usage. - ULONGLONG ullPreviousUsage = VolatileLoad(&m_ullProcessorUsageBaseline); - if (ullPreviousUsage >= ullCurrentUsage || - ullPreviousUsage != (ULONGLONG)InterlockedCompareExchange64( - (LONGLONG*)&m_ullProcessorUsageBaseline, - (LONGLONG)ullCurrentUsage, - (LONGLONG)ullPreviousUsage)) - { - // another thread beat us to it, and already reported this usage. - return 0; - } - - // The result is the difference between this value and the previous usage value. - return ullCurrentUsage - ullPreviousUsage; -} -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING - OBJECTHANDLE Thread::GetOrCreateDeserializationTracker() { CONTRACTL diff --git a/src/vm/threads.h b/src/vm/threads.h index 68a66c3284..6b7fe45368 100644 --- a/src/vm/threads.h +++ b/src/vm/threads.h @@ -4835,18 +4835,8 @@ public: // Holds per-thread information the debugger uses to expose locking information // See ThreadDebugBlockingInfo.h for more details ThreadDebugBlockingInfo DebugBlockingInfo; -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - // For the purposes of tracking resource usage we implement a simple cpu resource usage counter on each - // thread. Every time QueryThreadProcessorUsage() is invoked it returns the amount of cpu time (a - // combination of user and kernel mode time) used since the last call to QueryThreadProcessorUsage(). The - // result is in 100 nanosecond units. - ULONGLONG QueryThreadProcessorUsage(); private: - // The amount of processor time (both user and kernel) in 100ns units used by this thread at the time of - // the last call to QueryThreadProcessorUsage(). - ULONGLONG m_ullProcessorUsageBaseline; -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING // Disables pumping and thread join in RCW creation bool m_fDisableComObjectEagerCleanup; @@ -4854,7 +4844,6 @@ private: // See ThreadStore::TriggerGCForDeadThreadsIfNecessary() bool m_fHasDeadThreadBeenConsideredForGCTrigger; -private: CLRRandom m_random; public: diff --git a/src/vm/util.cpp b/src/vm/util.cpp index fafbf5bbb2..0a21d3da6d 100644 --- a/src/vm/util.cpp +++ b/src/vm/util.cpp @@ -3148,49 +3148,6 @@ BOOL DelayLoadOleaut32CheckDisabled() } #endif -BOOL EnableARM() -{ -#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING - CONTRACTL - { - NOTHROW; - // TODO: this should really be GC_TRIGGERS so we wouldn't need the - // CONTRACT_VIOLATION below but the hosting API that calls this - // can be called on a COOP thread and it has a GC_NOTRIGGER contract. - // We should use the AD unload thread to call this function on. - GC_NOTRIGGER; - } - CONTRACTL_END; - - BOOL fARMEnabled = g_fEnableARM; - - if (!fARMEnabled) - { - if (ThreadStore::s_pThreadStore) - { - // We need to establish the baselines for the CPU usage counting. - Thread *pThread = NULL; - CONTRACT_VIOLATION(GCViolation); - - // Take the thread store lock while we enumerate threads. - ThreadStoreLockHolder tsl ; - - while ((pThread = ThreadStore::GetThreadList(pThread)) != NULL) - { - if (pThread->IsUnstarted() || pThread->IsDead()) - continue; - pThread->QueryThreadProcessorUsage(); - } - } - g_fEnableARM = TRUE; - } - - return fARMEnabled; -#else // FEATURE_APPDOMAIN_RESOURCE_MONITORING - return FALSE; -#endif // FEATURE_APPDOMAIN_RESOURCE_MONITORING -} - #endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE diff --git a/src/vm/util.hpp b/src/vm/util.hpp index 512f09f87b..d1086a9337 100644 --- a/src/vm/util.hpp +++ b/src/vm/util.hpp @@ -1114,11 +1114,6 @@ extern LONG g_OLEAUT32_Loaded; BOOL DbgIsExecutable(LPVOID lpMem, SIZE_T length); -#ifndef DACCESS_COMPILE -// returns if ARM was already enabled or not. -BOOL EnableARM(); -#endif // !DACCESS_COMPILE - int GetRandomInt(int maxVal); // diff --git a/src/vm/vars.cpp b/src/vm/vars.cpp index 8b329d4c2e..0887f2e0f1 100644 --- a/src/vm/vars.cpp +++ b/src/vm/vars.cpp @@ -185,8 +185,6 @@ int g_IGCTrimCommit = 0; BOOL g_fEnableETW = FALSE; -BOOL g_fEnableARM = FALSE; - // // Global state variable indicating if the EE is in its init phase. // diff --git a/src/vm/vars.hpp b/src/vm/vars.hpp index e4b790836e..25d46c2cc0 100644 --- a/src/vm/vars.hpp +++ b/src/vm/vars.hpp @@ -482,7 +482,6 @@ extern int g_IGCTrimCommit; #endif extern BOOL g_fEnableETW; -extern BOOL g_fEnableARM; // Returns a BOOL to indicate if the runtime is active or not BOOL IsRuntimeActive(); |