Skip to content

Commit

Permalink
a few tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
VSadov committed Oct 1, 2021
1 parent dc1a35a commit 48e68e5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 63 deletions.
8 changes: 3 additions & 5 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void Module::Initialize(AllocMemTracker *pamTracker, LPCWSTR szName)
{
// For composite images, manifest metadata gets loaded as part of the native image
COUNT_T cMeta = 0;
if (GetPEAssembly()->GetOpenedILimage()->GetNativeManifestMetadata(&cMeta) != NULL)
if (GetPEAssembly()->GetILimage()->GetNativeManifestMetadata(&cMeta) != NULL)
{
// Load the native assembly import
GetNativeAssemblyImport(TRUE /* loadAllowed */);
Expand Down Expand Up @@ -742,7 +742,6 @@ Module *Module::Create(Assembly *pAssembly, mdFile moduleRef, PEAssembly *pPEAss
STANDARD_VM_CHECK;
PRECONDITION(CheckPointer(pAssembly));
PRECONDITION(CheckPointer(pPEAssembly));
PRECONDITION(!IsNilToken(moduleRef) || pPEAssembly->IsAssembly());
POSTCONDITION(CheckPointer(RETVAL));
POSTCONDITION(RETVAL->GetPEAssembly() == pPEAssembly);
}
Expand Down Expand Up @@ -2375,7 +2374,7 @@ BOOL Module::IsInSameVersionBubble(Module *target)
{
// Check if the current module's image has native manifest metadata, otherwise the current->GetNativeAssemblyImport() asserts.
COUNT_T cMeta=0;
const void* pMeta = GetPEAssembly()->GetOpenedILimage()->GetNativeManifestMetadata(&cMeta);
const void* pMeta = GetPEAssembly()->GetILimage()->GetNativeManifestMetadata(&cMeta);
if (pMeta == NULL)
{
return FALSE;
Expand Down Expand Up @@ -4618,7 +4617,7 @@ IMDInternalImport* Module::GetNativeAssemblyImport(BOOL loadAllowed)
}
CONTRACT_END;

RETURN GetPEAssembly()->GetOpenedILimage()->GetNativeMDImport(loadAllowed);
RETURN GetPEAssembly()->GetILimage()->GetNativeMDImport(loadAllowed);
}

BYTE* Module::GetNativeFixupBlobData(RVA rva)
Expand Down Expand Up @@ -6959,7 +6958,6 @@ ReflectionModule *ReflectionModule::Create(Assembly *pAssembly, PEAssembly *pPEA
// Hoist CONTRACT into separate routine because of EX incompatibility

mdFile token;
_ASSERTE(pPEAssembly->IsAssembly());
token = mdFileNil;

// Initial memory block for Modules must be zero-initialized (to make it harder
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6139,7 +6139,7 @@ static void GetCodeViewInfo(Module * pModule, CV_INFO_PDB70 * pCvInfoIL, CV_INFO
_ASSERTE(pPEAssembly != NULL);

PTR_PEImageLayout pLayout = NULL;
if (pPEAssembly->HasOpenedILimage())
if (pPEAssembly->HasILimage())
{
pLayout = pPEAssembly->GetLoadedIL();
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12818,7 +12818,7 @@ PCODE UnsafeJitFunction(PrepareCodeConfig* config,
LARGE_INTEGER methodJitTimeStop;
QueryPerformanceCounter(&methodJitTimeStop);
SString codeBase;
ftn->GetModule()->GetDomainFile()->GetPEAssembly()->GetCodeBaseOrName(codeBase);
ftn->GetModule()->GetDomainFile()->GetPEAssembly()->GetPathOrCodeBase(codeBase);
codeBase.AppendPrintf(W(",0x%x,%d,%d\n"),
//(const WCHAR *)codeBase, //module name
ftn->GetMemberDef(), //method token
Expand Down
18 changes: 9 additions & 9 deletions src/coreclr/vm/peassembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ BOOL PEAssembly::Equals(PEImage *pImage)
// Descriptive strings
// ------------------------------------------------------------

void PEAssembly::GetCodeBaseOrName(SString &result)
void PEAssembly::GetPathOrCodeBase(SString &result)
{
CONTRACTL
{
Expand All @@ -285,12 +285,10 @@ void PEAssembly::GetCodeBaseOrName(SString &result)
{
result.Set(m_openedILimage->GetPath());
}
else if (IsAssembly())
else
{
((PEAssembly*)this)->GetCodeBase(result);
GetCodeBase(result);
}
else
result.SetUTF8(GetSimpleName());
}


Expand Down Expand Up @@ -926,7 +924,7 @@ PEAssembly::PEAssembly(
}

#if _DEBUG
GetCodeBaseOrName(m_debugName);
GetPathOrCodeBase(m_debugName);
m_debugName.Normalize();
m_pDebugName = m_debugName;
#endif
Expand Down Expand Up @@ -1104,13 +1102,14 @@ BOOL PEAssembly::GetCodeBase(SString &result)
}
CONTRACTL_END;

auto ilImage = GetILimage();
if (ilImage == nullptr || !ilImage->IsInBundle())
PEImage* ilImage = GetILimage();
if (ilImage == NULL || !ilImage->IsInBundle())
{
// All other cases use the file path.
result.Set(GetEffectivePath());
if (!result.IsEmpty())
PathToUrl(result);

return TRUE;
}
else
Expand Down Expand Up @@ -1290,7 +1289,8 @@ void PEAssembly::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
{
m_openedILimage->EnumMemoryRegions(flags);
}
if (GetILimage().IsValid())

if (HasILimage())
{
GetILimage()->EnumMemoryRegions(flags);
}
Expand Down
25 changes: 4 additions & 21 deletions src/coreclr/vm/peassembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class PEAssembly
#endif // DACCESS_COMPILE

// Full name is the most descriptive name available (path, codebase, or name as appropriate)
void GetCodeBaseOrName(SString &result);
void GetPathOrCodeBase(SString &result);

#ifdef LOGGING
// This is useful for log messages
Expand All @@ -159,7 +159,6 @@ class PEAssembly
// Classification
// ------------------------------------------------------------

BOOL IsAssembly() const;
PTR_PEAssembly AsAssembly();
BOOL IsSystem() const;
BOOL IsDynamic() const;
Expand Down Expand Up @@ -294,38 +293,22 @@ class PEAssembly

void LoadLibrary();

PTR_PEImage GetILimage()
{
CONTRACTL
{
THROWS;
MODE_ANY;
GC_TRIGGERS;
}
CONTRACTL_END;

return m_openedILimage;
}

PEImage* GetOpenedILimage()
PEImage* GetILimage()
{
LIMITED_METHOD_DAC_CONTRACT;
_ASSERTE(HasOpenedILimage());
return m_openedILimage;
}


BOOL HasOpenedILimage()
BOOL HasILimage()
{
LIMITED_METHOD_DAC_CONTRACT;
return m_openedILimage != NULL;

}

BOOL HasLoadedIL()
{
LIMITED_METHOD_DAC_CONTRACT;
return HasOpenedILimage() && GetOpenedILimage()->HasLoadedLayout();
return HasILimage() && GetILimage()->HasLoadedLayout();
}

LPCWSTR GetPathForErrorMessages();
Expand Down
26 changes: 8 additions & 18 deletions src/coreclr/vm/peassembly.inl
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,6 @@ inline LPCWSTR PEAssembly::GetDebugName()
// Classification
// ------------------------------------------------------------

inline BOOL PEAssembly::IsAssembly() const
{
LIMITED_METHOD_DAC_CONTRACT;

return true;
}

inline PTR_PEAssembly PEAssembly::AsAssembly()
{
LIMITED_METHOD_DAC_CONTRACT;
Expand All @@ -280,7 +273,6 @@ inline BOOL PEAssembly::IsDynamic() const
inline PEAssembly *PEAssembly::GetAssembly() const
{
WRAPPER_NO_CONTRACT;
_ASSERTE(IsAssembly());
return dac_cast<PTR_PEAssembly>(this);
}

Expand Down Expand Up @@ -449,7 +441,7 @@ inline BOOL PEAssembly::IsReadyToRun()
}
CONTRACTL_END;

if (HasOpenedILimage())
if (HasILimage())
{
return GetLoadedIL()->HasReadyToRunHeader();
}
Expand Down Expand Up @@ -481,7 +473,7 @@ inline mdToken PEAssembly::GetEntryPointToken(
return mdTokenNil;

_ASSERTE (!bAssumeLoaded || HasLoadedIL ());
return GetOpenedILimage()->GetEntryPointToken();
return GetILimage()->GetEntryPointToken();
}

inline BOOL PEAssembly::IsILOnly()
Expand All @@ -494,7 +486,7 @@ inline BOOL PEAssembly::IsILOnly()
if (IsDynamic())
return FALSE;

return GetOpenedILimage()->IsILOnly();
return GetILimage()->IsILOnly();
}

inline BOOL PEAssembly::IsDll()
Expand All @@ -504,7 +496,7 @@ inline BOOL PEAssembly::IsDll()
if (IsDynamic())
return TRUE;

return GetOpenedILimage()->IsDll();
return GetILimage()->IsDll();
}

inline PTR_VOID PEAssembly::GetRvaField(RVA field)
Expand Down Expand Up @@ -847,9 +839,9 @@ inline BOOL PEAssembly::IsPtrInILImage(PTR_CVOID data)
}
CONTRACTL_END;

if (HasOpenedILimage())
if (HasILimage())
{
return GetOpenedILimage()->IsPtrInImage(data);
return GetILimage()->IsPtrInImage(data);
}
else
return FALSE;
Expand All @@ -863,9 +855,9 @@ inline PTR_PEImageLayout PEAssembly::GetLoadedIL()
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;

_ASSERTE(HasOpenedILimage());
_ASSERTE(HasILimage());

return GetOpenedILimage()->GetLoadedLayout();
return GetILimage()->GetLoadedLayout();
};

inline BOOL PEAssembly::IsLoaded()
Expand Down Expand Up @@ -1013,7 +1005,6 @@ inline DWORD PEAssembly::GetFlags()
{
CONTRACTL
{
PRECONDITION(IsAssembly());
INSTANCE_CHECK;
if (FORBIDGC_LOADER_USE_ENABLED()) NOTHROW; else THROWS;
if (FORBIDGC_LOADER_USE_ENABLED()) GC_NOTRIGGER; else GC_TRIGGERS;
Expand All @@ -1033,7 +1024,6 @@ inline HRESULT PEAssembly::GetFlagsNoTrigger(DWORD * pdwFlags)
{
CONTRACTL
{
PRECONDITION(IsAssembly());
INSTANCE_CHECK;
NOTHROW;
GC_NOTRIGGER;
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/vm/peimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,11 +895,6 @@ PTR_PEImageLayout PEImage::GetLayoutInternal(DWORD imageLayoutMask)
}
}

if (pRetVal != NULL)
{
pRetVal->AddRef();
}

return pRetVal;
}

Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/proftoeeinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3996,10 +3996,10 @@ DWORD ProfToEEInterfaceImpl::GetModuleFlags(Module * pModule)
dwRet |= (COR_PRF_MODULE_DISK | COR_PRF_MODULE_NGEN);
}
#endif
// Not NGEN or ReadyToRun.
if (pPEAssembly->HasOpenedILimage())
// Not Dynamic.
if (pPEAssembly->HasILimage())
{
PEImage * pILImage = pPEAssembly->GetOpenedILimage();
PEImage * pILImage = pPEAssembly->GetILimage();
if (pILImage->IsFile())
{
dwRet |= COR_PRF_MODULE_DISK;
Expand Down

0 comments on commit 48e68e5

Please sign in to comment.