Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -1094,25 +1094,32 @@ TargetPointer IRuntimeTypeSystem.GetMethodDescForSlot(TypeHandle typeHandle, ush

TargetPointer cannonMTPTr = GetCanonicalMethodTable(typeHandle);
TypeHandle canonMT = GetTypeHandle(cannonMTPTr);
if (slot >= GetNumVtableSlots(canonMT))
throw new ArgumentException(nameof(slot), "Slot number is greater than the number of slots");

TargetPointer slotPtr = GetAddressOfSlot(canonMT, slot);
TargetCodePointer pCode = _target.ReadCodePointer(slotPtr);

if (pCode == TargetCodePointer.Null)
{
while (canonMT.Address != TargetPointer.Null)
TargetPointer lookupMTPtr = cannonMTPTr;
while (lookupMTPtr != TargetPointer.Null)
{
// if pCode is null, we iterate through the method descs in the MT.
foreach (MethodDescHandle mdh in GetIntroducedMethods(canonMT))
TypeHandle lookupMT = GetTypeHandle(lookupMTPtr);
foreach (MethodDescHandle mdh in GetIntroducedMethods(lookupMT))
{
MethodDesc md = _methodDescs[mdh.Address];
if (md.Slot == slot)
{
return mdh.Address;
}
}
canonMT = GetTypeHandle(GetCanonicalMethodTable(GetTypeHandle(GetParentMethodTable(canonMT))));
lookupMTPtr = GetParentMethodTable(lookupMT);
if (lookupMTPtr != TargetPointer.Null)
lookupMTPtr = GetCanonicalMethodTable(GetTypeHandle(lookupMTPtr));
}
Debug.Fail("We should never reach here, as there should always be a MethodDesc for a slot");
return TargetPointer.Null;
}

return GetMethodDescForEntrypoint(pCode);
Expand Down