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

Fix non-test issues that were not crashing GenericContextTest #9

Merged
merged 1 commit into from
Apr 28, 2021
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
22 changes: 18 additions & 4 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5183,7 +5183,7 @@ void CEEInfo::getCallInfo(
MethodDesc * directMethod = constrainedType.GetMethodTable()->TryResolveConstraintMethodApprox(
exactType,
pMD,
TRUE, /* allowInstParam, At compile time the exact destination cannot reliably be known */
!!(flags & CORINFO_CALLINFO_ALLOWINSTPARAM),
&fForceUseRuntimeLookup);
if (directMethod
#ifdef FEATURE_DEFAULT_INTERFACES
Expand Down Expand Up @@ -5347,7 +5347,8 @@ void CEEInfo::getCallInfo(
// Direct calls to abstract methods are not allowed
if (IsMdAbstract(dwTargetMethodAttrs) &&
// Compensate for always treating delegates as direct calls above
!(((flags & CORINFO_CALLINFO_LDFTN) && (flags & CORINFO_CALLINFO_CALLVIRT) && !resolvedCallVirt)))
!(((flags & CORINFO_CALLINFO_LDFTN) && (flags & CORINFO_CALLINFO_CALLVIRT) && !resolvedCallVirt))
&& !(IsMdStatic(dwTargetMethodAttrs) && fForceUseRuntimeLookup))
{
COMPlusThrowHR(COR_E_BADIMAGEFORMAT, BFA_BAD_IL);
}
Expand Down Expand Up @@ -5712,7 +5713,19 @@ void CEEInfo::getCallInfo(

pResult->methodFlags = getMethodAttribsInternal(pResult->hMethod);

SignatureKind signatureKind = flags & CORINFO_CALLINFO_CALLVIRT && !(pResult->kind == CORINFO_CALL) ? SK_VIRTUAL_CALLSITE : SK_CALLSITE;
SignatureKind signatureKind;
if (flags & CORINFO_CALLINFO_CALLVIRT && !(pResult->kind == CORINFO_CALL))
{
signatureKind = SK_VIRTUAL_CALLSITE;
}
else if ((pResult->kind == CORINFO_CALL_CODE_POINTER) && IsMdVirtual(dwTargetMethodAttrs) && IsMdStatic(dwTargetMethodAttrs))
{
signatureKind = SK_STATIC_VIRTUAL_CODEPOINTER_CALLSITE;
}
else
{
signatureKind = SK_CALLSITE;
}
getMethodSigInternal(pResult->hMethod, &pResult->sig, (pResult->hMethod == pResolvedToken->hMethod) ? pResolvedToken->hClass : NULL, signatureKind);

if (flags & CORINFO_CALLINFO_VERIFICATION)
Expand Down Expand Up @@ -8647,7 +8660,8 @@ CEEInfo::getMethodSigInternal(
BOOL isCallSiteThatGoesThroughInstantiatingStub =
signatureKind == SK_VIRTUAL_CALLSITE &&
!ftn->IsStatic() &&
ftn->GetMethodTable()->IsInterface();
ftn->GetMethodTable()->IsInterface() ||
signatureKind == SK_STATIC_VIRTUAL_CODEPOINTER_CALLSITE;
if (!isCallSiteThatGoesThroughInstantiatingStub)
sigRet->callConv = (CorInfoCallConv) (sigRet->callConv | CORINFO_CALLCONV_PARAMTYPE);
}
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/jitinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum SignatureKind
SK_NOT_CALLSITE,
SK_CALLSITE,
SK_VIRTUAL_CALLSITE,
SK_STATIC_VIRTUAL_CODEPOINTER_CALLSITE,
};

class Stub;
Expand Down
15 changes: 12 additions & 3 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9173,7 +9173,7 @@ MethodDesc *MethodTable::GetDefaultConstructor(BOOL forceBoxedEntryPoint /* = FA
//==========================================================================================
// Finds the (non-unboxing) MethodDesc that implements the interface virtual static method pInterfaceMD.
MethodDesc *
MethodTable::ResolveVirtualStaticMethod(MethodDesc* pInterfaceMD, BOOL allowInstParam)
MethodTable::ResolveVirtualStaticMethod(MethodDesc* pInterfaceMD, BOOL allowInstParam, BOOL allowNullResult)
{
for (MethodTable* pMT = this; pMT != nullptr; pMT = pMT->GetParentMethodTable())
{
Expand All @@ -9183,7 +9183,11 @@ MethodTable::ResolveVirtualStaticMethod(MethodDesc* pInterfaceMD, BOOL allowInst
return pMD;
}
}
COMPlusThrow(kTypeLoadException, E_NOTIMPL);

if (allowNullResult)
return NULL;
else
COMPlusThrow(kTypeLoadException, E_NOTIMPL);
}

//==========================================================================================
Expand Down Expand Up @@ -9298,7 +9302,12 @@ MethodTable::TryResolveConstraintMethodApprox(

if (pInterfaceMD->IsStatic())
{
return ResolveVirtualStaticMethod(pInterfaceMD, allowInstParam);
MethodDesc *result = ResolveVirtualStaticMethod(pInterfaceMD, allowInstParam, pfForceUseRuntimeLookup != NULL);
if (result == NULL)
{
*pfForceUseRuntimeLookup = TRUE;
}
return result;
}

// We can't resolve constraint calls effectively for reference types, and there's
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/methodtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -2280,7 +2280,7 @@ class MethodTable


// Resolve virtual static interface method pInterfaceMD on this type.
MethodDesc *ResolveVirtualStaticMethod(MethodDesc* pInterfaceMD, BOOL allowInstParam);
MethodDesc *ResolveVirtualStaticMethod(MethodDesc* pInterfaceMD, BOOL allowInstParam, BOOL allowNullResult);

// Try a partial resolve of the constraint call, up to generic code sharing.
//
Expand Down