Skip to content
Merged
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
31 changes: 12 additions & 19 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11500,39 +11500,32 @@ LPVOID CInterpreterJitInfo::GetCookieForInterpreterCalliSig(CORINFO_SIG_INFO* sz

// 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.
MethodDesc* pContextMD = nullptr;
if (m_pMethodBeingCompiled != nullptr && m_pMethodBeingCompiled->IsILStub())
{
MethodDesc* pTargetMD = m_pMethodBeingCompiled->AsDynamicMethodDesc()->GetILStubResolver()->GetStubTargetMethodDesc();
if (pTargetMD != nullptr)
{
pContextMD = pTargetMD;
result = pTargetMD->GetCalliCookie();
}
}

if (result == NULL)
{
Instantiation classInst = Instantiation((TypeHandle*) szMetaSig->sigInst.classInst, szMetaSig->sigInst.classInstCount);
Instantiation methodInst = Instantiation((TypeHandle*) szMetaSig->sigInst.methInst, szMetaSig->sigInst.methInstCount);
SigTypeContext typeContext = SigTypeContext(classInst, methodInst);
Module* mod = GetModule(szMetaSig->scope);

MetaSig sig(szMetaSig->pSig, szMetaSig->cbSig, mod, &typeContext);
Instantiation classInst = Instantiation((TypeHandle*) szMetaSig->sigInst.classInst, szMetaSig->sigInst.classInstCount);
Instantiation methodInst = Instantiation((TypeHandle*) szMetaSig->sigInst.methInst, szMetaSig->sigInst.methInstCount);
SigTypeContext typeContext = SigTypeContext(classInst, methodInst);
Module* mod = GetModule(szMetaSig->scope);

if (szMetaSig->isAsyncCall())
sig.SetIsAsyncCall();
MetaSig sig(szMetaSig->pSig, szMetaSig->cbSig, mod, &typeContext);

_ASSERTE(szMetaSig->isAsyncCall() == sig.IsAsyncCall());
if (szMetaSig->isAsyncCall())
sig.SetIsAsyncCall();

result = GetCookieForCalliSig(sig, pContextMD);
_ASSERTE(szMetaSig->isAsyncCall() == sig.IsAsyncCall());

if (pContextMD != nullptr)
{
pContextMD->SetCalliCookie(result);
result = pContextMD->GetCalliCookie();
}
}
result = GetCookieForCalliSig(sig, pContextMD);

EE_TO_JIT_TRANSITION();
return (void*)result;
Expand Down