diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index 28b31c4116a72..0c9750c0282cb 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -4421,12 +4421,12 @@ void DacDbiInterfaceImpl::EnumerateAssembliesInAppDomain( // Pass the magical flags to the loader enumerator to get all Execution-only assemblies. iterator = pAppDomain->IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoading | kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (iterator.Next(pDomainAssembly.This())) + while (iterator.Next(pAssembly.This())) { VMPTR_DomainAssembly vmDomainAssembly = VMPTR_DomainAssembly::NullPtr(); - vmDomainAssembly.SetHostPtr(pDomainAssembly); + vmDomainAssembly.SetHostPtr(pAssembly->GetDomainAssembly()); fpCallback(vmDomainAssembly, pUserData); } diff --git a/src/coreclr/debug/daccess/dacimpl.h b/src/coreclr/debug/daccess/dacimpl.h index cec666bc02bc1..0fc5a780e6f32 100644 --- a/src/coreclr/debug/daccess/dacimpl.h +++ b/src/coreclr/debug/daccess/dacimpl.h @@ -528,14 +528,12 @@ struct ProcessModIter kIncludeLoaded | kIncludeExecution)); } - CollectibleAssemblyHolder pDomainAssembly; - if (!m_assemIter.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + if (!m_assemIter.Next(pAssembly.This())) { return NULL; } - // Note: DAC doesn't need to keep the assembly alive - see code:CollectibleAssemblyHolder#CAH_DAC - CollectibleAssemblyHolder pAssembly = pDomainAssembly->GetAssembly(); return pAssembly; } diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index 2d675c3372802..800db3a2a09e0 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -2855,11 +2855,11 @@ ClrDataAccess::GetAppDomainData(CLRDATA_ADDRESS addr, struct DacpAppDomainData * // The assembly list is not valid in a closed appdomain. AppDomain::AssemblyIterator i = pAppDomain->IterateAssembliesEx((AssemblyIterationFlags)( kIncludeLoading | kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (i.Next(pDomainAssembly.This())) + while (i.Next(pAssembly.This())) { - if (pDomainAssembly->GetAssembly()->IsLoaded()) + if (pAssembly->IsLoaded()) { appdomainData->AssemblyCount++; } @@ -2971,14 +2971,13 @@ ClrDataAccess::GetAssemblyList(CLRDATA_ADDRESS addr, int count, CLRDATA_ADDRESS PTR_AppDomain pAppDomain = PTR_AppDomain(TO_TADDR(addr)); AppDomain::AssemblyIterator i = pAppDomain->IterateAssembliesEx( (AssemblyIterationFlags)(kIncludeLoading | kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; int n = 0; if (values) { - while (i.Next(pDomainAssembly.This()) && (n < count)) + while (i.Next(pAssembly.This()) && (n < count)) { - CollectibleAssemblyHolder pAssembly = pDomainAssembly->GetAssembly(); if (pAssembly->IsLoaded()) { // Note: DAC doesn't need to keep the assembly alive - see code:CollectibleAssemblyHolder#CAH_DAC @@ -2988,8 +2987,8 @@ ClrDataAccess::GetAssemblyList(CLRDATA_ADDRESS addr, int count, CLRDATA_ADDRESS } else { - while (i.Next(pDomainAssembly.This())) - if (pDomainAssembly->GetAssembly()->IsLoaded()) + while (i.Next(pAssembly.This())) + if (pAssembly->IsLoaded()) n++; } diff --git a/src/coreclr/debug/daccess/task.cpp b/src/coreclr/debug/daccess/task.cpp index 085c0e551ae8d..65f14dedd1892 100644 --- a/src/coreclr/debug/daccess/task.cpp +++ b/src/coreclr/debug/daccess/task.cpp @@ -5196,8 +5196,8 @@ EnumMethodInstances::Next(ClrDataAccess* dac, NextMethod: { // Note: DAC doesn't need to keep the assembly alive - see code:CollectibleAssemblyHolder#CAH_DAC - CollectibleAssemblyHolder pDomainAssembly; - if (!m_methodIter.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + if (!m_methodIter.Next(pAssembly.This())) { return S_FALSE; } diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 0e9d93f26c89a..b66bae97abc54 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -12322,12 +12322,12 @@ HRESULT Debugger::DeoptimizeMethod(Module* pModule, mdMethodDef methodDef) } // Now deoptimize anything that has inlined it in a R2R method - AppDomain::AssemblyIterator domainAssemblyIterator = SystemDomain::System()->DefaultDomain()->IterateAssembliesEx((AssemblyIterationFlags) (kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + AppDomain::AssemblyIterator assemblyIterator = SystemDomain::System()->DefaultDomain()->IterateAssembliesEx((AssemblyIterationFlags) (kIncludeLoaded | kIncludeExecution)); + CollectibleAssemblyHolder pAssembly; NativeImageInliningIterator inlinerIter; - while (domainAssemblyIterator.Next(pDomainAssembly.This())) + while (assemblyIterator.Next(pAssembly.This())) { - Module *pCandidateModule = pDomainAssembly->GetModule(); + Module *pCandidateModule = pAssembly->GetModule(); if (pCandidateModule->HasReadyToRunInlineTrackingMap()) { inlinerIter.Reset(pCandidateModule, MethodInModule(pModule, methodDef)); diff --git a/src/coreclr/debug/ee/functioninfo.cpp b/src/coreclr/debug/ee/functioninfo.cpp index 8babd5ba4431c..cd74c4f1f8b41 100644 --- a/src/coreclr/debug/ee/functioninfo.cpp +++ b/src/coreclr/debug/ee/functioninfo.cpp @@ -2023,8 +2023,8 @@ void DebuggerMethodInfo::CreateDJIsForNativeBlobs(AppDomain * pAppDomain, Method // This also handles the possibility of getting the same methoddesc back from the iterator. // It also lets EnC + generics play nice together (including if an generic method was EnC-ed) LoadedMethodDescIterator it(pAppDomain, m_module, m_token); - CollectibleAssemblyHolder pDomainAssembly; - while (it.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + while (it.Next(pAssembly.This())) { MethodDesc * pDesc = it.Current(); if (!pDesc->HasNativeCode()) diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index 051b7c2a2005f..01b4f2d180086 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -1819,11 +1819,10 @@ BOOL AppDomain::ContainsAssembly(Assembly * assem) WRAPPER_NO_CONTRACT; AssemblyIterator i = IterateAssembliesEx((AssemblyIterationFlags)( kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (i.Next(pDomainAssembly.This())) + while (i.Next(pAssembly.This())) { - CollectibleAssemblyHolder pAssembly = pDomainAssembly->GetAssembly(); if (pAssembly == assem) return TRUE; } @@ -2776,15 +2775,15 @@ Assembly * AppDomain::FindAssembly(PEAssembly * pPEAssembly, FindAssemblyOptions kIncludeLoaded | (includeFailedToLoad ? kIncludeFailedToLoad : 0) | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (i.Next(pDomainAssembly.This())) + while (i.Next(pAssembly.This())) { - PEAssembly * pManifestFile = pDomainAssembly->GetPEAssembly(); + PEAssembly * pManifestFile = pAssembly->GetPEAssembly(); if (pManifestFile && pManifestFile->Equals(pPEAssembly)) { - return pDomainAssembly.GetValue()->GetAssembly(); + return pAssembly; } } return NULL; @@ -3579,10 +3578,10 @@ BOOL AppDomain::NotifyDebuggerLoad(int flags, BOOL attaching) // Attach to our assemblies LOG((LF_CORDB, LL_INFO100, "AD::NDA: Iterating assemblies\n")); i = IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeLoading | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; - while (i.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + while (i.Next(pAssembly.This())) { - result = (pDomainAssembly->GetAssembly()->NotifyDebuggerLoad(flags, attaching) || + result = (pAssembly->NotifyDebuggerLoad(flags, attaching) || result); } @@ -3599,13 +3598,13 @@ void AppDomain::NotifyDebuggerUnload() LOG((LF_CORDB, LL_INFO100, "AD::NDD: Interating domain bound assemblies\n")); AssemblyIterator i = IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeLoading | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; // Detach from our assemblies - while (i.Next(pDomainAssembly.This())) + while (i.Next(pAssembly.This())) { LOG((LF_CORDB, LL_INFO100, "AD::NDD: Iterating assemblies\n")); - pDomainAssembly->GetAssembly()->NotifyDebuggerUnload(); + pAssembly->NotifyDebuggerUnload(); } } #endif // DEBUGGING_SUPPORTED @@ -4024,7 +4023,7 @@ void AppDomain::RemoveTypesFromTypeIDMap(LoaderAllocator* pLoaderAllocator) // BOOL AppDomain::AssemblyIterator::Next( - CollectibleAssemblyHolder * pDomainAssemblyHolder) + CollectibleAssemblyHolder * pAssemblyHolder) { CONTRACTL { NOTHROW; @@ -4033,7 +4032,7 @@ AppDomain::AssemblyIterator::Next( } CONTRACTL_END; CrstHolder ch(m_pAppDomain->GetAssemblyListLock()); - return Next_Unlocked(pDomainAssemblyHolder); + return Next_Unlocked(pAssemblyHolder); } //--------------------------------------------------------------------------------------- @@ -4042,7 +4041,7 @@ AppDomain::AssemblyIterator::Next( // BOOL AppDomain::AssemblyIterator::Next_Unlocked( - CollectibleAssemblyHolder * pDomainAssemblyHolder) + CollectibleAssemblyHolder * pAssemblyHolder) { CONTRACTL { NOTHROW; @@ -4068,13 +4067,13 @@ AppDomain::AssemblyIterator::Next_Unlocked( { if (m_assemblyIterationFlags & kIncludeFailedToLoad) { - *pDomainAssemblyHolder = pDomainAssembly; + *pAssemblyHolder = pAssembly; return TRUE; } continue; // reject } - // First, reject DomainAssemblies whose load status is not to be included in + // First, reject assemblies whose load status is not to be included in // the enumeration if (pAssembly->IsAvailableToProfilers() && @@ -4104,7 +4103,7 @@ AppDomain::AssemblyIterator::Next_Unlocked( } } - // Next, reject DomainAssemblies whose execution status is + // Next, reject assemblies whose execution status is // not to be included in the enumeration // execution assembly @@ -4114,7 +4113,7 @@ AppDomain::AssemblyIterator::Next_Unlocked( } // Next, reject collectible assemblies - if (pDomainAssembly->IsCollectible()) + if (pAssembly->IsCollectible()) { if (m_assemblyIterationFlags & kExcludeCollectible) { @@ -4130,14 +4129,14 @@ AppDomain::AssemblyIterator::Next_Unlocked( continue; // reject } - if (pDomainAssembly->GetLoaderAllocator()->AddReferenceIfAlive()) + if (pAssembly->GetLoaderAllocator()->AddReferenceIfAlive()) { // The assembly is alive // Set the holder value (incl. increasing ref-count) - *pDomainAssemblyHolder = pDomainAssembly; + *pAssemblyHolder = pAssembly; // Now release the reference we took in the if-condition - pDomainAssembly->GetLoaderAllocator()->Release(); + pAssembly->GetLoaderAllocator()->Release(); return TRUE; } // The assembly is not alive anymore (and we didn't increase its ref-count in the @@ -4149,15 +4148,15 @@ AppDomain::AssemblyIterator::Next_Unlocked( } // Set the holder value to assembly with 0 ref-count without increasing the ref-count (won't // call Release either) - pDomainAssemblyHolder->Assign(pDomainAssembly, FALSE); + pAssemblyHolder->Assign(pAssembly, FALSE); return TRUE; } - *pDomainAssemblyHolder = pDomainAssembly; + *pAssemblyHolder = pAssembly; return TRUE; } - *pDomainAssemblyHolder = NULL; + *pAssemblyHolder = NULL; return FALSE; } // AppDomain::AssemblyIterator::Next_Unlocked @@ -4424,11 +4423,11 @@ AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, bool enumThis) m_Assemblies.EnumMemoryRegions(flags); AssemblyIterator assem = IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (assem.Next(pDomainAssembly.This())) + while (assem.Next(pAssembly.This())) { - pDomainAssembly->EnumMemoryRegions(flags); + pAssembly->GetDomainAssembly()->EnumMemoryRegions(flags); } } diff --git a/src/coreclr/vm/appdomain.hpp b/src/coreclr/vm/appdomain.hpp index 4561d3b6517ce..c9780094d1894 100644 --- a/src/coreclr/vm/appdomain.hpp +++ b/src/coreclr/vm/appdomain.hpp @@ -1002,9 +1002,9 @@ class AppDomain final AssemblyIterationFlags m_assemblyIterationFlags; public: - BOOL Next(CollectibleAssemblyHolder * pDomainAssemblyHolder); - // Note: Does not lock the assembly list, but AddRefs collectible assemblies. - BOOL Next_Unlocked(CollectibleAssemblyHolder * pDomainAssemblyHolder); + BOOL Next(CollectibleAssemblyHolder * pAssemblyHolder); + // Note: Does not lock the assembly list, but AddRefs collectible assemblies' loader allocator. + BOOL Next_Unlocked(CollectibleAssemblyHolder * pAssemblyHolder); private: inline DWORD GetIndex() diff --git a/src/coreclr/vm/appdomainnative.cpp b/src/coreclr/vm/appdomainnative.cpp index 2977195cf2b54..ada5e6c7b689a 100644 --- a/src/coreclr/vm/appdomainnative.cpp +++ b/src/coreclr/vm/appdomainnative.cpp @@ -70,14 +70,14 @@ extern "C" void QCALLTYPE AssemblyNative_GetLoadedAssemblies(QCall::ObjectHandle // loaded into this appdomain, on another thread. AppDomain::AssemblyIterator i = pApp->IterateAssembliesEx((AssemblyIterationFlags)( kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (i.Next(pDomainAssembly.This()) && (numAssemblies < nArrayElems)) + while (i.Next(pAssembly.This()) && (numAssemblies < nArrayElems)) { // Do not change this code. This is done this way to // prevent a GC hole in the SetObjectReference() call. The compiler // is free to pick the order of evaluation. - OBJECTREF o = (OBJECTREF)pDomainAssembly->GetAssembly()->GetExposedObject(); + OBJECTREF o = (OBJECTREF)pAssembly->GetExposedObject(); if (o == NULL) { // The assembly was collected and is not reachable from managed code anymore continue; diff --git a/src/coreclr/vm/class.cpp b/src/coreclr/vm/class.cpp index e7aec3bce335e..8f7d33be46a21 100644 --- a/src/coreclr/vm/class.cpp +++ b/src/coreclr/vm/class.cpp @@ -459,10 +459,10 @@ HRESULT EEClass::AddField(MethodTable* pMT, mdFieldDef fieldDef, FieldDesc** ppN AppDomain::AssemblyIterator appIt = pDomain->IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); bool isStaticField = !!pNewFD->IsStatic(); - CollectibleAssemblyHolder pDomainAssembly; - while (appIt.Next(pDomainAssembly.This()) && SUCCEEDED(hr)) + CollectibleAssemblyHolder pAssembly; + while (appIt.Next(pAssembly.This()) && SUCCEEDED(hr)) { - Module* pMod = pDomainAssembly->GetModule(); + Module* pMod = pAssembly->GetModule(); LOG((LF_ENC, LL_INFO100, "EEClass::AddField Checking: %s mod:%p\n", pMod->GetDebugName(), pMod)); EETypeHashTable* paramTypes = pMod->GetAvailableParamTypes(); @@ -655,10 +655,10 @@ HRESULT EEClass::AddMethod(MethodTable* pMT, mdMethodDef methodDef, MethodDesc** PTR_AppDomain pDomain = AppDomain::GetCurrentDomain(); AppDomain::AssemblyIterator appIt = pDomain->IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; - while (appIt.Next(pDomainAssembly.This()) && SUCCEEDED(hr)) + CollectibleAssemblyHolder pAssembly; + while (appIt.Next(pAssembly.This()) && SUCCEEDED(hr)) { - Module* pMod = pDomainAssembly->GetModule(); + Module* pMod = pAssembly->GetModule(); LOG((LF_ENC, LL_INFO100, "EEClass::AddMethod Checking: %s mod:%p\n", pMod->GetDebugName(), pMod)); EETypeHashTable* paramTypes = pMod->GetAvailableParamTypes(); diff --git a/src/coreclr/vm/codeversion.cpp b/src/coreclr/vm/codeversion.cpp index 04de0dc003be7..4fb4364ff3324 100644 --- a/src/coreclr/vm/codeversion.cpp +++ b/src/coreclr/vm/codeversion.cpp @@ -2055,8 +2055,8 @@ HRESULT CodeVersionManager::EnumerateDomainClosedMethodDescs( pModuleContainingMethodDef, methodDef, assemFlags); - CollectibleAssemblyHolder pDomainAssembly; - while (it.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + while (it.Next(pAssembly.This())) { MethodDesc * pLoadedMD = it.Current(); diff --git a/src/coreclr/vm/encee.cpp b/src/coreclr/vm/encee.cpp index 7dec6bc204589..250a90eb51eae 100644 --- a/src/coreclr/vm/encee.cpp +++ b/src/coreclr/vm/encee.cpp @@ -343,8 +343,8 @@ HRESULT EditAndContinueModule::UpdateMethod(MethodDesc *pMethod) module, tkMethod, AssemblyIterationFlags(kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; - while (it.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + while (it.Next(pAssembly.This())) { MethodDesc* pMD = it.Current(); pMD->ResetCodeEntryPointForEnC(); diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index 4f563dd5b2744..726205a15e7bc 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -5373,16 +5373,15 @@ VOID ETW::EnumerationLog::IterateAppDomain(DWORD enumerationOptions) AppDomain::AssemblyIterator assemblyIterator = pDomain->IterateAssembliesEx( (AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; - while (assemblyIterator.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + while (assemblyIterator.Next(pAssembly.This())) { - CollectibleAssemblyHolder pAssembly = pDomainAssembly->GetAssembly(); if (enumerationOptions & ETW::EnumerationLog::EnumerationStructs::DomainAssemblyModuleDCStart) { ETW::EnumerationLog::IterateAssembly(pAssembly, enumerationOptions); } - Module * pModule = pDomainAssembly->GetModule(); + Module * pModule = pAssembly->GetModule(); ETW::EnumerationLog::IterateModule(pModule, enumerationOptions); if((enumerationOptions & ETW::EnumerationLog::EnumerationStructs::DomainAssemblyModuleDCEnd) || diff --git a/src/coreclr/vm/eventtrace_bulktype.cpp b/src/coreclr/vm/eventtrace_bulktype.cpp index a2d30fa1ca487..1cb9e212ce4f2 100644 --- a/src/coreclr/vm/eventtrace_bulktype.cpp +++ b/src/coreclr/vm/eventtrace_bulktype.cpp @@ -513,16 +513,15 @@ void BulkStaticsLogger::LogAllStatics() AppDomain *domain = ::GetAppDomain(); // There is only 1 AppDomain, so no iterator here. AppDomain::AssemblyIterator assemblyIter = domain->IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded|kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; - while (assemblyIter.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + while (assemblyIter.Next(pAssembly.This())) { // Make sure the assembly is loaded. - CollectibleAssemblyHolder pAssembly = pDomainAssembly->GetAssembly(); if (!pAssembly->IsLoaded()) continue; // Get the domain module from the module/appdomain pair. - Module *module = pDomainAssembly->GetModule(); + Module *module = pAssembly->GetModule(); if (module == NULL) continue; diff --git a/src/coreclr/vm/loaderallocator.cpp b/src/coreclr/vm/loaderallocator.cpp index dc1f4d72d00b9..0eaffbc912865 100644 --- a/src/coreclr/vm/loaderallocator.cpp +++ b/src/coreclr/vm/loaderallocator.cpp @@ -357,13 +357,10 @@ LoaderAllocator * LoaderAllocator::GCLoaderAllocators_RemoveAssemblies(AppDomain AppDomain::AssemblyIterator iData; iData = pAppDomain->IterateAssembliesEx((AssemblyIterationFlags)( kIncludeExecution | kIncludeLoaded | kIncludeCollected)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (iData.Next_Unlocked(pDomainAssembly.This())) + while (iData.Next_Unlocked(pAssembly.This())) { - // The assembly could be collected (ref-count = 0), do not use holder which calls add-ref - Assembly * pAssembly = pDomainAssembly->GetAssembly(); - if (pAssembly != NULL) { LoaderAllocator * pLoaderAllocator = pAssembly->GetLoaderAllocator(); @@ -391,13 +388,10 @@ LoaderAllocator * LoaderAllocator::GCLoaderAllocators_RemoveAssemblies(AppDomain i = pAppDomain->IterateAssembliesEx((AssemblyIterationFlags)( kIncludeExecution | kIncludeLoaded | kIncludeCollected)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (i.Next_Unlocked(pDomainAssembly.This())) + while (i.Next_Unlocked(pAssembly.This())) { - // The assembly could be collected (ref-count = 0), do not use holder which calls add-ref - Assembly * pAssembly = pDomainAssembly->GetAssembly(); - if (pAssembly != NULL) { LoaderAllocator * pLoaderAllocator = pAssembly->GetLoaderAllocator(); @@ -414,11 +408,8 @@ LoaderAllocator * LoaderAllocator::GCLoaderAllocators_RemoveAssemblies(AppDomain i = pAppDomain->IterateAssembliesEx((AssemblyIterationFlags)( kIncludeExecution | kIncludeLoaded | kIncludeCollected)); - while (i.Next_Unlocked(pDomainAssembly.This())) + while (i.Next_Unlocked(pAssembly.This())) { - // The assembly could be collected (ref-count = 0), do not use holder which calls add-ref - Assembly * pAssembly = pDomainAssembly->GetAssembly(); - if (pAssembly != NULL) { LoaderAllocator * pLoaderAllocator = pAssembly->GetLoaderAllocator(); diff --git a/src/coreclr/vm/methoditer.cpp b/src/coreclr/vm/methoditer.cpp index 409cbb991f259..7f84806123d5a 100644 --- a/src/coreclr/vm/methoditer.cpp +++ b/src/coreclr/vm/methoditer.cpp @@ -18,7 +18,7 @@ // assembly might be without a reference and get deallocated (even the native part). // BOOL LoadedMethodDescIterator::Next( - CollectibleAssemblyHolder * pDomainAssemblyHolder) + CollectibleAssemblyHolder * pAssemblyHolder) { CONTRACTL { @@ -35,7 +35,7 @@ BOOL LoadedMethodDescIterator::Next( // If the method + type is not generic, then nothing more to iterate. if (!m_mainMD->HasClassOrMethodInstantiation()) { - *pDomainAssemblyHolder = NULL; + *pAssemblyHolder = NULL; return FALSE; } goto ADVANCE_METHOD; @@ -53,31 +53,31 @@ BOOL LoadedMethodDescIterator::Next( // at the method table, flags and token etc. if (m_mainMD == NULL) { - *pDomainAssemblyHolder = NULL; + *pAssemblyHolder = NULL; return FALSE; } // Needs to work w/ non-generic methods too. if (!m_mainMD->HasClassOrMethodInstantiation()) { - *pDomainAssemblyHolder = NULL; + *pAssemblyHolder = NULL; return TRUE; } m_assemIterator = m_pAppDomain->IterateAssembliesEx(m_assemIterationFlags); ADVANCE_ASSEMBLY: - if (!m_assemIterator.Next(pDomainAssemblyHolder)) + if (!m_assemIterator.Next(pAssemblyHolder)) { - _ASSERTE(*pDomainAssemblyHolder == NULL); + _ASSERTE(*pAssemblyHolder == NULL); return FALSE; } #ifdef _DEBUG - dbg_m_pDomainAssembly = *pDomainAssemblyHolder; + dbg_m_pAssembly = *pAssemblyHolder; #endif //_DEBUG - m_currentModule = (*pDomainAssemblyHolder)->GetModule(); + m_currentModule = (*pAssemblyHolder)->GetModule(); if (m_mainMD->HasClassInstantiation()) { @@ -149,7 +149,7 @@ BOOL LoadedMethodDescIterator::Next( // Note: We don't need to keep the assembly alive in DAC - see code:CollectibleAssemblyHolder#CAH_DAC #ifndef DACCESS_COMPILE _ASSERTE_MSG( - *pDomainAssemblyHolder == dbg_m_pDomainAssembly, + *pAssemblyHolder == dbg_m_pAssembly, "Caller probably modified the assembly holder, which they shouldn't - see method comment."); #endif //DACCESS_COMPILE diff --git a/src/coreclr/vm/methoditer.h b/src/coreclr/vm/methoditer.h index fdc49e2ce5971..90ccc67e96f6c 100644 --- a/src/coreclr/vm/methoditer.h +++ b/src/coreclr/vm/methoditer.h @@ -56,14 +56,14 @@ class LoadedMethodDescIterator BOOL m_fFirstTime; #ifdef _DEBUG - DomainAssembly * dbg_m_pDomainAssembly; + Assembly * dbg_m_pAssembly; #endif //_DEBUG public: // Iterates next MethodDesc. Updates the holder only if the assembly differs from the previous one. // Caller should not release (i.e. change) the holder explicitly between calls, otherwise collectible // assembly might be without a reference and get deallocated (even the native part). - BOOL Next(CollectibleAssemblyHolder * pDomainAssemblyHolder); + BOOL Next(CollectibleAssemblyHolder * pAssemblyHolder); MethodDesc *Current(); void Start(AppDomain * pAppDomain, Module *pModule, diff --git a/src/coreclr/vm/multicorejit.cpp b/src/coreclr/vm/multicorejit.cpp index bac039f9d0908..ab6d2e65fc74e 100644 --- a/src/coreclr/vm/multicorejit.cpp +++ b/src/coreclr/vm/multicorejit.cpp @@ -786,12 +786,12 @@ HRESULT MulticoreJitModuleEnumerator::EnumerateLoadedModules(AppDomain * pDomain AppDomain::AssemblyIterator appIt = pDomain->IterateAssembliesEx((AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (appIt.Next(pDomainAssembly.This()) && SUCCEEDED(hr)) + while (appIt.Next(pAssembly.This()) && SUCCEEDED(hr)) { { - hr = HandleAssembly(pDomainAssembly->GetAssembly()); + hr = HandleAssembly(pAssembly); } } diff --git a/src/coreclr/vm/perfmap.cpp b/src/coreclr/vm/perfmap.cpp index 2d823e546fca5..1f515b00922ee 100644 --- a/src/coreclr/vm/perfmap.cpp +++ b/src/coreclr/vm/perfmap.cpp @@ -108,11 +108,9 @@ void PerfMap::Enable(PerfMapType type, bool sendExisting) { AppDomain::AssemblyIterator assemblyIterator = GetAppDomain()->IterateAssembliesEx( (AssemblyIterationFlags)(kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; - while (assemblyIterator.Next(pDomainAssembly.This())) + CollectibleAssemblyHolder pAssembly; + while (assemblyIterator.Next(pAssembly.This())) { - CollectibleAssemblyHolder pAssembly = pDomainAssembly->GetAssembly(); - // PerfMap does not log R2R methods so only proceed if we are emitting jitdumps if (type == PerfMapType::ALL || type == PerfMapType::JITDUMP) { diff --git a/src/coreclr/vm/profilingenumerators.cpp b/src/coreclr/vm/profilingenumerators.cpp index b0741dcefe71f..f214be043f0bf 100644 --- a/src/coreclr/vm/profilingenumerators.cpp +++ b/src/coreclr/vm/profilingenumerators.cpp @@ -302,18 +302,14 @@ HRESULT IterateUnsharedModules(AppDomain * pAppDomain, // earlier during FILE_LOAD_LOADLIBRARY. This does not affect the timeline, as either // way the profiler receives the notification AFTER the assembly would appear in the // enumeration. - // - // Although it's called an "AssemblyIterator", it actually iterates over - // DomainAssembly instances. - AppDomain::AssemblyIterator domainAssemblyIterator = + AppDomain::AssemblyIterator assemblyIterator = pAppDomain->IterateAssembliesEx( (AssemblyIterationFlags) (kIncludeAvailableToProfilers | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + CollectibleAssemblyHolder pAssembly; - while (domainAssemblyIterator.Next(pDomainAssembly.This())) + while (assemblyIterator.Next(pAssembly.This())) { - _ASSERTE(pDomainAssembly != NULL); - _ASSERTE(pDomainAssembly->GetAssembly() != NULL); + _ASSERTE(pAssembly != NULL); // #ProfilerEnumModules (See also code:#ProfilerEnumGeneral) // @@ -327,7 +323,7 @@ HRESULT IterateUnsharedModules(AppDomain * pAppDomain, // code:#ProfilerEnumAssemblies for info on how the timing works. // Call user-supplied callback, and cancel iteration if requested - HRESULT hr = (callbackObj->*callbackMethod)(pDomainAssembly->GetModule()); + HRESULT hr = (callbackObj->*callbackMethod)(pAssembly->GetModule()); if (hr != S_OK) { return hr; diff --git a/src/coreclr/vm/rejit.cpp b/src/coreclr/vm/rejit.cpp index 01d03666546ef..689e30d7d8364 100644 --- a/src/coreclr/vm/rejit.cpp +++ b/src/coreclr/vm/rejit.cpp @@ -731,15 +731,14 @@ HRESULT ReJitManager::UpdateNativeInlinerActiveILVersions( // Iterate through all modules, for any that are NGEN or R2R need to check if there are inliners there and call // RequestReJIT on them - AppDomain::AssemblyIterator domainAssemblyIterator = SystemDomain::System()->DefaultDomain()->IterateAssembliesEx((AssemblyIterationFlags) (kIncludeLoaded | kIncludeExecution)); - CollectibleAssemblyHolder pDomainAssembly; + AppDomain::AssemblyIterator assemblyIterator = AppDomain::GetCurrentDomain()->IterateAssembliesEx((AssemblyIterationFlags) (kIncludeLoaded | kIncludeExecution)); + CollectibleAssemblyHolder pAssembly; NativeImageInliningIterator inlinerIter; - while (domainAssemblyIterator.Next(pDomainAssembly.This())) + while (assemblyIterator.Next(pAssembly.This())) { - _ASSERTE(pDomainAssembly != NULL); - _ASSERTE(pDomainAssembly->GetAssembly() != NULL); + _ASSERTE(pAssembly != NULL); - Module * pModule = pDomainAssembly->GetModule(); + Module * pModule = pAssembly->GetModule(); if (pModule->HasReadyToRunInlineTrackingMap()) { inlinerIter.Reset(pModule, MethodInModule(pInlineeModule, inlineeMethodDef));