Skip to content
Open
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
9 changes: 8 additions & 1 deletion src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -3128,7 +3128,14 @@ class ICorStaticInfo

// Get information about which await call to use to await the return type
// of the non-async version of an async call.
virtual CORINFO_METHOD_HANDLE getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_LOOKUP* instArg) = 0;
//
// Returns the method handle of the await call to insert. 'contextHandle' is
// set to the context to use when inlining the await call, exactly as
// getCallInfo would report it for a direct call to it (it may be an
// approximate/shared instantiation when 'instArg' requires a runtime
// lookup). 'instArg' is filled with the (potentially runtime-looked-up)
// instantiation argument that must be passed to the await call.
virtual CORINFO_METHOD_HANDLE getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg) = 0;

/*********************************************************************************/
//
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ void getAsyncInfo(

CORINFO_METHOD_HANDLE getAwaitReturnCall(
CORINFO_METHOD_HANDLE callerHandle,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg) override;

mdMethodDef getMethodDefFromMethod(
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

#include <minipal/guid.h>

constexpr GUID JITEEVersionIdentifier = { /* a09d20fa-2c93-476b-86aa-7daaa3e52ddf */
0xa09d20fa,
0x2c93,
0x476b,
{0x86, 0xaa, 0x7d, 0xaa, 0xa3, 0xe5, 0x2d, 0xdf}
constexpr GUID JITEEVersionIdentifier = { /* 52ca9f65-880a-43bc-89e8-8b5f66d80ab4 */
0x52ca9f65,
0x880a,
0x43bc,
{0x89, 0xe8, 0x8b, 0x5f, 0x66, 0xd8, 0x0a, 0xb4}
};

#endif // JIT_EE_VERSIONING_GUID_H
6 changes: 4 additions & 2 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5880,7 +5880,8 @@ void InterpCompiler::EmitRet(CORINFO_METHOD_INFO* methodInfo)
void InterpCompiler::WrapTopOfStackInAwait()
{
CORINFO_LOOKUP instArgLookup;
CORINFO_METHOD_HANDLE awaitMethod = m_compHnd->getAwaitReturnCall(m_methodHnd, &instArgLookup);
CORINFO_CONTEXT_HANDLE contextHandle;
CORINFO_METHOD_HANDLE awaitMethod = m_compHnd->getAwaitReturnCall(m_methodHnd, &contextHandle, &instArgLookup);

CORINFO_SIG_INFO awaitSig;
m_compHnd->getMethodSig(awaitMethod, &awaitSig);
Expand Down Expand Up @@ -8358,7 +8359,8 @@ void InterpCompiler::CreateSynchronizedRetValVar()
// The actual type of the return value will be the Task<T> or
// ValueTask<T> type, so get it from the await call signature
CORINFO_LOOKUP instArg;
CORINFO_METHOD_HANDLE awaitCall = m_compHnd->getAwaitReturnCall(m_methodHnd, &instArg);
CORINFO_CONTEXT_HANDLE contextHandle;
CORINFO_METHOD_HANDLE awaitCall = m_compHnd->getAwaitReturnCall(m_methodHnd, &contextHandle, &instArg);
CORINFO_SIG_INFO awaitCallSig;
m_compHnd->getMethodSig(awaitCall, &awaitCallSig);

Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,10 +1181,11 @@ void WrapICorJitInfo::getAsyncInfo(

CORINFO_METHOD_HANDLE WrapICorJitInfo::getAwaitReturnCall(
CORINFO_METHOD_HANDLE callerHandle,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg)
{
API_ENTER(getAwaitReturnCall);
CORINFO_METHOD_HANDLE temp = wrapHnd->getAwaitReturnCall(callerHandle, instArg);
CORINFO_METHOD_HANDLE temp = wrapHnd->getAwaitReturnCall(callerHandle, contextHandle, instArg);
API_LEAVE(getAwaitReturnCall);
return temp;
}
Expand Down
32 changes: 30 additions & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11740,8 +11740,10 @@ bool Compiler::impWrapTopOfStackInAwait()
return true;
}

CORINFO_LOOKUP instArgLookup;
CORINFO_METHOD_HANDLE awaitMethod = info.compCompHnd->getAwaitReturnCall(info.compMethodHnd, &instArgLookup);
CORINFO_LOOKUP instArgLookup;
CORINFO_CONTEXT_HANDLE contextHandle;
CORINFO_METHOD_HANDLE awaitMethod =
info.compCompHnd->getAwaitReturnCall(info.compMethodHnd, &contextHandle, &instArgLookup);

CORINFO_SIG_INFO awaitSig;
info.compCompHnd->getMethodSig(awaitMethod, &awaitSig);
Expand Down Expand Up @@ -11804,6 +11806,11 @@ bool Compiler::impWrapTopOfStackInAwait()
}
}

CORINFO_CALL_INFO callInfo = {};
callInfo.hMethod = awaitMethod;
callInfo.methodFlags = info.compCompHnd->getMethodAttribs(awaitMethod);
impMarkInlineCandidate(awaitCall, contextHandle, &callInfo, compInlineContext);

GenTree* toPush = awaitCall;
if (varTypeIsStruct(callRetType))
{
Expand Down Expand Up @@ -11841,6 +11848,27 @@ bool Compiler::impWrapTopOfStackInAwait()

awaitCall->SetIsAsync(asyncInfo);

if (awaitCall->IsInlineCandidate())
{
// The struct return fixup does not create a new node for inline
// candidates, so 'toPush' is still the call itself.
assert(toPush == awaitCall);

// Make the call its own statement and hand back a GT_RET_EXPR (or
// nothing for void) as the placeholder for the inliner.
impAppendTree(awaitCall, CHECK_SPILL_ALL, impCurStmtDI, /* checkConsumedDebugInfo */ false);

if (callRetType == TYP_VOID)
{
assert(info.compRetType == TYP_VOID);
return true;
}

GenTreeRetExpr* retExpr = gtNewInlineCandidateReturnExpr(awaitCall, genActualType(awaitCall->TypeGet()));
awaitCall->GetSingleInlineCandidateInfo()->retExpr = retExpr;
toPush = retExpr;
}

if (info.compRetType == TYP_VOID)
{
impAppendTree(toPush, CHECK_SPILL_ALL, impCurStmtDI);
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3592,7 +3592,7 @@ private void getAsyncInfo(ref CORINFO_ASYNC_INFO pAsyncInfoOut)
pAsyncInfoOut.finishSuspensionWithContinuationContextMethHnd = ObjectToHandle(asyncHelpers.GetKnownMethod("FinishSuspensionWithContinuationContext"u8, null));
}

private CORINFO_METHOD_STRUCT_* getAwaitReturnCall(CORINFO_METHOD_STRUCT_* callerHandle, ref CORINFO_LOOKUP instArg)
private CORINFO_METHOD_STRUCT_* getAwaitReturnCall(CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CONTEXT_STRUCT** contextHandle, ref CORINFO_LOOKUP instArg)
{
instArg.lookupKind.needsRuntimeLookup = false;
instArg.constLookup.accessType = InfoAccessType.IAT_VALUE;
Expand Down Expand Up @@ -3632,6 +3632,11 @@ private void getAsyncInfo(ref CORINFO_ASYNC_INFO pAsyncInfoOut)

MethodDesc result = runtimeDeterminedResult.GetCanonMethodTarget(CanonicalFormKind.Specific);

// Use the runtime-determined method as the context for inlining the
// await call, exactly as getCallInfo reports its contextHandle
// (which may be an approximate/shared instantiation).
*contextHandle = contextFromMethod(runtimeDeterminedResult);

if (result.RequiresInstArg())
{
#if READYTORUN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ static ICorJitInfoCallbacks()
public delegate* unmanaged<IntPtr, IntPtr*, void*, void*, byte> runWithSPMIErrorTrap;
public delegate* unmanaged<IntPtr, IntPtr*, CORINFO_EE_INFO*, void> getEEInfo;
public delegate* unmanaged<IntPtr, IntPtr*, CORINFO_ASYNC_INFO*, void> getAsyncInfo;
public delegate* unmanaged<IntPtr, IntPtr*, CORINFO_METHOD_STRUCT_*, CORINFO_LOOKUP*, CORINFO_METHOD_STRUCT_*> getAwaitReturnCall;
public delegate* unmanaged<IntPtr, IntPtr*, CORINFO_METHOD_STRUCT_*, CORINFO_CONTEXT_STRUCT**, CORINFO_LOOKUP*, CORINFO_METHOD_STRUCT_*> getAwaitReturnCall;
public delegate* unmanaged<IntPtr, IntPtr*, CORINFO_METHOD_STRUCT_*, mdToken> getMethodDefFromMethod;
public delegate* unmanaged<IntPtr, IntPtr*, CORINFO_METHOD_STRUCT_*, byte*, nuint, nuint*, nuint> printMethodName;
public delegate* unmanaged<IntPtr, IntPtr*, CORINFO_METHOD_STRUCT_*, byte**, byte**, byte**, nuint, byte*> getMethodNameFromMetadata;
Expand Down Expand Up @@ -2162,12 +2162,12 @@ private static void _getAsyncInfo(IntPtr thisHandle, IntPtr* ppException, CORINF
}

[UnmanagedCallersOnly]
private static CORINFO_METHOD_STRUCT_* _getAwaitReturnCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_LOOKUP* instArg)
private static CORINFO_METHOD_STRUCT_* _getAwaitReturnCall(IntPtr thisHandle, IntPtr* ppException, CORINFO_METHOD_STRUCT_* callerHandle, CORINFO_CONTEXT_STRUCT** contextHandle, CORINFO_LOOKUP* instArg)
{
var _this = GetThis(thisHandle);
try
{
return _this.getAwaitReturnCall(callerHandle, ref *instArg);
return _this.getAwaitReturnCall(callerHandle, contextHandle, ref *instArg);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ CORINFO_CLASS_HANDLE*,CORINFO_CLASS_STRUCT_**
CORINFO_ARG_LIST_HANDLE,CORINFO_ARG_LIST_STRUCT_*
CORINFO_VARARGS_HANDLE,IntPtr
CORINFO_CONTEXT_HANDLE,CORINFO_CONTEXT_STRUCT*
CORINFO_CONTEXT_HANDLE*,CORINFO_CONTEXT_STRUCT**
CORINFO_WASM_TYPE_SYMBOL_HANDLE,CORINFO_WASM_TYPE_SYMBOL_STRUCT_*
SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR*,SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR*

Expand Down Expand Up @@ -293,7 +294,7 @@ FUNCTIONS
[ManualNativeWrapper] bool runWithSPMIErrorTrap(ICorJitInfo::errorTrapFunction function, void* parameter);
void getEEInfo(CORINFO_EE_INFO* pEEInfoOut);
void getAsyncInfo(CORINFO_ASYNC_INFO* pAsyncInfoOut);
CORINFO_METHOD_HANDLE getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_LOOKUP* instArg);
CORINFO_METHOD_HANDLE getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg);
mdMethodDef getMethodDefFromMethod(CORINFO_METHOD_HANDLE hMethod);
size_t printMethodName(CORINFO_METHOD_HANDLE ftn, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize)
const char* getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, const char **className, const char **namespaceName, const char **enclosingClassNames, size_t maxEnclosingClassNames);
Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/tools/aot/jitinterface/jitinterface_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct JitInterfaceCallbacks
bool (* runWithSPMIErrorTrap)(void * thisHandle, CorInfoExceptionClass** ppException, ICorJitInfo::errorTrapFunction function, void* parameter);
void (* getEEInfo)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_EE_INFO* pEEInfoOut);
void (* getAsyncInfo)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_ASYNC_INFO* pAsyncInfoOut);
CORINFO_METHOD_HANDLE (* getAwaitReturnCall)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE callerHandle, CORINFO_LOOKUP* instArg);
CORINFO_METHOD_HANDLE (* getAwaitReturnCall)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE callerHandle, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg);
mdMethodDef (* getMethodDefFromMethod)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE hMethod);
size_t (* printMethodName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize);
const char* (* getMethodNameFromMetadata)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftn, const char** className, const char** namespaceName, const char** enclosingClassNames, size_t maxEnclosingClassNames);
Expand Down Expand Up @@ -1364,10 +1364,11 @@ class JitInterfaceWrapper : public ICorJitInfo

virtual CORINFO_METHOD_HANDLE getAwaitReturnCall(
CORINFO_METHOD_HANDLE callerHandle,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg)
{
CorInfoExceptionClass* pException = nullptr;
CORINFO_METHOD_HANDLE temp = _callbacks->getAwaitReturnCall(_thisHandle, &pException, callerHandle, instArg);
CORINFO_METHOD_HANDLE temp = _callbacks->getAwaitReturnCall(_thisHandle, &pException, callerHandle, contextHandle, instArg);
if (pException != nullptr) throw pException;
return temp;
}
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/agnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ struct Agnostic_CORINFO_ASYNC_INFO
struct Agnostic_GetAwaitReturnCallResult
{
DWORDLONG methodHnd;
DWORDLONG contextHandle;
Agnostic_CORINFO_LOOKUP instArg;
};

Expand Down
9 changes: 6 additions & 3 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4425,29 +4425,32 @@ void MethodContext::repGetAsyncInfo(CORINFO_ASYNC_INFO* pAsyncInfoOut)
DEBUG_REP(dmpGetAsyncInfo(0, value));
}

void MethodContext::recGetAwaitReturnCall(CORINFO_METHOD_HANDLE callerHnd, CORINFO_LOOKUP* instArg, CORINFO_METHOD_HANDLE methHnd)
void MethodContext::recGetAwaitReturnCall(CORINFO_METHOD_HANDLE callerHnd, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg, CORINFO_METHOD_HANDLE methHnd)
{
if (GetAwaitReturnCall == nullptr)
GetAwaitReturnCall = new LightWeightMap<DWORDLONG, Agnostic_GetAwaitReturnCallResult>();

Agnostic_GetAwaitReturnCallResult value;
ZeroMemory(&value, sizeof(value));
value.methodHnd = CastHandle(methHnd);
value.contextHandle = CastHandle(*contextHandle);
value.instArg = SpmiRecordsHelper::StoreAgnostic_CORINFO_LOOKUP(instArg);

GetAwaitReturnCall->Add(CastHandle(callerHnd), value);
DEBUG_REC(dmpGetAwaitReturnCall(CastHandle(callerHnd), value));
}
void MethodContext::dmpGetAwaitReturnCall(DWORDLONG key, Agnostic_GetAwaitReturnCallResult& value)
{
printf("GetAwaitReturnCall key %016" PRIX64 " value methodHnd-%016" PRIX64 " instArg %s",
printf("GetAwaitReturnCall key %016" PRIX64 " value methodHnd-%016" PRIX64 " contextHandle-%016" PRIX64 " instArg %s",
key,
value.methodHnd,
value.contextHandle,
SpmiDumpHelper::DumpAgnostic_CORINFO_LOOKUP(value.instArg).c_str());
}
CORINFO_METHOD_HANDLE MethodContext::repGetAwaitReturnCall(CORINFO_METHOD_HANDLE callerHnd, CORINFO_LOOKUP* instArg)
CORINFO_METHOD_HANDLE MethodContext::repGetAwaitReturnCall(CORINFO_METHOD_HANDLE callerHnd, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg)
{
const Agnostic_GetAwaitReturnCallResult& result = LookupByKeyOrMissNoMessage(GetAwaitReturnCall, CastHandle(callerHnd));
*contextHandle = (CORINFO_CONTEXT_HANDLE)result.contextHandle;
*instArg = SpmiRecordsHelper::RestoreCORINFO_LOOKUP(result.instArg);
return (CORINFO_METHOD_HANDLE)result.methodHnd;
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ class MethodContext
void dmpGetAsyncInfo(DWORD key, const Agnostic_CORINFO_ASYNC_INFO& value);
void repGetAsyncInfo(CORINFO_ASYNC_INFO* pAsyncInfoOut);

void recGetAwaitReturnCall(CORINFO_METHOD_HANDLE callerHnd, CORINFO_LOOKUP* instArg, CORINFO_METHOD_HANDLE methHnd);
void recGetAwaitReturnCall(CORINFO_METHOD_HANDLE callerHnd, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg, CORINFO_METHOD_HANDLE methHnd);
void dmpGetAwaitReturnCall(DWORDLONG key, Agnostic_GetAwaitReturnCallResult& value);
CORINFO_METHOD_HANDLE repGetAwaitReturnCall(CORINFO_METHOD_HANDLE callerHnd, CORINFO_LOOKUP* instArg);
CORINFO_METHOD_HANDLE repGetAwaitReturnCall(CORINFO_METHOD_HANDLE callerHnd, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg);

void recGetGSCookie(GSCookie* pCookieVal, GSCookie** ppCookieVal);
void dmpGetGSCookie(DWORD key, DLDL value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1382,11 +1382,11 @@ void interceptor_ICJI::getAsyncInfo(CORINFO_ASYNC_INFO* pAsyncInfo)
mc->recGetAsyncInfo(pAsyncInfo);
}

CORINFO_METHOD_HANDLE interceptor_ICJI::getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_LOOKUP* instArg)
CORINFO_METHOD_HANDLE interceptor_ICJI::getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg)
{
mc->cr->AddCall("getAwaitReturnCall");
CORINFO_METHOD_HANDLE result = original_ICorJitInfo->getAwaitReturnCall(callerHandle, instArg);
mc->recGetAwaitReturnCall(callerHandle, instArg, result);
CORINFO_METHOD_HANDLE result = original_ICorJitInfo->getAwaitReturnCall(callerHandle, contextHandle, instArg);
mc->recGetAwaitReturnCall(callerHandle, contextHandle, instArg, result);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,11 @@ void interceptor_ICJI::getAsyncInfo(

CORINFO_METHOD_HANDLE interceptor_ICJI::getAwaitReturnCall(
CORINFO_METHOD_HANDLE callerHandle,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg)
{
mcs->AddCall("getAwaitReturnCall");
return original_ICorJitInfo->getAwaitReturnCall(callerHandle, instArg);
return original_ICorJitInfo->getAwaitReturnCall(callerHandle, contextHandle, instArg);
}

mdMethodDef interceptor_ICJI::getMethodDefFromMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,10 @@ void interceptor_ICJI::getAsyncInfo(

CORINFO_METHOD_HANDLE interceptor_ICJI::getAwaitReturnCall(
CORINFO_METHOD_HANDLE callerHandle,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg)
{
return original_ICorJitInfo->getAwaitReturnCall(callerHandle, instArg);
return original_ICorJitInfo->getAwaitReturnCall(callerHandle, contextHandle, instArg);
}

mdMethodDef interceptor_ICJI::getMethodDefFromMethod(
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,10 +1197,10 @@ void MyICJI::getAsyncInfo(CORINFO_ASYNC_INFO* pAsyncInfo)
jitInstance->mc->repGetAsyncInfo(pAsyncInfo);
}

CORINFO_METHOD_HANDLE MyICJI::getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_LOOKUP* instArg)
CORINFO_METHOD_HANDLE MyICJI::getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg)
{
jitInstance->mc->cr->AddCall("getAwaitReturnCall");
return jitInstance->mc->repGetAwaitReturnCall(callerHandle, instArg);
return jitInstance->mc->repGetAwaitReturnCall(callerHandle, contextHandle, instArg);
}

/*********************************************************************************/
Expand Down
12 changes: 11 additions & 1 deletion src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10359,7 +10359,7 @@ void CEEInfo::getAsyncInfo(CORINFO_ASYNC_INFO* pAsyncInfoOut)
EE_TO_JIT_TRANSITION();
}

CORINFO_METHOD_HANDLE CEEInfo::getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_LOOKUP* instArg)
CORINFO_METHOD_HANDLE CEEInfo::getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHandle, CORINFO_CONTEXT_HANDLE* contextHandle, CORINFO_LOOKUP* instArg)
{
CONTRACTL {
THROWS;
Expand Down Expand Up @@ -10408,6 +10408,12 @@ CORINFO_METHOD_HANDLE CEEInfo::getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHa
}
}

// The context for inlining the await call, mirroring what getCallInfo would
// report as its contextHandle. By default this is the returned method
// itself (an exact instantiation, or an approximate/shared one when a
// runtime lookup is required for the instantiation argument).
MethodDesc* pInliningContext = pMD;

if (pMD->RequiresInstArg())
{
if (retType.IsCanonicalSubtype())
Expand All @@ -10420,9 +10426,13 @@ CORINFO_METHOD_HANDLE CEEInfo::getAwaitReturnCall(CORINFO_METHOD_HANDLE callerHa
instArg->lookupKind.needsRuntimeLookup = false;
instArg->constLookup.accessType = IAT_VALUE;
instArg->constLookup.addr = pContext;
// The exact instantiation is known, so use it as the inlining context.
pInliningContext = pContext;
}
}

*contextHandle = MAKE_METHODCONTEXT(pInliningContext);

EE_TO_JIT_TRANSITION();

return CORINFO_METHOD_HANDLE(pMD);
Expand Down
Loading