summaryrefslogtreecommitdiff
path: root/src/vm/jitinterface.cpp
diff options
context:
space:
mode:
authorFadi Hanna <fadim@microsoft.com>2019-05-08 13:39:15 -0700
committerGitHub <noreply@github.com>2019-05-08 13:39:15 -0700
commit97fb71da9107373cbf0202030520a301ac15c4a2 (patch)
treeb14b479148f456a5e5bd0809696e2bf32e3b6d00 /src/vm/jitinterface.cpp
parent883a27180106affebd45814f5b6fc236c9d7eab2 (diff)
downloadcoreclr-97fb71da9107373cbf0202030520a301ac15c4a2.tar.gz
coreclr-97fb71da9107373cbf0202030520a301ac15c4a2.tar.bz2
coreclr-97fb71da9107373cbf0202030520a301ac15c4a2.zip
Fix 23317. (#24383)
The issue is that a LDVIRTFTN operation becomes a dictionary lookup to a direct call to an abstract function with no code. We AV later when executing the PreStub of that direct call. Fixed by making this a dictionary lookup to a MethodDescSlot lookup, followed by the call to the JIT_VirtualFunctionPointer helper to resolve the target code (Same logic executing in jitted IL mode)
Diffstat (limited to 'src/vm/jitinterface.cpp')
-rw-r--r--src/vm/jitinterface.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp
index 91cfd3705b..8059e0c212 100644
--- a/src/vm/jitinterface.cpp
+++ b/src/vm/jitinterface.cpp
@@ -5445,21 +5445,33 @@ void CEEInfo::getCallInfo(
// (c) constraint calls that require runtime context lookup are never resolved
// to underlying shared generic code
+ bool unresolvedLdVirtFtn = (flags & CORINFO_CALLINFO_LDFTN) && (flags & CORINFO_CALLINFO_CALLVIRT) && !resolvedCallVirt;
+
if (((pResult->exactContextNeedsRuntimeLookup && pTargetMD->IsInstantiatingStub() && (!allowInstParam || fResolvedConstraint)) || fForceUseRuntimeLookup)
// Handle invalid IL - see comment in code:CEEInfo::ComputeRuntimeLookupForSharedGenericToken
&& ContextIsShared(pResolvedToken->tokenContext))
{
_ASSERTE(!m_pMethodBeingCompiled->IsDynamicMethod());
- pResult->kind = CORINFO_CALL_CODE_POINTER;
- // For reference types, the constrained type does not affect method resolution
- DictionaryEntryKind entryKind = (!constrainedType.IsNull() && constrainedType.IsValueType()) ? ConstrainedMethodEntrySlot : MethodEntrySlot;
+ if (IsReadyToRunCompilation() && unresolvedLdVirtFtn)
+ {
+ // Compensate for always treating delegates as direct calls above.
+ // Dictionary lookup is computed in embedGenericHandle as part of the LDVIRTFTN code sequence
+ pResult->kind = CORINFO_VIRTUALCALL_LDVIRTFTN;
+ }
+ else
+ {
+ pResult->kind = CORINFO_CALL_CODE_POINTER;
- ComputeRuntimeLookupForSharedGenericToken(entryKind,
- pResolvedToken,
- pConstrainedResolvedToken,
- pMD,
- &pResult->codePointerLookup);
+ // For reference types, the constrained type does not affect method resolution
+ DictionaryEntryKind entryKind = (!constrainedType.IsNull() && constrainedType.IsValueType()) ? ConstrainedMethodEntrySlot : MethodEntrySlot;
+
+ ComputeRuntimeLookupForSharedGenericToken(entryKind,
+ pResolvedToken,
+ pConstrainedResolvedToken,
+ pMD,
+ &pResult->codePointerLookup);
+ }
}
else
{
@@ -5470,13 +5482,10 @@ void CEEInfo::getCallInfo(
pResult->kind = CORINFO_CALL;
- if (IsReadyToRunCompilation())
+ if (IsReadyToRunCompilation() && unresolvedLdVirtFtn)
{
// Compensate for always treating delegates as direct calls above
- if ((flags & CORINFO_CALLINFO_LDFTN) && (flags & CORINFO_CALLINFO_CALLVIRT) && !resolvedCallVirt)
- {
- pResult->kind = CORINFO_VIRTUALCALL_LDVIRTFTN;
- }
+ pResult->kind = CORINFO_VIRTUALCALL_LDVIRTFTN;
}
}
pResult->nullInstanceCheck = resolvedCallVirt;