Skip to content

Commit

Permalink
try2: EnumMemoryRegion removal
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Oct 6, 2024
1 parent 34bf77c commit 8a6f881
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4427,7 +4427,7 @@ AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, bool enumThis)

while (assem.Next(pAssembly.This()))
{
pAssembly->GetDomainAssembly()->EnumMemoryRegions(flags);
pAssembly->EnumMemoryRegions(flags);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Assembly::Assembly(PEAssembly* pPEAssembly, LoaderAllocator *pLoaderAllocator)
#endif
, m_debuggerFlags{DACF_NONE}
, m_hExposedObject{}
, m_NextAssemblyInSameALC(NULL)
{
CONTRACTL
{
Expand Down
14 changes: 13 additions & 1 deletion src/coreclr/vm/assembly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,20 @@ class Assembly
m_debuggerFlags = flags;
}

DomainAssembly* GetNextAssemblyInSameALC()
{
return m_NextAssemblyInSameALC;
}

void SetNextAssemblyInSameALC(DomainAssembly* assembly)
{
_ASSERTE(m_NextAssemblyInSameALC == NULL);
m_NextAssemblyInSameALC = assembly;
}

private:
DebuggerAssemblyControlFlags ComputeDebuggingConfig(void);
HRESULT GetDebuggingCustomAttributes(DWORD* pdwFlags);

public:
// On failure:
// if loadFlag == Loader::Load => throw
Expand Down Expand Up @@ -530,6 +540,8 @@ class Assembly
DebuggerAssemblyControlFlags m_debuggerFlags;

LOADERHANDLE m_hExposedObject;

DomainAssembly* m_NextAssemblyInSameALC;
};

#ifndef DACCESS_COMPILE
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4502,10 +4502,6 @@ void Module::EnumMemoryRegions(CLRDataEnumMemoryFlags flags,
EMEM_OUT(("MEM: %p Module\n", dac_cast<TADDR>(this)));
}

if (m_pDomainAssembly.IsValid())
{
m_pDomainAssembly->EnumMemoryRegions(flags);
}
if (m_pPEAssembly.IsValid())
{
m_pPEAssembly->EnumMemoryRegions(flags);
Expand Down
33 changes: 0 additions & 33 deletions src/coreclr/vm/domainassembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#ifndef DACCESS_COMPILE
DomainAssembly::DomainAssembly(PEAssembly* pPEAssembly, LoaderAllocator* pLoaderAllocator, AllocMemTracker* memTracker)
: m_pAssembly(NULL)
, m_NextDomainAssemblyInSameALC(NULL)
{
CONTRACTL
{
Expand Down Expand Up @@ -668,35 +667,3 @@ PEAssembly* DomainAssembly::GetPEAssembly()
{
return PTR_PEAssembly(m_pAssembly->GetPEAssembly());
}

#ifdef DACCESS_COMPILE

void DomainAssembly::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
{
SUPPORTS_DAC;

DAC_ENUM_DTHIS();

// Modules are needed for all minidumps, but they are enumerated elsewhere
// so we don't need to duplicate effort; thus we do noting with m_pModule.

// For MiniDumpNormal, we only want the file name.
if (m_pAssembly->GetPEAssembly().IsValid())
{
m_pAssembly->GetPEAssembly()->EnumMemoryRegions(flags);
}

if (flags == CLRDATA_ENUM_MEM_HEAP2)
{
m_pAssembly->GetLoaderAllocator()->EnumMemoryRegions(flags);
}
else if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE)
{
if (m_pAssembly.IsValid())
{
m_pAssembly->EnumMemoryRegions(flags);
}
}
}

#endif // #ifdef DACCESS_COMPILE
26 changes: 2 additions & 24 deletions src/coreclr/vm/domainassembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class DomainAssembly final
DomainAssembly() {LIMITED_METHOD_CONTRACT;};
#endif

PEAssembly *GetPEAssembly();
PEAssembly* GetPEAssembly();

Assembly* GetAssembly()
{
Expand All @@ -77,27 +77,7 @@ class DomainAssembly final
return m_pAssembly;
}

#ifndef DACCESS_COMPILE
BOOL Equals(DomainAssembly *pAssembly) { WRAPPER_NO_CONTRACT; return GetPEAssembly()->Equals(pAssembly->GetPEAssembly()); }
BOOL Equals(PEAssembly *pPEAssembly) { WRAPPER_NO_CONTRACT; return GetPEAssembly()->Equals(pPEAssembly); }
#endif // DACCESS_COMPILE

#ifdef DACCESS_COMPILE
void EnumMemoryRegions(CLRDataEnumMemoryFlags flags);
#endif

DomainAssembly* GetNextDomainAssemblyInSameALC()
{
return m_NextDomainAssemblyInSameALC;
}

void SetNextDomainAssemblyInSameALC(DomainAssembly* domainAssembly)
{
_ASSERTE(m_NextDomainAssemblyInSameALC == NULL);
m_NextDomainAssemblyInSameALC = domainAssembly;
}

private:
private:
// ------------------------------------------------------------
// Loader API
// ------------------------------------------------------------
Expand All @@ -107,9 +87,7 @@ class DomainAssembly final

DomainAssembly(PEAssembly* pPEAssembly, LoaderAllocator* pLoaderAllocator, AllocMemTracker* memTracker);

private:
PTR_Assembly m_pAssembly;
DomainAssembly* m_NextDomainAssemblyInSameALC;
};

#endif // _DOMAINASSEMBLY_H_
4 changes: 2 additions & 2 deletions src/coreclr/vm/loaderallocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1704,13 +1704,13 @@ BOOL AssemblyLoaderAllocator::CanUnload()
DomainAssemblyIterator::DomainAssemblyIterator(DomainAssembly* pFirstAssembly)
{
pCurrentAssembly = pFirstAssembly;
pNextAssembly = pCurrentAssembly ? pCurrentAssembly->GetNextDomainAssemblyInSameALC() : NULL;
pNextAssembly = pCurrentAssembly ? pCurrentAssembly->GetAssembly()->GetNextAssemblyInSameALC() : NULL;
}

void DomainAssemblyIterator::operator++()
{
pCurrentAssembly = pNextAssembly;
pNextAssembly = pCurrentAssembly ? pCurrentAssembly->GetNextDomainAssemblyInSameALC() : NULL;
pNextAssembly = pCurrentAssembly ? pCurrentAssembly->GetAssembly()->GetNextAssemblyInSameALC() : NULL;
}

#ifndef DACCESS_COMPILE
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/loaderallocator.inl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline void LoaderAllocatorID::AddDomainAssembly(DomainAssembly* pAssembly)
// Link domain assembly together
if (m_pDomainAssembly != NULL)
{
pAssembly->SetNextDomainAssemblyInSameALC(m_pDomainAssembly);
pAssembly->GetAssembly()->SetNextAssemblyInSameALC(m_pDomainAssembly);
}
m_pDomainAssembly = pAssembly;
}
Expand Down

0 comments on commit 8a6f881

Please sign in to comment.