Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#ifdef out of the DACCESS_BUILD the GetMethodDescForSlot api #104989

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/coreclr/vm/classcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ class MethodTableBuilder

DispatchMapBuilder *pDispatchMapBuilder;

#ifndef DACCESS_COMPILE
MethodDesc* GetMethodDescForSlot(WORD slot)
{
CONTRACTL
Expand All @@ -365,6 +366,7 @@ class MethodTableBuilder
(MethodTable::GetMethodDescForSlotAddress(pVtable[slot]) == pVtableMD[slot]));
return pVtableMD[slot];
}
#endif // DACCESS_COMPILE

void SetMethodDescForSlot(WORD slot, MethodDesc* pMD)
{
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/vm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ LPCUTF8 MethodDesc::GetNameThrowing()
}

//*******************************************************************************
#ifndef DACCESS_COMPILE
LPCUTF8 MethodDesc::GetName(USHORT slot)
{
// MethodDesc::GetDeclMethodDesc can throw.
Expand All @@ -293,6 +294,7 @@ LPCUTF8 MethodDesc::GetName(USHORT slot)
CONSISTENCY_CHECK(IsInterface() || !pDeclMD->IsInterface());
return pDeclMD->GetName();
}
#endif // DACCESS_COMPILE

//*******************************************************************************
LPCUTF8 MethodDesc::GetName()
Expand Down Expand Up @@ -590,6 +592,7 @@ PTR_PCODE MethodDesc::GetAddrOfSlot()
}

//*******************************************************************************
#ifndef DACCESS_COMPILE
PTR_MethodDesc MethodDesc::GetDeclMethodDesc(UINT32 slotNumber)
{
CONTRACTL {
Expand Down Expand Up @@ -642,6 +645,7 @@ PTR_MethodDesc MethodDesc::GetDeclMethodDesc(UINT32 slotNumber)
CONSISTENCY_CHECK((UINT32)pMDResult->GetSlot() == slotNumber);
return PTR_MethodDesc(pMDResult);
}
#endif // DACCESS_COMPILE

//*******************************************************************************
// Returns a hash for the method.
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ class MethodDesc
// See the TypeString class for better control over name formatting.
LPCUTF8 GetName();

#ifndef DACCESS_COMPILE
LPCUTF8 GetName(USHORT slot);
#endif // DACCESS_COMPILE

LPCUTF8 GetNameThrowing();

Expand Down Expand Up @@ -1053,7 +1055,9 @@ class MethodDesc

PTR_PCODE GetAddrOfSlot();

#ifndef DACCESS_COMPILE
PTR_MethodDesc GetDeclMethodDesc(UINT32 slotNumber);
#endif // DACCESS_COMPILE

public:
mdMethodDef GetMemberDef() const;
Expand Down
35 changes: 0 additions & 35 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5857,41 +5857,6 @@ bool MethodTable::DispatchMapTypeMatchesMethodTable(DispatchMapTypeID typeID, Me
return intIt.CurrentInterfaceMatches(this, pMT);
}

//==========================================================================================
MethodDesc * MethodTable::GetIntroducingMethodDesc(DWORD slotNumber)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;

MethodDesc * pCurrentMD = GetMethodDescForSlot(slotNumber);
DWORD dwSlot = pCurrentMD->GetSlot();
MethodDesc * pIntroducingMD = NULL;

MethodTable * pParentType = GetParentMethodTable();
MethodTable * pPrevParentType = NULL;

// Find this method in the parent.
// If it does exist in the parent, it would be at the same vtable slot.
while ((pParentType != NULL) &&
(dwSlot < pParentType->GetNumVirtuals()))
{
pPrevParentType = pParentType;
pParentType = pParentType->GetParentMethodTable();
}

if (pPrevParentType != NULL)
{
pIntroducingMD = pPrevParentType->GetMethodDescForSlot(dwSlot);
}

return pIntroducingMD;
}

//==========================================================================================
// There is a case where a method declared in a type can be explicitly
// overridden by a methodImpl on another method within the same type. In
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/methodtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1671,11 +1671,13 @@ class MethodTable
// Slots <-> the MethodDesc associated with the slot.
//

#ifndef DACCESS_COMPILE
// Get the MethodDesc that implements a given slot
// NOTE: Since this may fill in the slot with a temporary entrypoint if that hasn't happened
// yet, when writing asserts, GetMethodDescForSlot_NoThrow should be used to avoid
// the presence of an assert hiding bugs.
MethodDesc* GetMethodDescForSlot(DWORD slot);
#endif

// This api produces the same result as GetMethodDescForSlot, but it uses a variation on the
// algorithm that does not allocate a temporary entrypoint for the slot if it doesn't exist.
Expand Down Expand Up @@ -2434,8 +2436,6 @@ class MethodTable
MethodTable *LookupDispatchMapType(DispatchMapTypeID typeID);
bool DispatchMapTypeMatchesMethodTable(DispatchMapTypeID typeID, MethodTable* pMT);

MethodDesc *GetIntroducingMethodDesc(DWORD slotNumber);

// Determines whether all methods in the given interface have their final implementing
// slot in a parent class. I.e. if this returns TRUE, it is trivial (no VSD lookup) to
// dispatch pItfMT methods on this class if one knows how to dispatch them on pParentMT.
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/methodtable.inl
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ inline BOOL MethodTable::HasLayout()
}

//==========================================================================================
#ifndef DACCESS_COMPILE
inline MethodDesc* MethodTable::GetMethodDescForSlot(DWORD slot)
{
CONTRACTL
Expand All @@ -425,6 +426,7 @@ inline MethodDesc* MethodTable::GetMethodDescForSlot(DWORD slot)

return MethodTable::GetMethodDescForSlotAddress(pCode);
}
#endif // DACCESS_COMPILE

//==========================================================================================
inline MethodDesc* MethodTable::GetMethodDescForSlot_NoThrow(DWORD slot)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/methodtablebuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,6 @@ class MethodTableBuilder
inline BOOL IsMethodImpl();
inline MethodClassification MethodType();
inline bmtMDMethod *GetMDMethod() const;
inline MethodDesc *GetIntroducingMethodDesc();
inline bmtMDMethod * operator->();
inline bmtMDMethod * operator*() { WRAPPER_NO_CONTRACT; return GetMDMethod(); }
}; // class DeclaredMethodIterator
Expand Down
32 changes: 0 additions & 32 deletions src/coreclr/vm/methodtablebuilder.inl
Original file line number Diff line number Diff line change
Expand Up @@ -136,38 +136,6 @@ MethodTableBuilder::DeclaredMethodIterator::GetMDMethod() const
return m_declaredMethods[m_idx];
}

//*******************************************************************************
inline class MethodDesc *
MethodTableBuilder::DeclaredMethodIterator::GetIntroducingMethodDesc()
{
STANDARD_VM_CONTRACT;

bmtMDMethod *pCurrentMD = GetMDMethod();
DWORD dwSlot = pCurrentMD->GetSlotIndex();
MethodDesc *pIntroducingMD = NULL;

bmtRTType *pParentType = pCurrentMD->GetOwningType()->GetParentType();
bmtRTType *pPrevParentType = NULL;

// Find this method in the parent.
// If it does exist in the parent, it would be at the same vtable slot.
while (pParentType != NULL &&
dwSlot < pParentType->GetMethodTable()->GetNumVirtuals())
{
pPrevParentType = pParentType;
pParentType = pParentType->GetParentType();
}

if (pPrevParentType != NULL)
{
pIntroducingMD =
pPrevParentType->GetMethodTable()->GetMethodDescForSlot(dwSlot);
}

return pIntroducingMD;
}


//***************************************************************************************
inline MethodTableBuilder::bmtMDMethod *
MethodTableBuilder::DeclaredMethodIterator::operator->()
Expand Down
Loading