Skip to content

Commit

Permalink
Remove IsZapped and GetZappedModule functions (dotnet#57823)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung authored Aug 21, 2021
1 parent 52c6dcb commit 07d17b6
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 341 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ void DacDbiInterfaceImpl::ComputeFieldData(PTR_FieldDesc pFD,
{
// RVA statics are relative to a base module address
DWORD offset = pFD->GetOffset();
PTR_VOID addr = pFD->GetModule()->GetRvaField(offset, pFD->IsZapped());
PTR_VOID addr = pFD->GetModule()->GetRvaField(offset);
if (pCurrentFieldData->OkToGetOrSetStaticAddress())
{
pCurrentFieldData->SetStaticAddress(PTR_TO_TADDR(addr));
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ BOOL DacValidateMD(MethodDesc * pMD)
retval = FALSE;
}

if (retval && pMD->HasTemporaryEntryPoint())
if (retval)
{
MethodDesc *pMDCheck = MethodDesc::GetMethodDescFromStubAddr(pMD->GetTemporaryEntryPoint(), TRUE);

Expand Down
7 changes: 3 additions & 4 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2544,7 +2544,7 @@ void Module::FreeClassTables()
if (!th.IsTypeDesc())
{
MethodTable * pMT = th.AsMethodTable();
if (pMT->IsCanonicalMethodTable() && (!pMT->IsZapped() || pMT->GetZapModule() == this))
if (pMT->IsCanonicalMethodTable())
pMT->GetClass()->Destruct(pMT);
}
}
Expand Down Expand Up @@ -3261,7 +3261,7 @@ TADDR Module::GetIL(DWORD target)
return m_file->GetIL(target);
}

PTR_VOID Module::GetRvaField(DWORD rva, BOOL fZapped)
PTR_VOID Module::GetRvaField(DWORD rva)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
Expand Down Expand Up @@ -7657,9 +7657,8 @@ TADDR ReflectionModule::GetIL(RVA il) // virtual
#endif // DACCESS_COMPILE
}

PTR_VOID ReflectionModule::GetRvaField(RVA field, BOOL fZapped) // virtual
PTR_VOID ReflectionModule::GetRvaField(RVA field) // virtual
{
_ASSERTE(!fZapped);
#ifndef DACCESS_COMPILE
WRAPPER_NO_CONTRACT;
// This function should be call only if the target is a field or a field with RVA.
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ class Module
// These are overridden by reflection modules
virtual TADDR GetIL(RVA il);

virtual PTR_VOID GetRvaField(RVA field, BOOL fZapped);
virtual PTR_VOID GetRvaField(RVA field);
CHECK CheckRvaField(RVA field);
CHECK CheckRvaField(RVA field, COUNT_T size);

Expand Down Expand Up @@ -2538,7 +2538,7 @@ class ReflectionModule : public Module

// Overrides functions to access sections
virtual TADDR GetIL(RVA target);
virtual PTR_VOID GetRvaField(RVA rva, BOOL fZapped);
virtual PTR_VOID GetRvaField(RVA rva);

Assembly* GetCreatingAssembly( void )
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void EEClass::Destruct(MethodTable * pOwningMT)
}

#ifdef FEATURE_COMINTEROP
if (GetSparseCOMInteropVTableMap() != NULL && !pOwningMT->IsZapped())
if (GetSparseCOMInteropVTableMap() != NULL)
delete GetSparseCOMInteropVTableMap();
#endif // FEATURE_COMINTEROP

Expand Down
22 changes: 8 additions & 14 deletions src/coreclr/vm/comutilnative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,14 +1718,11 @@ static BOOL HasOverriddenMethod(MethodTable* mt, MethodTable* classMT, WORD meth
return FALSE;
}

if (!classMT->IsZapped())
// If CoreLib is JITed, the slots can be patched and thus we need to compare the actual MethodDescs
// to detect match reliably
if (MethodTable::GetMethodDescForSlotAddress(actual) == MethodTable::GetMethodDescForSlotAddress(base))
{
// If CoreLib is JITed, the slots can be patched and thus we need to compare the actual MethodDescs
// to detect match reliably
if (MethodTable::GetMethodDescForSlotAddress(actual) == MethodTable::GetMethodDescForSlotAddress(base))
{
return FALSE;
}
return FALSE;
}

return TRUE;
Expand Down Expand Up @@ -2084,13 +2081,10 @@ static bool HasOverriddenStreamMethod(MethodTable * pMT, WORD slot)
if (actual == base)
return false;

if (!g_pStreamMT->IsZapped())
{
// If CoreLib is JITed, the slots can be patched and thus we need to compare the actual MethodDescs
// to detect match reliably
if (MethodTable::GetMethodDescForSlotAddress(actual) == MethodTable::GetMethodDescForSlotAddress(base))
return false;
}
// If CoreLib is JITed, the slots can be patched and thus we need to compare the actual MethodDescs
// to detect match reliably
if (MethodTable::GetMethodDescForSlotAddress(actual) == MethodTable::GetMethodDescForSlotAddress(base))
return false;

return true;
}
Expand Down
20 changes: 4 additions & 16 deletions src/coreclr/vm/dllimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5949,12 +5949,9 @@ EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc* pMD)

if (pMD->IsEarlyBound())
{
if (!pMD->IsZapped())
{
// we need the MD to be populated in case we decide to build an intercept
// stub to wrap the target in InitEarlyBoundNDirectTarget
NDirect::PopulateNDirectMethodDesc(pMD);
}
// we need the MD to be populated in case we decide to build an intercept
// stub to wrap the target in InitEarlyBoundNDirectTarget
NDirect::PopulateNDirectMethodDesc(pMD);

pMD->InitEarlyBoundNDirectTarget();
}
Expand All @@ -5973,16 +5970,7 @@ EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc* pMD)
// With IL stubs, we don't have to do anything but ensure the DLL is loaded.
//

if (!pMD->IsZapped())
{
NDirect::PopulateNDirectMethodDesc(pMD);
}
else
{
// must have been populated at NGEN time
_ASSERTE(pMD->GetLibName() != NULL);
}

NDirect::PopulateNDirectMethodDesc(pMD);
pMD->CheckRestore();

NDirectLink(pMD);
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/vm/ecall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,6 @@ DWORD ECall::GetIDForMethod(MethodDesc *pMD)
}
CONTRACTL_END;

// We should not go here for NGened methods
_ASSERTE(!pMD->IsZapped());

INT ImplsIndex = FindImplsIndexForClass(pMD->GetMethodTable());
if (ImplsIndex < 0)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ PTR_VOID FieldDesc::GetStaticAddressHandle(PTR_VOID base)
if (IsRVA())
{
Module* pModule = GetModule();
PTR_VOID ret = pModule->GetRvaField(GetOffset(), IsZapped());
PTR_VOID ret = pModule->GetRvaField(GetOffset());

_ASSERTE(!pModule->IsPEFile() || !pModule->IsRvaFieldTls(GetOffset()));

Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/vm/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,6 @@ class FieldDesc
return GetApproxEnclosingMethodTable()->GetModule();
}

BOOL IsZapped()
{
WRAPPER_NO_CONTRACT;

// Field Desc's are currently always saved into the same module as their
// corresponding method table.
return GetApproxEnclosingMethodTable()->IsZapped();
}

Module *GetLoaderModule()
{
WRAPPER_NO_CONTRACT;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ void CEEInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
fieldAccessor = intrinsicAccessor;
}
else
if (m_pMethodBeingCompiled->IsZapped() || IsCompilingForNGen() ||
if (IsCompilingForNGen() ||
// Static fields are not pinned in collectible types. We will always access
// them using a helper since the address cannot be embeded into the code.
pFieldMT->Collectible() ||
Expand Down Expand Up @@ -3816,7 +3816,7 @@ CorInfoInitClassResult CEEInfo::initClass(

MethodDesc *methodBeingCompiled = m_pMethodBeingCompiled;

BOOL fMethodZappedOrNGen = methodBeingCompiled->IsZapped() || IsCompilingForNGen();
BOOL fMethodZappedOrNGen = IsCompilingForNGen();

MethodTable *pTypeToInitMT = typeToInitTH.AsMethodTable();

Expand Down
63 changes: 14 additions & 49 deletions src/coreclr/vm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ BOOL NDirectMethodDesc::HasDefaultDllImportSearchPathsAttribute()
return (ndirect.m_wFlags & kDefaultDllImportSearchPathsStatus) != 0;
}

_ASSERTE(!IsZapped());

BOOL attributeIsFound = GetDefaultDllImportSearchPathsAttributeValue(GetModule(),GetMemberDef(),&ndirect.m_DefaultDllImportSearchPathsAttributeValue);

if(attributeIsFound )
Expand Down Expand Up @@ -545,7 +543,7 @@ PCODE MethodDesc::GetMethodEntryPoint()

TADDR pSlot = dac_cast<TADDR>(this) + size;

return IsZapped() ? NonVtableSlot::GetValueAtPtr(pSlot) : *PTR_PCODE(pSlot);
return *PTR_PCODE(pSlot);
}

_ASSERTE(GetMethodTable()->IsCanonicalMethodTable());
Expand All @@ -567,9 +565,6 @@ TADDR MethodDesc::GetAddrOfSlot()

if (HasNonVtableSlot())
{
// Slots in NGened images are relative pointers
_ASSERTE(!IsZapped());

SIZE_T size = GetBaseSize();

return dac_cast<TADDR>(this) + size;
Expand Down Expand Up @@ -1404,21 +1399,6 @@ DWORD MethodDesc::GetImplAttrs()
return props;
}

//*******************************************************************************
Module* MethodDesc::GetZapModule()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
FORBID_FAULT;
SUPPORTS_DAC;
}
CONTRACTL_END

return NULL;
}

//*******************************************************************************
Module* MethodDesc::GetLoaderModule()
{
Expand All @@ -1430,11 +1410,6 @@ Module* MethodDesc::GetLoaderModule()
}
CONTRACTL_END;

if (IsZapped())
{
return GetZapModule();
}
else
if (HasMethodInstantiation() && !IsGenericMethodDefinition())
{
Module *retVal = ClassLoader::ComputeLoaderModule(GetMethodTable(),
Expand Down Expand Up @@ -2978,8 +2953,6 @@ PCODE MethodDescChunk::GetTemporaryEntryPoint(int index)
{
LIMITED_METHOD_CONTRACT;

_ASSERTE(HasTemporaryEntryPoints());

#ifdef HAS_COMPACT_ENTRYPOINTS
if (HasCompactEntryPoints())
{
Expand Down Expand Up @@ -3013,8 +2986,6 @@ PCODE MethodDesc::GetTemporaryEntryPoint()
CONTRACTL_END;

MethodDescChunk* pChunk = GetMethodDescChunk();
_ASSERTE(pChunk->HasTemporaryEntryPoints());

int lo = 0, hi = pChunk->GetCount() - 1;

// Find the temporary entrypoint in the chunk by binary search
Expand Down Expand Up @@ -3201,9 +3172,6 @@ bool MethodDesc::DetermineAndSetIsEligibleForTieredCompilation()
// Policy
g_pConfig->TieredCompilation() &&

// Functional requirement - NGEN images embed direct calls that we would be unable to detect and redirect
!IsZapped() &&

// Functional requirement - The NativeCodeSlot is required to hold the code pointer for the default code version because
// the method's entry point slot will point to a precode or to the current code entry point
HasNativeCodeSlot() &&
Expand Down Expand Up @@ -4061,24 +4029,21 @@ MethodDescChunk::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
pMT->EnumMemoryRegions(flags);
}

if (HasTemporaryEntryPoints())
{
SIZE_T size;
SIZE_T size;

#ifdef HAS_COMPACT_ENTRYPOINTS
if (HasCompactEntryPoints())
{
size = SizeOfCompactEntryPoints(GetCount());
}
else
if (HasCompactEntryPoints())
{
size = SizeOfCompactEntryPoints(GetCount());
}
else
#endif // HAS_COMPACT_ENTRYPOINTS
{
size = Precode::SizeOfTemporaryEntryPoints(GetTemporaryEntryPoints(), GetCount());
}

DacEnumMemoryRegion(GetTemporaryEntryPoints(), size);
{
size = Precode::SizeOfTemporaryEntryPoints(GetTemporaryEntryPoints(), GetCount());
}

DacEnumMemoryRegion(GetTemporaryEntryPoints(), size);

MethodDesc * pMD = GetFirstMethodDesc();
MethodDesc * pOldMD = NULL;
while (pMD != NULL && pMD != pOldMD)
Expand Down Expand Up @@ -4222,7 +4187,7 @@ void MethodDesc::WalkValueTypeParameters(MethodTable *pMT, WalkValueTypeParamete
IfFailThrowBF(ptr.SkipExactlyOne(), BFA_BAD_SIGNATURE, pModule);
}

if (!IsZapped() && !IsCompilationProcess() && !HaveValueTypeParametersBeenWalked())
if (!IsCompilationProcess() && !HaveValueTypeParametersBeenWalked())
{
SetValueTypeParametersWalked();
}
Expand Down Expand Up @@ -4267,7 +4232,7 @@ BOOL MethodDesc::HasTypeEquivalentStructParameters()

WalkValueTypeParameters(this->GetMethodTable(), CheckForEquivalenceAndLoadType, &fHasTypeEquivalentStructParameters);

if (!fHasTypeEquivalentStructParameters && !IsZapped())
if (!fHasTypeEquivalentStructParameters)
SetDoesNotHaveEquivalentValuetypeParameters();

return fHasTypeEquivalentStructParameters;
Expand Down Expand Up @@ -4348,7 +4313,7 @@ void MethodDesc::PrepareForUseAsADependencyOfANativeImageWorker()
{
}
EX_END_CATCH(RethrowTerminalExceptions);
_ASSERTE(IsZapped() || HaveValueTypeParametersBeenWalked());
_ASSERTE(HaveValueTypeParametersBeenWalked());
}
#endif //!DACCESS_COMPILE

Expand Down
Loading

0 comments on commit 07d17b6

Please sign in to comment.