Skip to content
Merged
Changes from 3 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
Comment thread
MichalStrehovsky marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ private void ImportCall(ILOpcode opcode, int token)
Debug.Assert(false); break;
}

MethodDesc asyncVariantMethod = null;
MethodDesc asyncVariantRuntimeDeterminedMethod = null;
Comment thread
eduardo-vp marked this conversation as resolved.
Outdated
// Are we scanning a call within a state machine?
if (opcode is ILOpcode.call or ILOpcode.callvirt
&& _canonMethod.IsAsyncCall())
Expand All @@ -475,8 +477,10 @@ private void ImportCall(ILOpcode opcode, int token)
_dependencies.Add(_factory.MethodEntrypoint(asyncHelpers.GetKnownMethod("FinishSuspensionWithContinuationContext"u8, null)), asyncReason);
}

// If this is the task await pattern, we're actually going to call the variant
// so switch our focus to the variant.
// If this is the task await pattern, the JIT will first resolve the call to the
// async variant, then may switch back to the original if the async variant is just
// a thunk (for non-runtime-async methods). Report both variants as dependencies such
// that the JIT can pick either one.
Comment thread
eduardo-vp marked this conversation as resolved.

// in rare cases a method that returns Task is not actually TaskReturning (i.e. returns T).
// we cannot resolve to an Async variant in such case.
Expand All @@ -487,11 +491,20 @@ private void ImportCall(ILOpcode opcode, int token)

if (allowAsyncVariant && MatchTaskAwaitPattern())
{
runtimeDeterminedMethod = _factory.TypeSystemContext.GetAsyncVariantMethod(runtimeDeterminedMethod);
method = _factory.TypeSystemContext.GetAsyncVariantMethod(method);
asyncVariantMethod = _factory.TypeSystemContext.GetAsyncVariantMethod(method);
asyncVariantRuntimeDeterminedMethod = _factory.TypeSystemContext.GetAsyncVariantMethod(runtimeDeterminedMethod);
}
}

ImportCall(opcode, reason, method, runtimeDeterminedMethod);
if (asyncVariantMethod != null)
{
ImportCall(opcode, reason, asyncVariantMethod, asyncVariantRuntimeDeterminedMethod);
}
}

private void ImportCall(ILOpcode opcode, string reason, MethodDesc method, MethodDesc runtimeDeterminedMethod)
{
if (opcode == ILOpcode.newobj)
{
TypeDesc owningType = runtimeDeterminedMethod.OwningType;
Expand Down
Loading