Skip to content

Commit

Permalink
Move more helpers from DomainAssembly to Assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Oct 5, 2024
1 parent 3bcaadb commit d03738f
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 136 deletions.
26 changes: 13 additions & 13 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ void DacDbiInterfaceImpl::GetCompilerFlags (
}

// Get the underlying module - none of this is AppDomain specific
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();
DWORD dwBits = pModule->GetDebuggerInfoBits();
*pfAllowJITOpts = !CORDisableJITOptimizations(dwBits);
*pfEnableEnC = pModule->IsEditAndContinueEnabled();
Expand Down Expand Up @@ -721,7 +721,7 @@ HRESULT DacDbiInterfaceImpl::SetCompilerFlags(VMPTR_DomainAssembly vmDomainAssem

DWORD dwBits = 0;
DomainAssembly * pDomainAssembly = vmDomainAssembly.GetDacPtr();
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();
HRESULT hr = S_OK;


Expand Down Expand Up @@ -821,7 +821,7 @@ SIZE_T DacDbiInterfaceImpl::GetArgCount(MethodDesc * pMD)
return 0;
}

MetaSig msig(pCallSig, cbCallSigSize, pMD->GetModule(), NULL, MetaSig::sigMember);
MetaSig msig(pCallSig, cbCallSigSize, pMD->GetAssembly()->GetModule(), NULL, MetaSig::sigMember);

// Get the arg count.
UINT32 NumArguments = msig.NumFixedArgs();
Expand Down Expand Up @@ -1019,7 +1019,7 @@ void DacDbiInterfaceImpl::GetSequencePoints(MethodDesc * pMethodDesc,
#endif
// if there is a profiler load-time mapping and not a rejit mapping, apply that instead
InstrumentedILOffsetMapping loadTimeMapping =
pMethodDesc->GetModule()->GetInstrumentedILOffsetMapping(pMethodDesc->GetMemberDef());
pMethodDesc->GetAssembly()->GetModule()->GetInstrumentedILOffsetMapping(pMethodDesc->GetMemberDef());
ComposeMapping(&loadTimeMapping, mapCopy, &entryCount);
#ifdef FEATURE_REJIT
}
Expand Down Expand Up @@ -1091,7 +1091,7 @@ void DacDbiInterfaceImpl::GetILCodeAndSig(VMPTR_DomainAssembly vmDomainAssembly,
DD_ENTER_MAY_THROW;

DomainAssembly * pDomainAssembly = vmDomainAssembly.GetDacPtr();
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();
RVA methodRVA = 0;
DWORD implFlags;

Expand Down Expand Up @@ -1330,7 +1330,7 @@ void DacDbiInterfaceImpl::GetNativeCodeInfo(VMPTR_DomainAssembly vmDomai
pCodeInfo->Clear();

DomainAssembly * pDomainAssembly = vmDomainAssembly.GetDacPtr();
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();

MethodDesc* pMethodDesc = FindLoadedMethodRefOrDef(pModule, functionToken);
pCodeInfo->vmNativeCodeMethodDescToken.SetHostPtr(pMethodDesc);
Expand Down Expand Up @@ -2866,7 +2866,7 @@ TypeHandle DacDbiInterfaceImpl::GetClassOrValueTypeHandle(DebuggerIPCE_BasicType
else
{
DomainAssembly * pDomainAssembly = pData->vmDomainAssembly.GetDacPtr();
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();

typeHandle = ClassLoader::LookupTypeDefOrRefInModule(pModule, pData->metadataToken);
if (typeHandle.IsNull())
Expand Down Expand Up @@ -3842,7 +3842,7 @@ FieldDesc * DacDbiInterfaceImpl::GetEnCFieldDesc(const EnCHangingFieldInfo * pEn
FieldDesc * pFD = NULL;

DomainAssembly * pDomainAssembly = pEnCFieldInfo->GetObjectTypeData().vmDomainAssembly.GetDacPtr();
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();

// get the type handle for the object
TypeHandle typeHandle = ClassLoader::LookupTypeDefOrRefInModule(pModule,
Expand Down Expand Up @@ -3881,7 +3881,7 @@ PTR_CBYTE DacDbiInterfaceImpl::GetPtrToEnCField(FieldDesc * pFD, const EnCHangin

PTR_EditAndContinueModule pEnCModule;
DomainAssembly * pDomainAssembly = pEnCFieldInfo->GetObjectTypeData().vmDomainAssembly.GetDacPtr();
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();

// make sure we actually have an EditAndContinueModule
_ASSERTE(pModule->IsEditAndContinueCapable());
Expand Down Expand Up @@ -4053,7 +4053,7 @@ void DacDbiInterfaceImpl::ResolveTypeReference(const TypeRefData * pTypeRefInfo,
{
DD_ENTER_MAY_THROW;
DomainAssembly * pDomainAssembly = pTypeRefInfo->vmDomainAssembly.GetDacPtr();
Module * pReferencingModule = pDomainAssembly->GetModule();
Module * pReferencingModule = pDomainAssembly->GetAssembly()->GetModule();
BOOL fSuccess = FALSE;

// Resolve the type ref
Expand Down Expand Up @@ -4317,7 +4317,7 @@ void DacDbiInterfaceImpl::GetModuleForDomainAssembly(VMPTR_DomainAssembly vmDoma
_ASSERTE(pModule != NULL);

DomainAssembly * pDomainAssembly = vmDomainAssembly.GetDacPtr();
pModule->SetHostPtr(pDomainAssembly->GetModule());
pModule->SetHostPtr(pDomainAssembly->GetAssembly()->GetModule());
}


Expand Down Expand Up @@ -4446,7 +4446,7 @@ void DacDbiInterfaceImpl::EnumerateModulesInAssembly(
DomainAssembly * pDomainAssembly = vmAssembly.GetDacPtr();

// Debugger isn't notified of Resource / Inspection-only modules.
if (pDomainAssembly->GetModule()->IsVisibleToDebugger())
if (pDomainAssembly->GetAssembly()->GetModule()->IsVisibleToDebugger())
{
// If domain assembly isn't yet loaded, just return
if (!pDomainAssembly->GetAssembly()->IsLoaded())
Expand All @@ -4469,7 +4469,7 @@ VMPTR_DomainAssembly DacDbiInterfaceImpl::ResolveAssembly(


DomainAssembly * pDomainAssembly = vmScope.GetDacPtr();
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();

VMPTR_DomainAssembly vmDomainAssembly = VMPTR_DomainAssembly::NullPtr();

Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5134,8 +5134,8 @@ DebuggerModule * Debugger::LookupOrCreateModule(DomainAssembly * pDomainAssembly
{
_ASSERTE(pDomainAssembly != NULL);
LOG((LF_CORDB, LL_INFO1000, "D::LOCM df=%p\n", pDomainAssembly));
DebuggerModule * pDModule = LookupOrCreateModule(pDomainAssembly->GetModule());
LOG((LF_CORDB, LL_INFO1000, "D::LOCM m=%p ad=%p -> dm=%p\n", pDomainAssembly->GetModule(), AppDomain::GetCurrentDomain(), pDModule));
DebuggerModule * pDModule = LookupOrCreateModule(pDomainAssembly->GetAssembly()->GetModule());
LOG((LF_CORDB, LL_INFO1000, "D::LOCM m=%p ad=%p -> dm=%p\n", pDomainAssembly->GetAssembly()->GetModule(), AppDomain::GetCurrentDomain(), pDModule));
_ASSERTE(pDModule != NULL);
_ASSERTE(pDModule->GetDomainAssembly() == pDomainAssembly);

Expand Down Expand Up @@ -5235,7 +5235,7 @@ DebuggerModule* Debugger::AddDebuggerModule(DomainAssembly * pDomainAssembly)
LOG((LF_CORDB, LL_INFO1000, "D::ADM df=0x%x\n", pDomainAssembly));
DebuggerDataLockHolder chInfo(this);

Module * pRuntimeModule = pDomainAssembly->GetModule();
Module * pRuntimeModule = pDomainAssembly->GetAssembly()->GetModule();

HRESULT hr = CheckInitModuleTable();
IfFailThrow(hr);
Expand Down Expand Up @@ -8041,7 +8041,7 @@ BOOL Debugger::ShouldSendCustomNotification(DomainAssembly *pAssembly, mdTypeDef
}
CONTRACTL_END;

Module *pModule = pAssembly->GetModule();
Module *pModule = pAssembly->GetAssembly()->GetModule();
TypeInModule tim(pModule, typeDef);
return !(m_pCustomNotificationTable->Lookup(tim).IsNull());
}
Expand Down Expand Up @@ -9402,7 +9402,7 @@ void Debugger::LoadModule(Module* pRuntimeModule,
// We should simply things when we actually get rid of DebuggerModule, possibly by just passing the
// DomainAssembly around.
_ASSERTE(module->GetDomainAssembly() == pDomainAssembly);
_ASSERTE(module->GetRuntimeModule() == pDomainAssembly->GetModule());
_ASSERTE(module->GetRuntimeModule() == pDomainAssembly->GetAssembly()->GetModule());

// Send a load module event to the Right Side.
ipce = m_pRCThread->GetIPCEventSendBuffer();
Expand Down Expand Up @@ -10830,7 +10830,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
// unexpected in an OOM situation. Quickly just sanity check them.
//
Thread * pThread = pEvent->SetIP.vmThreadToken.GetRawPtr();
Module * pModule = pEvent->SetIP.vmDomainAssembly.GetRawPtr()->GetModule();
Module * pModule = pEvent->SetIP.vmDomainAssembly.GetRawPtr()->GetAssembly()->GetModule();

// Get the DJI for this function
DebuggerMethodInfo * pDMI = GetOrCreateMethodInfo(pModule, pEvent->SetIP.mdMethod);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,7 @@ Assembly *AppDomain::LoadAssemblyInternal(AssemblySpec* pIdentity,

// Set the assembly module to be tenured now that we know it won't be deleted
pDomainAssembly->GetAssembly()->SetIsTenured();
if (pDomainAssembly->IsCollectible())
if (pDomainAssembly->GetAssembly()->IsCollectible())
{
// We add the assembly to the LoaderAllocator only when we are sure that it can be added
// and won't be deleted in case of a concurrent load from the same ALC
Expand Down 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
4 changes: 2 additions & 2 deletions src/coreclr/vm/appdomain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,12 @@ class CollectibleAssemblyHolderBase
LoaderAllocator * GetLoaderAllocator(DomainAssembly * pDomainAssembly)
{
WRAPPER_NO_CONTRACT;
return pDomainAssembly->GetLoaderAllocator();
return pDomainAssembly->GetAssembly()->GetLoaderAllocator();
}
BOOL IsCollectible(DomainAssembly * pDomainAssembly)
{
WRAPPER_NO_CONTRACT;
return pDomainAssembly->IsCollectible();
return pDomainAssembly->GetAssembly()->IsCollectible();
}
LoaderAllocator * GetLoaderAllocator(Assembly * pAssembly)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ Assembly *Assembly::CreateDynamic(AssemblyBinder* pBinder, NativeAssemblyNamePar
pDomainAssembly = new DomainAssembly(pPEAssembly, pLoaderAllocator, pamTracker);
pAssem = pDomainAssembly->GetAssembly();
pAssem->m_isDynamic = true;
if (pDomainAssembly->IsCollectible())
if (pAssem->IsCollectible())
{
// We add the assembly to the LoaderAllocator only when we are sure that it can be added
// and won't be deleted in case of a concurrent load from the same ALC
Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2917,7 +2917,7 @@ BOOL Module::NotifyDebuggerLoad(DomainAssembly * pDomainAssembly, int flags, BOO
// Always capture metadata, even if no debugger is attached. If a debugger later attaches, it will use
// this data.
{
Module * pModule = pDomainAssembly->GetModule();
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();
pModule->UpdateDynamicMetadataIfNeeded();
}

Expand Down 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
44 changes: 2 additions & 42 deletions src/coreclr/vm/domainassembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
#ifndef DACCESS_COMPILE
DomainAssembly::DomainAssembly(PEAssembly* pPEAssembly, LoaderAllocator* pLoaderAllocator, AllocMemTracker* memTracker)
: m_pAssembly(NULL)
, m_pPEAssembly(pPEAssembly)
, m_pModule(NULL)
, m_fCollectible(pLoaderAllocator->IsCollectible())
, m_NextDomainAssemblyInSameALC(NULL)
, m_pLoaderAllocator(pLoaderAllocator)
{
CONTRACTL
{
Expand All @@ -48,12 +43,11 @@ DomainAssembly::DomainAssembly(PEAssembly* pPEAssembly, LoaderAllocator* pLoader
NewHolder<Assembly> assembly = Assembly::Create(pPEAssembly, memTracker, pLoaderAllocator);

m_pAssembly = assembly.Extract();
m_pModule = m_pAssembly->GetModule();

m_pAssembly->SetDomainAssembly(this);

// Creating the Assembly should have ensured the PEAssembly is loaded
_ASSERT(GetPEAssembly()->IsLoaded());
_ASSERT(m_pAssembly->GetPEAssembly()->IsLoaded());
}

DomainAssembly::~DomainAssembly()
Expand All @@ -67,8 +61,6 @@ DomainAssembly::~DomainAssembly()
}
CONTRACTL_END;

m_pPEAssembly->Release();

if (m_pAssembly != NULL)
{
delete m_pAssembly;
Expand Down Expand Up @@ -648,7 +640,7 @@ BOOL Assembly::NotifyDebuggerLoad(int flags, BOOL attaching)

if( ShouldNotifyDebugger())
{
result|=m_pModule->NotifyDebuggerLoad(GetDomainAssembly(), ATTACH_MODULE_LOAD, attaching);
result |= m_pModule->NotifyDebuggerLoad(GetDomainAssembly(), ATTACH_MODULE_LOAD, attaching);
SetDebuggerNotified();
}

Expand All @@ -670,35 +662,3 @@ void Assembly::NotifyDebuggerUnload()
}

#endif // #ifndef DACCESS_COMPILE

#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_pPEAssembly.IsValid())
{
m_pPEAssembly->EnumMemoryRegions(flags);
}

if (flags == CLRDATA_ENUM_MEM_HEAP2)
{
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
Loading

0 comments on commit d03738f

Please sign in to comment.