Skip to content

Commit d603356

Browse files
authored
More cleanups in assembly loader area (#63157)
* GetManifestFile() --> GetPEAssembly() * GetManifestImport() -> GetMDImport() * removed GetCurrentAssembly(), GetLoadedAssembly() * removed GetCurrentModule(), GetLoadedModule() * fix * removed DomainFile::ModuleIterator * renamed Assembly::GetManifestModule() --> GetModule() * Removed Assembly::ModuleIterator * move most fields off DomainAssembly * DomainAssembly is a complete proxy * some DomainFile --> DomainAssembly renames. * deleted DomainFile class * renamed files * a few minor cleanups * DomainAssembly does not need to have VPTR_. Couple other changes. * More DomainFile --> DomainAssembly renames * More DomainFile --> DomainAssembly renames * a few more renames * removed domainassembly.inl * domainassembly.h cleanup * make gcc happy * couple more changes * fixed build after rebasing * PR feedback * more PR feedback
1 parent 9122424 commit d603356

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1743
-2452
lines changed

src/coreclr/debug/daccess/dacdbiimpl.cpp

Lines changed: 66 additions & 78 deletions
Large diffs are not rendered by default.

src/coreclr/debug/daccess/dacdbiimpl.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ class DacDbiInterfaceImpl :
9696
IStringHolder * pStrName);
9797

9898
// Get the values of the JIT Optimization and EnC flags.
99-
void GetCompilerFlags (VMPTR_DomainFile vmDomainFile,
99+
void GetCompilerFlags (VMPTR_DomainAssembly vmDomainAssembly,
100100
BOOL * pfAllowJITOpts,
101101
BOOL * pfEnableEnC);
102102

103103
// Helper function for SetCompilerFlags to set EnC status
104104
bool CanSetEnCBits(Module * pModule);
105105

106106
// Set the values of the JIT optimization and EnC flags.
107-
HRESULT SetCompilerFlags(VMPTR_DomainFile vmDomainFile,
107+
HRESULT SetCompilerFlags(VMPTR_DomainAssembly vmDomainAssembly,
108108
BOOL fAllowJitOpts,
109109
BOOL fEnableEnC);
110110

@@ -133,7 +133,7 @@ class DacDbiInterfaceImpl :
133133

134134
bool IsValidObject(CORDB_ADDRESS obj);
135135

136-
bool GetAppDomainForObject(CORDB_ADDRESS obj, OUT VMPTR_AppDomain * pApp, OUT VMPTR_Module *pModule, OUT VMPTR_DomainFile *mod);
136+
bool GetAppDomainForObject(CORDB_ADDRESS obj, OUT VMPTR_AppDomain * pApp, OUT VMPTR_Module *pModule, OUT VMPTR_DomainAssembly *mod);
137137

138138

139139

@@ -218,7 +218,7 @@ class DacDbiInterfaceImpl :
218218
// a module and a token. The info will come from a MethodDesc, if
219219
// one exists or from metadata.
220220
//
221-
void GetILCodeAndSig(VMPTR_DomainFile vmDomainFile,
221+
void GetILCodeAndSig(VMPTR_DomainAssembly vmDomainAssembly,
222222
mdToken functionToken,
223223
TargetBuffer * pCodeInfo,
224224
mdToken * pLocalSigToken);
@@ -229,7 +229,7 @@ class DacDbiInterfaceImpl :
229229
// whether it's an instantiated generic
230230
// its EnC version number
231231
// hot and cold region information.
232-
void GetNativeCodeInfo(VMPTR_DomainFile vmDomainFile,
232+
void GetNativeCodeInfo(VMPTR_DomainAssembly vmDomainAssembly,
233233
mdToken functionToken,
234234
NativeCodeFunctionData * pCodeInfo);
235235

@@ -260,7 +260,7 @@ class DacDbiInterfaceImpl :
260260
ClassInfo * pData);
261261

262262
// get field information and object size for an instantiated generic type
263-
void GetInstantiationFieldInfo (VMPTR_DomainFile vmDomainFile,
263+
void GetInstantiationFieldInfo (VMPTR_DomainAssembly vmDomainAssembly,
264264
VMPTR_TypeHandle vmThExact,
265265
VMPTR_TypeHandle vmThApprox,
266266
DacDbiArrayList<FieldData> * pFieldList,
@@ -336,7 +336,7 @@ class DacDbiInterfaceImpl :
336336
CorElementType simpleType,
337337
mdTypeDef * pMetadataToken,
338338
VMPTR_Module * pVmModule,
339-
VMPTR_DomainFile * pVmDomainFile);
339+
VMPTR_DomainAssembly * pVmDomainAssembly);
340340

341341
BOOL IsExceptionObject(VMPTR_Object vmObject);
342342

@@ -352,7 +352,7 @@ class DacDbiInterfaceImpl :
352352
HRESULT GetDelegateFunctionData(
353353
DelegateType delegateType,
354354
VMPTR_Object delegateObject,
355-
OUT VMPTR_DomainFile *ppFunctionDomainFile,
355+
OUT VMPTR_DomainAssembly *ppFunctionDomainAssembly,
356356
OUT mdMethodDef *pMethodDef);
357357

358358
HRESULT GetDelegateTargetObject(
@@ -730,10 +730,10 @@ class DacDbiInterfaceImpl :
730730
// Gets properties for a module
731731
void GetModuleData(VMPTR_Module vmModule, ModuleInfo * pData);
732732

733-
// Gets properties for a domainfile
734-
void GetDomainFileData(VMPTR_DomainFile vmDomainFile, DomainFileInfo * pData);
733+
// Gets properties for a domain assembly
734+
void GetDomainAssemblyData(VMPTR_DomainAssembly vmDomainAssembly, DomainAssemblyInfo * pData);
735735

736-
void GetModuleForDomainFile(VMPTR_DomainFile vmDomainFile, OUT VMPTR_Module * pModule);
736+
void GetModuleForDomainAssembly(VMPTR_DomainAssembly vmDomainAssembly, OUT VMPTR_Module * pModule);
737737

738738
// Yields true if the address is a CLR stub.
739739
BOOL IsTransitionStub(CORDB_ADDRESS address);
@@ -829,8 +829,8 @@ class DacDbiInterfaceImpl :
829829
// Return the current appdomain the specified thread is in.
830830
VMPTR_AppDomain GetCurrentAppDomain(VMPTR_Thread vmThread);
831831

832-
// Given an assembly ref token and metadata scope (via the DomainFile), resolve the assembly.
833-
VMPTR_DomainAssembly ResolveAssembly(VMPTR_DomainFile vmScope, mdToken tkAssemblyRef);
832+
// Given an assembly ref token and metadata scope (via the DomainAssembly), resolve the assembly.
833+
VMPTR_DomainAssembly ResolveAssembly(VMPTR_DomainAssembly vmScope, mdToken tkAssemblyRef);
834834

835835

836836
// Hijack the thread

src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,22 +514,22 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread
514514
#endif // FEATURE_COMINTEROP
515515

516516
Module * pModule = (pMD ? pMD->GetModule() : NULL);
517-
DomainFile * pDomainFile = (pModule ? pModule->GetDomainFile() : NULL);
517+
DomainAssembly * pDomainAssembly = (pModule ? pModule->GetDomainAssembly() : NULL);
518518

519519
if (frameData.stubFrame.frameType == STUBFRAME_FUNC_EVAL)
520520
{
521521
FuncEvalFrame * pFEF = dac_cast<PTR_FuncEvalFrame>(pFrame);
522522
DebuggerEval * pDE = pFEF->GetDebuggerEval();
523523

524524
frameData.stubFrame.funcMetadataToken = pDE->m_methodToken;
525-
frameData.stubFrame.vmDomainFile.SetHostPtr(
526-
pDE->m_debuggerModule ? pDE->m_debuggerModule->GetDomainFile() : NULL);
525+
frameData.stubFrame.vmDomainAssembly.SetHostPtr(
526+
pDE->m_debuggerModule ? pDE->m_debuggerModule->GetDomainAssembly() : NULL);
527527
frameData.stubFrame.vmMethodDesc = VMPTR_MethodDesc::NullPtr();
528528
}
529529
else
530530
{
531531
frameData.stubFrame.funcMetadataToken = (pMD == NULL ? NULL : pMD->GetMemberDef());
532-
frameData.stubFrame.vmDomainFile.SetHostPtr(pDomainFile);
532+
frameData.stubFrame.vmDomainAssembly.SetHostPtr(pDomainAssembly);
533533
frameData.stubFrame.vmMethodDesc.SetHostPtr(pMD);
534534
}
535535

@@ -702,11 +702,11 @@ void DacDbiInterfaceImpl::InitFrameData(StackFrameIterator * pIter,
702702
// Although MiniDumpNormal tries to dump all AppDomains, it's possible
703703
// target corruption will keep one from being present. This should mean
704704
// we'll just fail later, but struggle on for now.
705-
DomainFile *pDomainFile = NULL;
705+
DomainAssembly *pDomainAssembly = NULL;
706706
EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY
707707
{
708-
pDomainFile = (pModule ? pModule->GetDomainFile() : NULL);
709-
_ASSERTE(pDomainFile != NULL);
708+
pDomainAssembly = (pModule ? pModule->GetDomainAssembly() : NULL);
709+
_ASSERTE(pDomainAssembly != NULL);
710710
}
711711
EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY
712712

@@ -783,7 +783,7 @@ void DacDbiInterfaceImpl::InitFrameData(StackFrameIterator * pIter,
783783
//
784784

785785
pFuncData->funcMetadataToken = pMD->GetMemberDef();
786-
pFuncData->vmDomainFile.SetHostPtr(pDomainFile);
786+
pFuncData->vmDomainAssembly.SetHostPtr(pDomainAssembly);
787787

788788
// PERF: this is expensive to get so I stopped fetching it eagerly
789789
// It is only needed if we haven't already got a cached copy

src/coreclr/debug/daccess/dacimpl.h

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ struct ProcessModIter
506506
bool m_nextDomain;
507507
AppDomain::AssemblyIterator m_assemIter;
508508
Assembly* m_curAssem;
509-
Assembly::ModuleIterator m_modIter;
510509

511510
ProcessModIter(void)
512511
: m_domainIter(FALSE)
@@ -542,7 +541,7 @@ struct ProcessModIter
542541
}
543542

544543
// Note: DAC doesn't need to keep the assembly alive - see code:CollectibleAssemblyHolder#CAH_DAC
545-
CollectibleAssemblyHolder<Assembly *> pAssembly = pDomainAssembly->GetLoadedAssembly();
544+
CollectibleAssemblyHolder<Assembly *> pAssembly = pDomainAssembly->GetAssembly();
546545
return pAssembly;
547546
}
548547
return NULL;
@@ -551,27 +550,13 @@ struct ProcessModIter
551550
Module* NextModule(void)
552551
{
553552
SUPPORTS_DAC;
554-
for (;;)
553+
m_curAssem = NextAssem();
554+
if (!m_curAssem)
555555
{
556-
if (!m_curAssem)
557-
{
558-
m_curAssem = NextAssem();
559-
if (!m_curAssem)
560-
{
561-
return NULL;
562-
}
563-
564-
m_modIter = m_curAssem->IterateModules();
565-
}
566-
567-
if (!m_modIter.Next())
568-
{
569-
m_curAssem = NULL;
570-
continue;
571-
}
572-
573-
return m_modIter.GetModule();
556+
return NULL;
574557
}
558+
559+
return m_curAssem->GetModule();
575560
}
576561
};
577562

src/coreclr/debug/daccess/request.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,10 +2607,7 @@ ClrDataAccess::GetAssemblyData(CLRDATA_ADDRESS cdBaseDomainPtr, CLRDATA_ADDRESS
26072607
assemblyData->ModuleCount = 0;
26082608
assemblyData->isDomainNeutral = FALSE;
26092609

2610-
pAssembly->GetManifestFile();
2611-
2612-
ModuleIterator mi = pAssembly->IterateModules();
2613-
while (mi.Next())
2610+
if (pAssembly->GetModule())
26142611
{
26152612
assemblyData->ModuleCount++;
26162613
}
@@ -2628,17 +2625,17 @@ ClrDataAccess::GetAssemblyName(CLRDATA_ADDRESS assembly, unsigned int count, _In
26282625
if (name)
26292626
name[0] = 0;
26302627

2631-
if (!pAssembly->GetManifestFile()->GetPath().IsEmpty())
2628+
if (!pAssembly->GetPEAssembly()->GetPath().IsEmpty())
26322629
{
2633-
if (!pAssembly->GetManifestFile()->GetPath().DacGetUnicode(count, name, pNeeded))
2630+
if (!pAssembly->GetPEAssembly()->GetPath().DacGetUnicode(count, name, pNeeded))
26342631
hr = E_FAIL;
26352632
else if (name)
26362633
name[count-1] = 0;
26372634
}
2638-
else if (!pAssembly->GetManifestFile()->IsDynamic())
2635+
else if (!pAssembly->GetPEAssembly()->IsDynamic())
26392636
{
26402637
StackSString displayName;
2641-
pAssembly->GetManifestFile()->GetDisplayName(displayName, 0);
2638+
pAssembly->GetPEAssembly()->GetDisplayName(displayName, 0);
26422639

26432640
const WCHAR *val = displayName.GetUnicode();
26442641

@@ -2673,9 +2670,9 @@ ClrDataAccess::GetAssemblyLocation(CLRDATA_ADDRESS assembly, int count, _Inout_u
26732670
Assembly* pAssembly = PTR_Assembly(TO_TADDR(assembly));
26742671

26752672
// Turn from bytes to wide characters
2676-
if (!pAssembly->GetManifestFile()->GetPath().IsEmpty())
2673+
if (!pAssembly->GetPEAssembly()->GetPath().IsEmpty())
26772674
{
2678-
if (!pAssembly->GetManifestFile()->GetPath().
2675+
if (!pAssembly->GetPEAssembly()->GetPath().
26792676
DacGetUnicode(count, location, pNeeded))
26802677
{
26812678
hr = E_FAIL;
@@ -2703,21 +2700,14 @@ ClrDataAccess::GetAssemblyModuleList(CLRDATA_ADDRESS assembly, unsigned int coun
27032700
SOSDacEnter();
27042701

27052702
Assembly* pAssembly = PTR_Assembly(TO_TADDR(assembly));
2706-
ModuleIterator mi = pAssembly->IterateModules();
2707-
unsigned int n = 0;
27082703
if (modules)
27092704
{
2710-
while (mi.Next() && n < count)
2711-
modules[n++] = HOST_CDADDR(mi.GetModule());
2712-
}
2713-
else
2714-
{
2715-
while (mi.Next())
2716-
n++;
2705+
if (pAssembly->GetModule() && count > 0)
2706+
modules[0] = HOST_CDADDR(pAssembly->GetModule());
27172707
}
27182708

27192709
if (pNeeded)
2720-
*pNeeded = n;
2710+
*pNeeded = 1;
27212711

27222712
SOSDacLeave();
27232713
return hr;

src/coreclr/debug/daccess/task.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,11 @@ ClrDataAssembly::Release(THIS)
948948
return newRefs;
949949
}
950950

951+
struct TrivialModuleIterator
952+
{
953+
Module* m_module;
954+
};
955+
951956
HRESULT STDMETHODCALLTYPE
952957
ClrDataAssembly::StartEnumModules(
953958
/* [out] */ CLRDATA_ENUM* handle)
@@ -958,11 +963,10 @@ ClrDataAssembly::StartEnumModules(
958963

959964
EX_TRY
960965
{
961-
Assembly::ModuleIterator* iter = new (nothrow)
962-
Assembly::ModuleIterator;
966+
TrivialModuleIterator* iter = new (nothrow) TrivialModuleIterator;
963967
if (iter)
964968
{
965-
*iter = m_assembly->IterateModules();
969+
iter->m_module = m_assembly->GetModule();
966970
*handle = TO_CDENUM(iter);
967971
status = S_OK;
968972
}
@@ -995,12 +999,13 @@ ClrDataAssembly::EnumModule(
995999

9961000
EX_TRY
9971001
{
998-
Assembly::ModuleIterator* iter =
999-
FROM_CDENUM(Assembly::ModuleIterator, *handle);
1000-
if (iter->Next())
1002+
TrivialModuleIterator* iter = FROM_CDENUM(TrivialModuleIterator, *handle);
1003+
if (iter->m_module)
10011004
{
10021005
*mod = new (nothrow)
1003-
ClrDataModule(m_dac, iter->GetModule());
1006+
ClrDataModule(m_dac, iter->m_module);
1007+
1008+
iter->m_module = NULL;
10041009
status = *mod ? S_OK : E_OUTOFMEMORY;
10051010
}
10061011
else
@@ -1031,8 +1036,7 @@ ClrDataAssembly::EndEnumModules(
10311036

10321037
EX_TRY
10331038
{
1034-
Assembly::ModuleIterator* iter =
1035-
FROM_CDENUM(Assembly::ModuleIterator, handle);
1039+
TrivialModuleIterator* iter = FROM_CDENUM(TrivialModuleIterator, handle);
10361040
delete iter;
10371041
status = S_OK;
10381042
}
@@ -1170,7 +1174,7 @@ ClrDataAssembly::GetFileName(
11701174
{
11711175
COUNT_T _nameLen;
11721176

1173-
if (m_assembly->GetManifestFile()->GetPath().
1177+
if (m_assembly->GetPEAssembly()->GetPath().
11741178
DacGetUnicode(bufLen, name, &_nameLen))
11751179
{
11761180
if (nameLen)

src/coreclr/debug/di/breakpoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ HRESULT CordbFunctionBreakpoint::Activate(BOOL fActivate)
201201
pProcess->InitIPCEvent(pEvent, DB_IPCE_BREAKPOINT_ADD, true, pAppDomain->GetADToken());
202202

203203
pEvent->BreakpointData.funcMetadataToken = m_code->GetMetadataToken();
204-
pEvent->BreakpointData.vmDomainFile = m_code->GetModule()->GetRuntimeDomainFile();
204+
pEvent->BreakpointData.vmDomainAssembly = m_code->GetModule()->GetRuntimeDomainAssembly();
205205
pEvent->BreakpointData.encVersion = m_code->GetVersion();
206206

207207
BOOL codeIsIL = m_code->IsIL();

src/coreclr/debug/di/divalue.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,7 +2464,7 @@ HRESULT CordbObjectValue::EnumerateExceptionCallStack(ICorDebugExceptionObjectCa
24642464
CorDebugExceptionObjectStackFrame& currentStackFrame = pStackFrames[index];
24652465

24662466
CordbAppDomain* pAppDomain = GetProcess()->LookupOrCreateAppDomain(currentDacFrame.vmAppDomain);
2467-
CordbModule* pModule = pAppDomain->LookupOrCreateModule(currentDacFrame.vmDomainFile);
2467+
CordbModule* pModule = pAppDomain->LookupOrCreateModule(currentDacFrame.vmDomainAssembly);
24682468

24692469
hr = pModule->QueryInterface(IID_ICorDebugModule, reinterpret_cast<void**>(&currentStackFrame.pModule));
24702470
_ASSERTE(SUCCEEDED(hr));
@@ -2653,18 +2653,18 @@ HRESULT CordbObjectValue::GetFunctionHelper(ICorDebugFunction **ppFunction)
26532653
return hr;
26542654

26552655
mdMethodDef functionMethodDef = 0;
2656-
VMPTR_DomainFile functionDomainFile;
2656+
VMPTR_DomainAssembly functionDomainAssembly;
26572657
NativeCodeFunctionData nativeCodeForDelFunc;
26582658

2659-
hr = pDAC->GetDelegateFunctionData(delType, pDelegateObj, &functionDomainFile, &functionMethodDef);
2659+
hr = pDAC->GetDelegateFunctionData(delType, pDelegateObj, &functionDomainAssembly, &functionMethodDef);
26602660
if (hr != S_OK)
26612661
return hr;
26622662

26632663
// TODO: How to ensure results are sanitized?
26642664
// Also, this is expensive. Do we really care that much about this?
2665-
pDAC->GetNativeCodeInfo(functionDomainFile, functionMethodDef, &nativeCodeForDelFunc);
2665+
pDAC->GetNativeCodeInfo(functionDomainAssembly, functionMethodDef, &nativeCodeForDelFunc);
26662666

2667-
RSSmartPtr<CordbModule> funcModule(GetProcess()->LookupOrCreateModule(functionDomainFile));
2667+
RSSmartPtr<CordbModule> funcModule(GetProcess()->LookupOrCreateModule(functionDomainAssembly));
26682668
RSSmartPtr<CordbFunction> func;
26692669
{
26702670
RSLockHolder lockHolder(GetProcess()->GetProcessLock());

0 commit comments

Comments
 (0)