diff options
author | Elinor Fung <elfung@microsoft.com> | 2022-11-10 08:57:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 08:57:59 +0300 |
commit | db213657acc53fc48212867d5728e83d9e36a558 (patch) | |
tree | 5450d6b532421f67c72cc848b410a0b206db7223 | |
parent | 059285bab60a7cf75c92b48dcc2fcb7bdf6a8b8a (diff) |
Delete `AppDomainIterator` (#78078)
-rw-r--r-- | src/coreclr/debug/daccess/daccess.cpp | 113 | ||||
-rw-r--r-- | src/coreclr/debug/daccess/dacdbiimpl.cpp | 22 | ||||
-rw-r--r-- | src/coreclr/debug/daccess/dacimpl.h | 45 | ||||
-rw-r--r-- | src/coreclr/debug/daccess/enummem.cpp | 20 | ||||
-rw-r--r-- | src/coreclr/debug/daccess/request.cpp | 12 | ||||
-rw-r--r-- | src/coreclr/debug/daccess/task.cpp | 31 | ||||
-rw-r--r-- | src/coreclr/nativeaot/Runtime/eventtrace.cpp | 15 | ||||
-rw-r--r-- | src/coreclr/vm/appdomain.cpp | 24 | ||||
-rw-r--r-- | src/coreclr/vm/appdomain.hpp | 158 | ||||
-rw-r--r-- | src/coreclr/vm/ceeload.cpp | 14 | ||||
-rw-r--r-- | src/coreclr/vm/eventtrace.cpp | 10 | ||||
-rw-r--r-- | src/coreclr/vm/interoputil.cpp | 7 | ||||
-rw-r--r-- | src/coreclr/vm/multicorejit.cpp | 22 |
13 files changed, 89 insertions, 404 deletions
diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index b77e0312e23..f383542abbd 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -543,32 +543,13 @@ MetaEnum::NextDomainToken(AppDomain** appDomain, return NextToken(token, NULL, NULL); } - // - // Splay tokens across all app domains. - // - - while (true) + // Need to fetch a token. + if ((status = NextToken(token, NULL, NULL)) != S_OK) { - if (m_lastToken == mdTokenNil) - { - // Need to fetch a token. - if ((status = NextToken(token, NULL, NULL)) != S_OK) - { - return status; - } - - m_domainIter.Init(); - } - - if (m_domainIter.Next()) - { - break; - } - - m_lastToken = mdTokenNil; + return status; } - *appDomain = m_domainIter.GetDomain(); + *appDomain = AppDomain::GetCurrentDomain(); *token = m_lastToken; return S_OK; @@ -622,33 +603,14 @@ MetaEnum::NextDomainTokenByName(_In_opt_ LPCUTF8 namespaceName, return NextTokenByName(namespaceName, name, nameFlags, token); } - // - // Splay tokens across all app domains. - // - - while (true) + // Need to fetch a token. + if ((status = NextTokenByName(namespaceName, name, nameFlags, + token)) != S_OK) { - if (m_lastToken == mdTokenNil) - { - // Need to fetch a token. - if ((status = NextTokenByName(namespaceName, name, nameFlags, - token)) != S_OK) - { - return status; - } - - m_domainIter.Init(); - } - - if (m_domainIter.Next()) - { - break; - } - - m_lastToken = mdTokenNil; + return status; } - *appDomain = m_domainIter.GetDomain(); + *appDomain = AppDomain::GetCurrentDomain(); *token = m_lastToken; return S_OK; @@ -1366,35 +1328,16 @@ SplitName::CdNextDomainField(ClrDataAccess* dac, 0, NULL, NULL, NULL, NULL); } - // - // Splay fields across all app domains. - // - - while (true) + // Need to fetch a field. + if ((status = CdNextField(dac, handle, NULL, NULL, NULL, + 0, NULL, NULL, NULL, NULL)) != S_OK) { - if (!split->m_lastField) - { - // Need to fetch a field. - if ((status = CdNextField(dac, handle, NULL, NULL, NULL, - 0, NULL, NULL, NULL, NULL)) != S_OK) - { - return status; - } - - split->m_metaEnum.m_domainIter.Init(); - } - - if (split->m_metaEnum.m_domainIter.Next()) - { - break; - } - - split->m_lastField = NULL; + return status; } return ClrDataValue:: NewFromFieldDesc(dac, - split->m_metaEnum.m_domainIter.GetDomain(), + AppDomain::GetCurrentDomain(), split->m_fieldEnum.IsFieldFromParentClass() ? CLRDATA_VALUE_IS_INHERITED : 0, split->m_lastField, @@ -3730,16 +3673,9 @@ ClrDataAccess::StartEnumAppDomains( EX_TRY { - AppDomainIterator* iter = new (nothrow) AppDomainIterator(FALSE); - if (iter) - { - *handle = TO_CDENUM(iter); - status = S_OK; - } - else - { - status = E_OUTOFMEMORY; - } + // Only one app domain - use 1 to indicate there there is a next value + *handle = 1; + status = S_OK; } EX_CATCH { @@ -3765,12 +3701,12 @@ ClrDataAccess::EnumAppDomain( EX_TRY { - AppDomainIterator* iter = FROM_CDENUM(AppDomainIterator, *handle); - if (iter->Next()) + if (*handle == 1) { *appDomain = new (nothrow) - ClrDataAppDomain(this, iter->GetDomain()); + ClrDataAppDomain(this, AppDomain::GetCurrentDomain()); status = *appDomain ? S_OK : E_OUTOFMEMORY; + *handle = 0; } else { @@ -3800,8 +3736,7 @@ ClrDataAccess::EndEnumAppDomains( EX_TRY { - AppDomainIterator* iter = FROM_CDENUM(AppDomainIterator, handle); - delete iter; + // Nothing to do - we don't actually create an iterator for app domains status = S_OK; } EX_CATCH @@ -4462,8 +4397,7 @@ ClrDataAccess::TranslateExceptionRecordToNotification( else { // Find a likely domain, because it's the shared domain. - AppDomainIterator adi(FALSE); - appDomain = adi.GetDomain(); + appDomain = AppDomain::GetCurrentDomain(); } pubMethodInst = @@ -4527,8 +4461,7 @@ ClrDataAccess::TranslateExceptionRecordToNotification( else { // Find a likely domain, because it's the shared domain. - AppDomainIterator adi(FALSE); - appDomain = adi.GetDomain(); + appDomain = AppDomain::GetCurrentDomain(); } pubMethodInst = diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index 3ba32fb341e..e20b0241776 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -4457,23 +4457,13 @@ void DacDbiInterfaceImpl::EnumerateAppDomains( _ASSERTE(fpCallback != NULL); - // Only include active appdomains in the enumeration. - // This includes appdomains sent before the AD load event, - // and does not include appdomains that are in shutdown after the AD exit event. - const BOOL bOnlyActive = TRUE; - AppDomainIterator iterator(bOnlyActive); + // It's critical that we don't yield appdomains after the unload event has been sent. + // See code:IDacDbiInterface#Enumeration for details. + AppDomain * pAppDomain = AppDomain::GetCurrentDomain(); - while(iterator.Next()) - { - // It's critical that we don't yield appdomains after the unload event has been sent. - // See code:IDacDbiInterface#Enumeration for details. - AppDomain * pAppDomain = iterator.GetDomain(); - - VMPTR_AppDomain vmAppDomain = VMPTR_AppDomain::NullPtr(); - vmAppDomain.SetHostPtr(pAppDomain); - - fpCallback(vmAppDomain, pUserData); - } + VMPTR_AppDomain vmAppDomain = VMPTR_AppDomain::NullPtr(); + vmAppDomain.SetHostPtr(pAppDomain); + fpCallback(vmAppDomain, pUserData); } // Enumerate all Assemblies in an appdomain. diff --git a/src/coreclr/debug/daccess/dacimpl.h b/src/coreclr/debug/daccess/dacimpl.h index 33a2149e9a5..a122d4eb675 100644 --- a/src/coreclr/debug/daccess/dacimpl.h +++ b/src/coreclr/debug/daccess/dacimpl.h @@ -279,7 +279,6 @@ class MetaEnum { public: MetaEnum(void) - : m_domainIter(FALSE) { Clear(); m_appDomain = NULL; @@ -355,7 +354,6 @@ public: ULONG32 m_kind; HENUMInternal m_enum; AppDomain* m_appDomain; - AppDomainIterator m_domainIter; mdToken m_lastToken; static HRESULT New(Module* mod, @@ -502,13 +500,11 @@ public: struct ProcessModIter { - AppDomainIterator m_domainIter; bool m_nextDomain; AppDomain::AssemblyIterator m_assemIter; Assembly* m_curAssem; ProcessModIter(void) - : m_domainIter(FALSE) { SUPPORTS_DAC; m_nextDomain = true; @@ -518,33 +514,24 @@ struct ProcessModIter Assembly * NextAssem() { SUPPORTS_DAC; - for (;;) - { - if (m_nextDomain) - { - if (!m_domainIter.Next()) - { - break; - } - - m_nextDomain = false; - m_assemIter = m_domainIter.GetDomain()->IterateAssembliesEx((AssemblyIterationFlags)( - kIncludeLoaded | kIncludeExecution)); - } + if (m_nextDomain) + { + m_nextDomain = false; - CollectibleAssemblyHolder<DomainAssembly *> pDomainAssembly; - if (!m_assemIter.Next(pDomainAssembly.This())) - { - m_nextDomain = true; - continue; - } + m_assemIter = AppDomain::GetCurrentDomain()->IterateAssembliesEx((AssemblyIterationFlags)( + kIncludeLoaded | kIncludeExecution)); + } - // Note: DAC doesn't need to keep the assembly alive - see code:CollectibleAssemblyHolder#CAH_DAC - CollectibleAssemblyHolder<Assembly *> pAssembly = pDomainAssembly->GetAssembly(); - return pAssembly; + CollectibleAssemblyHolder<DomainAssembly *> pDomainAssembly; + if (!m_assemIter.Next(pDomainAssembly.This())) + { + return NULL; } - return NULL; + + // Note: DAC doesn't need to keep the assembly alive - see code:CollectibleAssemblyHolder#CAH_DAC + CollectibleAssemblyHolder<Assembly *> pAssembly = pDomainAssembly->GetAssembly(); + return pAssembly; } Module* NextModule(void) @@ -3948,9 +3935,7 @@ public: static HRESULT CdEnd(CLRDATA_ENUM handle); MethodDesc* m_methodDesc; - AppDomain* m_givenAppDomain; - bool m_givenAppDomainUsed; - AppDomainIterator m_domainIter; + bool m_appDomainUsed; AppDomain* m_appDomain; LoadedMethodDescIterator m_methodIter; }; diff --git a/src/coreclr/debug/daccess/enummem.cpp b/src/coreclr/debug/daccess/enummem.cpp index 6763ecb358f..b8b505744ad 100644 --- a/src/coreclr/debug/daccess/enummem.cpp +++ b/src/coreclr/debug/daccess/enummem.cpp @@ -702,18 +702,18 @@ HRESULT ClrDataAccess::EnumMemDumpAppDomainInfo(CLRDataEnumMemoryFlags flags) SystemDomain::System()->GetLoaderAllocator()->EnumMemoryRegions(flags); } - AppDomainIterator adIter(FALSE); + AppDomain* appDomain = AppDomain::GetCurrentDomain(); + if (appDomain == NULL) + return S_OK; + EX_TRY { - while (adIter.Next()) - { - CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED - ( - // Note that the flags being CLRDATA_ENUM_MEM_MINI prevents - // you from pulling entire files loaded into memory into the dump. - adIter.GetDomain()->EnumMemoryRegions(flags, true); - ); - } + CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED + ( + // Note that the flags being CLRDATA_ENUM_MEM_MINI prevents + // you from pulling entire files loaded into memory into the dump. + appDomain->EnumMemoryRegions(flags, true); + ); } EX_CATCH_RETHROW_ONLY_COR_E_OPERATIONCANCELLED diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index a16aaf8e9b9..74974c3b6f4 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -2214,13 +2214,14 @@ HRESULT ClrDataAccess::GetAppDomainList(unsigned int count, CLRDATA_ADDRESS valu { SOSDacEnter(); - AppDomainIterator ai(FALSE); + AppDomain* appDomain = AppDomain::GetCurrentDomain(); unsigned int i = 0; - while (ai.Next() && (i < count)) + if (appDomain != NULL && i < count) { if (values) - values[i] = HOST_CDADDR(ai.GetDomain()); - i++; + values[0] = HOST_CDADDR(appDomain); + + i = 1; } if (fetched) @@ -2240,8 +2241,7 @@ ClrDataAccess::GetAppDomainStoreData(struct DacpAppDomainStoreData *adsData) // Get an accurate count of appdomains. adsData->DomainCount = 0; - AppDomainIterator ai(FALSE); - while (ai.Next()) + if (AppDomain::GetCurrentDomain() != NULL) adsData->DomainCount++; SOSDacLeave(); diff --git a/src/coreclr/debug/daccess/task.cpp b/src/coreclr/debug/daccess/task.cpp index 02751c12c59..5cafc577bef 100644 --- a/src/coreclr/debug/daccess/task.cpp +++ b/src/coreclr/debug/daccess/task.cpp @@ -5188,45 +5188,27 @@ EnumMethodDefinitions::CdEnd(CLRDATA_ENUM handle) EnumMethodInstances::EnumMethodInstances(MethodDesc* methodDesc, IXCLRDataAppDomain* givenAppDomain) - : m_domainIter(FALSE) { m_methodDesc = methodDesc; if (givenAppDomain) { - m_givenAppDomain = + m_appDomain = ((ClrDataAppDomain*)givenAppDomain)->GetAppDomain(); } else { - m_givenAppDomain = NULL; + m_appDomain = AppDomain::GetCurrentDomain(); } - m_givenAppDomainUsed = false; - m_appDomain = NULL; + m_appDomainUsed = false; } HRESULT EnumMethodInstances::Next(ClrDataAccess* dac, IXCLRDataMethodInstance **instance) { - NextDomain: - if (!m_appDomain) + if (!m_appDomainUsed) { - if (m_givenAppDomainUsed || - !m_domainIter.Next()) - { - return S_FALSE; - } - - if (m_givenAppDomain) - { - m_appDomain = m_givenAppDomain; - m_givenAppDomainUsed = true; - } - else - { - m_appDomain = m_domainIter.GetDomain(); - } - + m_appDomainUsed = true; m_methodIter.Start(m_appDomain, m_methodDesc->GetModule(), // module m_methodDesc->GetMemberDef(), // token @@ -5239,8 +5221,7 @@ EnumMethodInstances::Next(ClrDataAccess* dac, CollectibleAssemblyHolder<DomainAssembly *> pDomainAssembly; if (!m_methodIter.Next(pDomainAssembly.This())) { - m_appDomain = NULL; - goto NextDomain; + return S_FALSE; } } diff --git a/src/coreclr/nativeaot/Runtime/eventtrace.cpp b/src/coreclr/nativeaot/Runtime/eventtrace.cpp index 5893ed4b630..39de4049df0 100644 --- a/src/coreclr/nativeaot/Runtime/eventtrace.cpp +++ b/src/coreclr/nativeaot/Runtime/eventtrace.cpp @@ -6487,18 +6487,15 @@ void ETW::EnumerationLog::EnumerationHelper(Module* moduleFilter, BaseDomain* do } else { - AppDomainIterator appDomainIterator(FALSE); - while (appDomainIterator.Next()) + AppDomain * pDomain = AppDomain::GetCurrentDomain(); + if (pDomain != NULL) { - AppDomain* pDomain = appDomainIterator.GetDomain(); - if (pDomain != NULL) - { - // See code:#TableLockHolder - ReJitManager::TableLockHolder lkRejitMgrAD(pDomain->GetReJitManager()); + // See code:#TableLockHolder + ReJitManager::TableLockHolder lkRejitMgrAD(pDomain->GetReJitManager()); - ETW::EnumerationLog::IterateAppDomain(pDomain, enumerationOptions); - } + ETW::EnumerationLog::IterateAppDomain(pDomain, enumerationOptions); } + ETW::EnumerationLog::IterateDomain(SharedDomain::GetDomain(), enumerationOptions); } } diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index fe4e901de57..74c74041a49 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -1032,10 +1032,7 @@ void SystemDomain::DetachEnd() void SystemDomain::Stop() { WRAPPER_NO_CONTRACT; - AppDomainIterator i(TRUE); - - while (i.Next()) - i.GetDomain()->Stop(); + AppDomain::GetCurrentDomain()->Stop(); } void SystemDomain::PreallocateSpecialObjects() @@ -1220,19 +1217,6 @@ void SystemDomain::LazyInitFrozenObjectsHeap() } CONTRACT_END; - // We don't do a normal AppDomainIterator because we can't take the SystemDomain lock from - // here. - // We're only supposed to call this from a Server GC. We're walking here m_appDomainIdList - // m_appDomainIdList will have an AppDomain* or will be NULL. So the only danger is if we - // Fetch an AppDomain and then in some other thread the AppDomain is deleted. - // - // If the thread deleting the AppDomain (AppDomain::~AppDomain)was in Preemptive mode - // while doing SystemDomain::EnumAllStaticGCRefs we will issue a GCX_COOP(), which will wait - // for the GC to finish, so we are safe - // - // If the thread is in cooperative mode, it must have been suspended for the GC so a delete - // can't happen. - _ASSERTE(GCHeapUtilities::IsGCInProgress() && GCHeapUtilities::IsServerHeap() && IsGCSpecialThread()); @@ -1910,10 +1894,6 @@ AppDomain::AppDomain() m_ForceTrivialWaitOperations = false; m_Stage=STAGE_CREATING; -#ifdef _DEBUG - m_dwIterHolders=0; -#endif - #ifdef FEATURE_TYPEEQUIVALENCE m_pTypeEquivalenceTable = NULL; #endif // FEATURE_TYPEEQUIVALENCE @@ -5120,7 +5100,7 @@ AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, bool enumThis) { GetLoaderAllocator()->EnumMemoryRegions(flags); } - + m_Assemblies.EnumMemoryRegions(flags); AssemblyIterator assem = IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); CollectibleAssemblyHolder<DomainAssembly *> pDomainAssembly; diff --git a/src/coreclr/vm/appdomain.hpp b/src/coreclr/vm/appdomain.hpp index 0dbff5efbf6..18b4d4fd3f5 100644 --- a/src/coreclr/vm/appdomain.hpp +++ b/src/coreclr/vm/appdomain.hpp @@ -1468,8 +1468,6 @@ struct FailedAssembly { } }; -class AppDomainIterator; - const DWORD DefaultADID = 1; // An Appdomain is the managed equivalent of a process. It is an isolation unit (conceptually you don't @@ -1974,29 +1972,6 @@ public: static void ExceptionUnwind(Frame *pFrame); -#ifdef _DEBUG - - BOOL IsHeldByIterator() - { - LIMITED_METHOD_CONTRACT; - return m_dwIterHolders>0; - } - - void IteratorRelease() - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(m_dwIterHolders); - InterlockedDecrement(&m_dwIterHolders); - } - - - void IteratorAcquire() - { - LIMITED_METHOD_CONTRACT; - InterlockedIncrement(&m_dwIterHolders); - } - -#endif BOOL IsActive() { LIMITED_METHOD_DAC_CONTRACT; @@ -2017,7 +1992,6 @@ public: #endif } - static void RaiseExitProcessEvent(); Assembly* RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR szName); DomainAssembly* RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef); @@ -2208,10 +2182,6 @@ private: ArrayList m_failedAssemblies; -#ifdef _DEBUG - Volatile<LONG> m_dwIterHolders; -#endif - // // DAC iterator for failed assembly loads // @@ -2348,8 +2318,6 @@ typedef VPTR(class SystemDomain) PTR_SystemDomain; class SystemDomain : public BaseDomain { friend class AppDomainNative; - friend class AppDomainIterator; - friend class UnsafeAppDomainIterator; friend class ClrDataAccess; VPTR_VTABLE_CLASS(SystemDomain, BaseDomain) @@ -2675,132 +2643,6 @@ public: }; // class SystemDomain - -// -// an UnsafeAppDomainIterator is used to iterate over all existing domains -// -// The iteration is guaranteed to include all domains that exist at the -// start & end of the iteration. This iterator is considered unsafe because it does not -// reference count the various appdomains, and can only be used when the runtime is stopped, -// or external synchronization is used. (and therefore no other thread may cause the appdomain list to change.) -// In CoreCLR, this iterator doesn't use a list as there is at most 1 AppDomain, and instead will find the only AppDomain, or not. -// -class UnsafeAppDomainIterator -{ - friend class SystemDomain; -public: - UnsafeAppDomainIterator(BOOL bOnlyActive) - { - m_bOnlyActive = bOnlyActive; - } - - void Init() - { - LIMITED_METHOD_CONTRACT; - m_iterationCount = 0; - m_pCurrent = NULL; - } - - BOOL Next() - { - WRAPPER_NO_CONTRACT; - - if (m_iterationCount == 0) - { - m_iterationCount++; - m_pCurrent = AppDomain::GetCurrentDomain(); - if (m_pCurrent != NULL && - (m_bOnlyActive ? - m_pCurrent->IsActive() : m_pCurrent->IsValid())) - { - return TRUE; - } - } - - m_pCurrent = NULL; - return FALSE; - } - - AppDomain * GetDomain() - { - LIMITED_METHOD_DAC_CONTRACT; - - return m_pCurrent; - } - - private: - - int m_iterationCount; - AppDomain * m_pCurrent; - BOOL m_bOnlyActive; -}; // class UnsafeAppDomainIterator - -// -// an AppDomainIterator is used to iterate over all existing domains. -// -// The iteration is guaranteed to include all domains that exist at the -// start & end of the iteration. Any domains added or deleted during -// iteration may or may not be included. The iterator also guarantees -// that the current iterated appdomain (GetDomain()) will not be deleted. -// - -class AppDomainIterator : public UnsafeAppDomainIterator -{ - friend class SystemDomain; - - public: - AppDomainIterator(BOOL bOnlyActive) : UnsafeAppDomainIterator(bOnlyActive) - { - WRAPPER_NO_CONTRACT; - Init(); - } - - ~AppDomainIterator() - { - WRAPPER_NO_CONTRACT; - -#ifndef DACCESS_COMPILE - if (GetDomain() != NULL) - { -#ifdef _DEBUG - GetDomain()->IteratorRelease(); -#endif - GetDomain()->Release(); - } -#endif - } - - BOOL Next() - { - WRAPPER_NO_CONTRACT; - -#ifndef DACCESS_COMPILE - if (GetDomain() != NULL) - { -#ifdef _DEBUG - GetDomain()->IteratorRelease(); -#endif - GetDomain()->Release(); - } - - SystemDomain::LockHolder lh; -#endif - - if (UnsafeAppDomainIterator::Next()) - { -#ifndef DACCESS_COMPILE - GetDomain()->AddRef(); -#ifdef _DEBUG - GetDomain()->IteratorAcquire(); -#endif -#endif - return TRUE; - } - - return FALSE; - } -}; // class AppDomainIterator - #include "comreflectioncache.inl" #endif diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 73eb37933ab..9399e7bd7b6 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -2491,17 +2491,11 @@ void Module::SetSymbolBytes(LPCBYTE pbSyms, DWORD cbSyms) // the assembly was loaded in.</REVISIT_TODO> if (CORDebuggerAttached()) { - AppDomainIterator i(FALSE); - - while (i.Next()) + AppDomain *pDomain = AppDomain::GetCurrentDomain(); + if (pDomain->IsDebuggerAttached() && (GetDomain() == SystemDomain::System() || + pDomain->ContainsAssembly(m_pAssembly))) { - AppDomain *pDomain = i.GetDomain(); - - if (pDomain->IsDebuggerAttached() && (GetDomain() == SystemDomain::System() || - pDomain->ContainsAssembly(m_pAssembly))) - { - g_pDebugInterface->SendUpdateModuleSymsEventAndBlock(this, pDomain); - } + g_pDebugInterface->SendUpdateModuleSymsEventAndBlock(this, pDomain); } } } diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index 3582cbb6627..3043568b587 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -7668,14 +7668,10 @@ VOID ETW::EnumerationLog::EnumerationHelper(Module *moduleFilter, BaseDomain *do } else { - AppDomainIterator appDomainIterator(FALSE); - while(appDomainIterator.Next()) + AppDomain *pDomain = AppDomain::GetCurrentDomain(); + if (pDomain != NULL) { - AppDomain *pDomain = appDomainIterator.GetDomain(); - if (pDomain != NULL) - { - ETW::EnumerationLog::IterateAppDomain(pDomain, enumerationOptions); - } + ETW::EnumerationLog::IterateAppDomain(pDomain, enumerationOptions); } } } diff --git a/src/coreclr/vm/interoputil.cpp b/src/coreclr/vm/interoputil.cpp index 087e23b62ae..66130142728 100644 --- a/src/coreclr/vm/interoputil.cpp +++ b/src/coreclr/vm/interoputil.cpp @@ -1316,11 +1316,8 @@ static void ReleaseRCWsInCaches(LPVOID pCtxCookie) } CONTRACTL_END; - // Go through all the app domains and for each one release all the - // RCW's that live in the current context. - AppDomainIterator i(TRUE); - while (i.Next()) - i.GetDomain()->ReleaseRCWs(pCtxCookie); + // Release all the RCW's that live in the AppDomain. + AppDomain::GetCurrentDomain()->ReleaseRCWs(pCtxCookie); if (!g_fEEShutDown) { diff --git a/src/coreclr/vm/multicorejit.cpp b/src/coreclr/vm/multicorejit.cpp index 3bcc0e0c2e5..754d4e92976 100644 --- a/src/coreclr/vm/multicorejit.cpp +++ b/src/coreclr/vm/multicorejit.cpp @@ -1467,16 +1467,11 @@ void MulticoreJitManager::StopProfileAll() } CONTRACTL_END; - AppDomainIterator domain(TRUE); + AppDomain * pDomain = AppDomain::GetCurrentDomain(); - while (domain.Next()) + if (pDomain != NULL) { - AppDomain * pDomain = domain.GetDomain(); - - if (pDomain != NULL) - { - pDomain->GetMulticoreJitManager().StopProfile(true); - } + pDomain->GetMulticoreJitManager().StopProfile(true); } } @@ -1508,16 +1503,11 @@ void MulticoreJitManager::DisableMulticoreJit() #ifdef PROFILING_SUPPORTED - AppDomainIterator domain(TRUE); + AppDomain * pDomain = AppDomain::GetCurrentDomain(); - while (domain.Next()) + if (pDomain != NULL) { - AppDomain * pDomain = domain.GetDomain(); - - if (pDomain != NULL) - { - pDomain->GetMulticoreJitManager().AbortProfile(); - } + pDomain->GetMulticoreJitManager().AbortProfile(); } #endif |