Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ private ref struct RuntimeAsyncStackState
public INotifyCompletion? Notifier;
public ValueTaskSourceContinuation? ValueTaskSourceContinuation;
public RuntimeAsyncTaskContinuation? TaskContinuation;
public delegate*<Continuation, int, Action, void> AwaiterContinuation;
public int AwaiterOffset;

// When we suspend in the leaf, the contexts are captured into these fields.
public ExecutionContext? LeafExecutionContext;
Expand Down Expand Up @@ -265,6 +267,8 @@ public void CaptureContexts()
[NonVersionable]
public void Push(RuntimeAsyncStackState* stackState)
{
stackState->AwaiterContinuation = null;
stackState->AwaiterOffset = 0;
stackState->Next = StackState;
StackState = stackState;
CurrentThread ??= Thread.CurrentThread;
Expand Down Expand Up @@ -805,7 +809,15 @@ internal unsafe bool HandleSuspended(ref RuntimeAsyncAwaitState state)

try
{
if (stackState->CriticalNotifier is { } critNotifier)
if (stackState->AwaiterContinuation != null)
{
// The awaiter is stored in the continuation for the caller of
// AwaitAwaiterInContinuation or UnsafeAwaitAwaiterInContinuation.
Debug.Assert((headContinuation.Flags & ContinuationFlags.AllContinuationFlags) == 0);
stackState->AwaiterContinuation(
headContinuation, stackState->AwaiterOffset, GetContinuationAction());
}
else if (stackState->CriticalNotifier is { } critNotifier)
{
// Result of async call to AwaitAwaiter or UnsafeAwaitAwaiter.
// These never have special continuation context handling.
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -3154,6 +3154,14 @@ class ICorStaticInfo
// 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;

virtual CORINFO_METHOD_HANDLE getAwaitAwaiterInContinuationCall(
CORINFO_METHOD_HANDLE callerHandle,
CORINFO_SIG_INFO* callSig,
bool isUnsafe,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg
) = 0;

/*********************************************************************************/
//
// Diagnostic methods
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,13 @@ CORINFO_METHOD_HANDLE getAwaitReturnCall(
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg) override;

CORINFO_METHOD_HANDLE getAwaitAwaiterInContinuationCall(
CORINFO_METHOD_HANDLE callerHandle,
CORINFO_SIG_INFO* callSig,
bool isUnsafe,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg) override;

mdMethodDef getMethodDefFromMethod(
CORINFO_METHOD_HANDLE hMethod) override;

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 = { /* 5bb9b1e5-9941-4762-a195-351b6a736588 */
0x5bb9b1e5,
0x9941,
0x4762,
{0xa1, 0x95, 0x35, 0x1b, 0x6a, 0x73, 0x65, 0x88}
constexpr GUID JITEEVersionIdentifier = { /* 364f7f40-1feb-4b18-bc70-a3cb6481665b */
0x364f7f40,
0x1feb,
0x4b18,
{0xbc, 0x70, 0xa3, 0xcb, 0x64, 0x81, 0x66, 0x5b}
};

#endif // JIT_EE_VERSIONING_GUID_H
1 change: 1 addition & 0 deletions src/coreclr/jit/ICorJitInfo_names_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ DEF_CLR_API(runWithSPMIErrorTrap)
DEF_CLR_API(getEEInfo)
DEF_CLR_API(getAsyncInfo)
DEF_CLR_API(getAwaitReturnCall)
DEF_CLR_API(getAwaitAwaiterInContinuationCall)
DEF_CLR_API(getMethodDefFromMethod)
DEF_CLR_API(printMethodName)
DEF_CLR_API(getMethodNameFromMetadata)
Expand Down
13 changes: 13 additions & 0 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,19 @@ CORINFO_METHOD_HANDLE WrapICorJitInfo::getAwaitReturnCall(
return temp;
}

CORINFO_METHOD_HANDLE WrapICorJitInfo::getAwaitAwaiterInContinuationCall(
CORINFO_METHOD_HANDLE callerHandle,
CORINFO_SIG_INFO* callSig,
bool isUnsafe,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_LOOKUP* instArg)
{
API_ENTER(getAwaitAwaiterInContinuationCall);
CORINFO_METHOD_HANDLE temp = wrapHnd->getAwaitAwaiterInContinuationCall(callerHandle, callSig, isUnsafe, contextHandle, instArg);
API_LEAVE(getAwaitAwaiterInContinuationCall);
return temp;
}

mdMethodDef WrapICorJitInfo::getMethodDefFromMethod(
CORINFO_METHOD_HANDLE hMethod)
{
Expand Down
Loading
Loading