Skip to content
Merged
Changes from 1 commit
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
24 changes: 15 additions & 9 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11506,18 +11506,24 @@ LPVOID CInterpreterJitInfo::GetCookieForInterpreterCalliSig(CORINFO_SIG_INFO* sz
InterpreterCalliCookie result = NULL;
JIT_TO_EE_TRANSITION();

// When compiling a calli inside an IL stub for a P/Invoke, pass the target
// P/Invoke MethodDesc so ComputeCallStub can detect the Swift calling convention.
// Do not cache the cookie on pContextMD: MethodDesc::CalliCookie is for
// calling the target via managed calling convention. The stub we are about
// to generate calls the target via unmanaged calling convention.
// Pass the target P/Invoke MethodDesc as pContextMD so ComputeCallStub can
// detect the Swift calling convention. Do not cache the cookie on pContextMD:
// MethodDesc::CalliCookie is for the managed calling convention; the stub
// we generate calls the target via unmanaged calling convention.
MethodDesc* pContextMD = nullptr;
if (m_pMethodBeingCompiled != nullptr && m_pMethodBeingCompiled->IsILStub())
if (m_pMethodBeingCompiled != nullptr)
{
MethodDesc* pTargetMD = m_pMethodBeingCompiled->AsDynamicMethodDesc()->GetILStubResolver()->GetStubTargetMethodDesc();
if (pTargetMD != nullptr)
if (m_pMethodBeingCompiled->IsILStub())
{
pContextMD = pTargetMD;
MethodDesc* pTargetMD = m_pMethodBeingCompiled->AsDynamicMethodDesc()->GetILStubResolver()->GetStubTargetMethodDesc();
if (pTargetMD != nullptr)
{
pContextMD = pTargetMD;
}
}
else if (m_pMethodBeingCompiled->IsPInvoke())
{
pContextMD = m_pMethodBeingCompiled;
}
}

Expand Down
Loading