Skip to content

Commit

Permalink
Switch uses of DomainAssembly that just need Assembly to use `Ass…
Browse files Browse the repository at this point in the history
…embly` (#104334)
  • Loading branch information
elinor-fung authored Jul 9, 2024
1 parent 528b6fc commit eae1542
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 212 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/binder/bindertracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace
if (spec->GetName() != nullptr)
spec->GetDisplayName(ASM_DISPLAYF_VERSION | ASM_DISPLAYF_CULTURE | ASM_DISPLAYF_PUBLIC_KEY_TOKEN, request.AssemblyName);

DomainAssembly *parentAssembly = spec->GetParentAssembly();
::Assembly *parentAssembly = spec->GetParentAssembly();
if (parentAssembly != nullptr)
{
PEAssembly *pPEAssembly = parentAssembly->GetPEAssembly();
Expand Down
14 changes: 7 additions & 7 deletions src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3946,7 +3946,7 @@ void AppDomain::ExceptionUnwind(Frame *pFrame)

#ifndef DACCESS_COMPILE

DomainAssembly* AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef)
Assembly* AppDomain::RaiseTypeResolveEventThrowing(Assembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef)
{
CONTRACTL
{
Expand All @@ -3959,7 +3959,7 @@ DomainAssembly* AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssemb

OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(CLASS_LOADED);

DomainAssembly* pResolvedAssembly = NULL;
Assembly* pResolvedAssembly = NULL;
_ASSERTE(strcmp(szName, g_AppDomainClassName));

GCX_COOP();
Expand All @@ -3974,7 +3974,7 @@ DomainAssembly* AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssemb
GCPROTECT_BEGIN(gc);

if (pAssembly != NULL)
gc.AssemblyRef = pAssembly->GetExposedAssemblyObject();
gc.AssemblyRef = pAssembly->GetExposedObject();

MethodDescCallSite onTypeResolve(METHOD__ASSEMBLYLOADCONTEXT__ON_TYPE_RESOLVE);

Expand All @@ -3988,7 +3988,7 @@ DomainAssembly* AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssemb

if (ResultingAssemblyRef != NULL)
{
pResolvedAssembly = ResultingAssemblyRef->GetDomainAssembly();
pResolvedAssembly = ResultingAssemblyRef->GetAssembly();

if (pResultingAssemblyRef)
*pResultingAssemblyRef = ResultingAssemblyRef;
Expand All @@ -4006,7 +4006,7 @@ DomainAssembly* AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssemb
}


Assembly* AppDomain::RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR szName)
Assembly* AppDomain::RaiseResourceResolveEvent(Assembly* pAssembly, LPCSTR szName)
{
CONTRACT(Assembly*)
{
Expand All @@ -4032,7 +4032,7 @@ Assembly* AppDomain::RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR
GCPROTECT_BEGIN(gc);

if (pAssembly != NULL)
gc.AssemblyRef=pAssembly->GetExposedAssemblyObject();
gc.AssemblyRef=pAssembly->GetExposedObject();

MethodDescCallSite onResourceResolve(METHOD__ASSEMBLYLOADCONTEXT__ON_RESOURCE_RESOLVE);
gc.str = StringObject::NewString(szName);
Expand Down Expand Up @@ -4095,7 +4095,7 @@ AppDomain::RaiseAssemblyResolveEvent(
{
if (pSpec->GetParentAssembly() != NULL)
{
gc.AssemblyRef=pSpec->GetParentAssembly()->GetExposedAssemblyObject();
gc.AssemblyRef=pSpec->GetParentAssembly()->GetExposedObject();
}

MethodDescCallSite onAssemblyResolve(METHOD__ASSEMBLYLOADCONTEXT__ON_ASSEMBLY_RESOLVE);
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 @@ -1517,8 +1517,8 @@ class AppDomain : public BaseDomain
}

static void RaiseExitProcessEvent();
Assembly* RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR szName);
DomainAssembly* RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef);
Assembly* RaiseResourceResolveEvent(Assembly* pAssembly, LPCSTR szName);
Assembly* RaiseTypeResolveEventThrowing(Assembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef);
Assembly* RaiseAssemblyResolveEvent(AssemblySpec *pSpec);

private:
Expand Down
16 changes: 6 additions & 10 deletions src/coreclr/vm/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,9 +1590,8 @@ BOOL Assembly::FileNotFound(HRESULT hr)


BOOL Assembly::GetResource(LPCSTR szName, DWORD *cbResource,
PBYTE *pbInMemoryResource, Assembly** pAssemblyRef,
LPCSTR *szFileName, DWORD *dwLocation,
BOOL fSkipRaiseResolveEvent)
PBYTE *pbInMemoryResource, Assembly** pAssemblyRef,
LPCSTR *szFileName, DWORD *dwLocation)
{
CONTRACTL
{
Expand All @@ -1602,13 +1601,10 @@ BOOL Assembly::GetResource(LPCSTR szName, DWORD *cbResource,
}
CONTRACTL_END;

DomainAssembly *pAssembly = NULL;
BOOL result = GetDomainAssembly()->GetResource(szName, cbResource,
pbInMemoryResource, &pAssembly,
szFileName, dwLocation,
fSkipRaiseResolveEvent);
if (result && pAssemblyRef != NULL && pAssembly != NULL)
*pAssemblyRef = pAssembly->GetAssembly();
BOOL result = GetPEAssembly()->GetResource(szName, cbResource,
pbInMemoryResource, pAssemblyRef,
szFileName, dwLocation,
this);

return result;
}
Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/vm/assembly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,8 @@ class Assembly
~Assembly();

BOOL GetResource(LPCSTR szName, DWORD *cbResource,
PBYTE *pbInMemoryResource, Assembly **pAssemblyRef,
LPCSTR *szFileName, DWORD *dwLocation,
BOOL fSkipRaiseResolveEvent = FALSE);
PBYTE *pbInMemoryResource, Assembly **pAssemblyRef,
LPCSTR *szFileName, DWORD *dwLocation);

//****************************************************************************************
#ifdef DACCESS_COMPILE
Expand Down
22 changes: 9 additions & 13 deletions src/coreclr/vm/assemblynative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ extern "C" void QCALLTYPE AssemblyNative_InternalLoad(NativeAssemblyNameParts* p
{
pRefAssembly = SystemDomain::GetCallersAssembly(stackMark);
}
if (pRefAssembly)
{
pParentAssembly = pRefAssembly->GetDomainAssembly();
}
}

AssemblySpec spec;
Expand All @@ -93,8 +89,8 @@ extern "C" void QCALLTYPE AssemblyNative_InternalLoad(NativeAssemblyNameParts* p
spec.Init(ssName.GetUTF8(), &asmInfo,
pAssemblyNameParts->_pPublicKeyOrToken, pAssemblyNameParts->_cbPublicKeyOrToken, pAssemblyNameParts->_flags);

if (pParentAssembly != NULL)
spec.SetParentAssembly(pParentAssembly);
if (pRefAssembly != NULL)
spec.SetParentAssembly(pRefAssembly);

// Have we been passed the reference to the binder against which this load should be triggered?
// If so, then use it to set the fallback load context binder.
Expand Down Expand Up @@ -138,7 +134,7 @@ Assembly* AssemblyNative::LoadFromPEImage(AssemblyBinder* pBinder, PEImage *pIma
ReleaseHolder<BINDER_SPACE::Assembly> pAssembly;

// Set the caller's assembly to be CoreLib
DomainAssembly *pCallersAssembly = SystemDomain::System()->SystemAssembly()->GetDomainAssembly();
Assembly *pCallersAssembly = SystemDomain::System()->SystemAssembly();

// Initialize the AssemblySpec
AssemblySpec spec;
Expand Down Expand Up @@ -650,9 +646,9 @@ extern "C" BYTE * QCALLTYPE AssemblyNative_GetResource(QCall::AssemblyHandle pAs
if (*pNameUTF8 == '\0')
COMPlusThrow(kArgumentException, W("Format_StringZeroLength"));

pAssembly->GetResource(pNameUTF8, length,
pAssembly->GetPEAssembly()->GetResource(pNameUTF8, length,
&pbInMemoryResource, NULL, NULL,
NULL, FALSE);
NULL, pAssembly->GetAssembly());

END_QCALL;

Expand All @@ -679,20 +675,20 @@ extern "C" INT32 QCALLTYPE AssemblyNative_GetManifestResourceInfo(QCall::Assembl
if (*pNameUTF8 == '\0')
COMPlusThrow(kArgumentException, W("Format_StringZeroLength"));

DomainAssembly * pReferencedAssembly = NULL;
Assembly * pReferencedAssembly = NULL;
LPCSTR pFileName = NULL;
DWORD dwLocation = 0;

if (pAssembly->GetResource(pNameUTF8, NULL, NULL, &pReferencedAssembly, &pFileName,
&dwLocation, FALSE))
if (pAssembly->GetPEAssembly()->GetResource(pNameUTF8, NULL, NULL, &pReferencedAssembly, &pFileName,
&dwLocation, pAssembly->GetAssembly()))
{
if (pFileName)
retFileName.Set(pFileName);

GCX_COOP();

if (pReferencedAssembly)
retAssembly.Set(pReferencedAssembly->GetExposedAssemblyObject());
retAssembly.Set(pReferencedAssembly->GetExposedObject());

rv = dwLocation;
}
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/vm/assemblyspec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ AssemblySpecHash::~AssemblySpecHash()

HRESULT AssemblySpec::InitializeSpecInternal(mdToken kAssemblyToken,
IMDInternalImport *pImport,
DomainAssembly *pStaticParent)
Assembly *pStaticParent)
{
CONTRACTL
{
Expand Down Expand Up @@ -325,12 +325,12 @@ AssemblyBinder* AssemblySpec::GetBinderFromParentAssembly(AppDomain *pDomain)
CONTRACTL_END;

AssemblyBinder *pParentAssemblyBinder = NULL;
DomainAssembly *pParentDomainAssembly = GetParentAssembly();
Assembly *pParentAssembly = GetParentAssembly();

if(pParentDomainAssembly != NULL)
if(pParentAssembly != NULL)
{
// Get the PEAssembly associated with the parent's domain assembly
PEAssembly *pParentPEAssembly = pParentDomainAssembly->GetPEAssembly();
PEAssembly *pParentPEAssembly = pParentAssembly->GetPEAssembly();
pParentAssemblyBinder = pParentPEAssembly->GetAssemblyBinder();
}

Expand Down Expand Up @@ -1121,7 +1121,7 @@ BOOL AssemblySpecBindingCache::CompareSpecs(UPTR u1, UPTR u2)
return a1->CompareEx(a2);
}

DomainAssembly * AssemblySpec::GetParentAssembly()
Assembly * AssemblySpec::GetParentAssembly()
{
LIMITED_METHOD_CONTRACT;
return m_pParentAssembly;
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/vm/assemblyspec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AssemblySpec : public BaseAssemblySpec
{
private:
AppDomain *m_pAppDomain;
DomainAssembly *m_pParentAssembly;
Assembly *m_pParentAssembly;

// Contains the reference to the fallback load context associated with RefEmitted assembly requesting the load of another assembly (static or dynamic)
AssemblyBinder *m_pFallbackBinder;
Expand All @@ -38,7 +38,7 @@ class AssemblySpec : public BaseAssemblySpec

HRESULT InitializeSpecInternal(mdToken kAssemblyRefOrDef,
IMDInternalImport *pImport,
DomainAssembly *pStaticParent);
Assembly *pStaticParent);

// InitializeSpecInternal should be used very carefully so it's made private.
// functions that take special care (and thus are allowed to use the function) are listed below
Expand Down Expand Up @@ -73,7 +73,7 @@ class AssemblySpec : public BaseAssemblySpec
}


DomainAssembly* GetParentAssembly();
Assembly* GetParentAssembly();

AssemblyBinder* GetBinderFromParentAssembly(AppDomain *pDomain);

Expand All @@ -82,7 +82,7 @@ class AssemblySpec : public BaseAssemblySpec

void InitializeSpec(mdToken kAssemblyRefOrDef,
IMDInternalImport *pImport,
DomainAssembly *pStaticParent = NULL)
Assembly *pStaticParent = NULL)
{
CONTRACTL
{
Expand All @@ -92,7 +92,7 @@ class AssemblySpec : public BaseAssemblySpec
MODE_ANY;
}
CONTRACTL_END;
HRESULT hr=InitializeSpecInternal(kAssemblyRefOrDef, pImport,pStaticParent);
HRESULT hr = InitializeSpecInternal(kAssemblyRefOrDef, pImport, pStaticParent);
if(FAILED(hr))
EEFileLoadException::Throw(this,hr);
};
Expand All @@ -102,7 +102,7 @@ class AssemblySpec : public BaseAssemblySpec

void AssemblyNameInit(ASSEMBLYNAMEREF* pName); //[in,out]

void SetParentAssembly(DomainAssembly *pAssembly)
void SetParentAssembly(Assembly *pAssembly)
{
CONTRACTL
{
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/vm/callconvbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ HRESULT CallConv::TryGetCallingConventionFromUnmanagedCallConv(
callConvsArg.Init("CallConvs", SERIALIZATION_TYPE_SZARRAY, callConvsType);

InlineFactory<SArray<CaValue>, 4> caValueArrayFactory;
DomainAssembly* domainAssembly = pMD->GetLoaderModule()->GetDomainAssembly();
Assembly* assembly = pMD->GetLoaderModule()->GetAssembly();
IfFailThrow(CustomAttribute::ParseArgumentValues(
pData,
cData,
Expand All @@ -461,7 +461,7 @@ HRESULT CallConv::TryGetCallingConventionFromUnmanagedCallConv(
0,
&callConvsArg,
1,
domainAssembly));
assembly ));

// Value isn't defined
if (callConvsArg.val.type.tag == SERIALIZATION_TYPE_UNDEFINED)
Expand Down Expand Up @@ -527,7 +527,7 @@ bool CallConv::TryGetCallingConventionFromUnmanagedCallersOnly(_In_ MethodDesc*
namedArgs[1].Init("EntryPoint", SERIALIZATION_TYPE_STRING, caEntryPoint);

InlineFactory<SArray<CaValue>, 4> caValueArrayFactory;
DomainAssembly* domainAssembly = pMD->GetLoaderModule()->GetDomainAssembly();
Assembly* assembly = pMD->GetLoaderModule()->GetAssembly();
IfFailThrow(CustomAttribute::ParseArgumentValues(
pData,
cData,
Expand All @@ -536,7 +536,7 @@ bool CallConv::TryGetCallingConventionFromUnmanagedCallersOnly(_In_ MethodDesc*
0,
namedArgs,
ARRAY_SIZE(namedArgs),
domainAssembly));
assembly));

// If the value isn't defined, then return without setting anything.
if (namedArgs[0].val.type.tag == SERIALIZATION_TYPE_UNDEFINED)
Expand Down
Loading

0 comments on commit eae1542

Please sign in to comment.