Skip to content

[RuntimeAsync] Do not fail EnC on ordinary Task-returning methods when async feature is turned on. #115954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 30, 2025
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
7 changes: 0 additions & 7 deletions src/coreclr/vm/encee.cpp
Original file line number Diff line number Diff line change
@@ -344,13 +344,6 @@ HRESULT EditAndContinueModule::UpdateMethod(MethodDesc *pMethod)
}
CONTRACTL_END;

if (pMethod->HasAsyncMethodData())
{
// TODO: (async) revisit and examine if this can be supported
LOG((LF_ENC, LL_INFO100, "**Error** EnC for Async methods is NYI"));
return E_FAIL;
}

// Notify the debugger of the update
if (CORDebuggerAttached())
{
11 changes: 11 additions & 0 deletions src/coreclr/vm/method.cpp
Original file line number Diff line number Diff line change
@@ -3220,6 +3220,17 @@ void MethodDesc::ResetCodeEntryPointForEnC()
_ASSERTE(!IsVersionableWithPrecode());
_ASSERTE(!MayHaveEntryPointSlotsToBackpatch());

// Updates are expressed via metadata diff and a methoddef of a runtime async method
// would be resolved to the thunk.
// If we see a thunk here, fetch the other variant that owns the IL and reset that.
if (IsAsyncThunkMethod())
{
MethodDesc *otherVariant = GetAsyncOtherVariantNoCreate();
_ASSERTE(otherVariant != NULL);
otherVariant->ResetCodeEntryPointForEnC();
return;
}

LOG((LF_ENC, LL_INFO100000, "MD::RCEPFENC: this:%p - %s::%s - HasPrecode():%s, HasNativeCodeSlot():%s\n",
this, m_pszDebugClassName, m_pszDebugMethodName, (HasPrecode() ? "true" : "false"), (HasNativeCodeSlot() ? "true" : "false")));
if (HasPrecode())
7 changes: 7 additions & 0 deletions src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
@@ -1657,6 +1657,13 @@ class MethodDesc
return FindOrCreateAssociatedMethodDesc(this, GetMethodTable(), FALSE, GetMethodInstantiation(), allowInstParam, FALSE, TRUE, AsyncVariantLookup::AsyncOtherVariant);
}

// same as above, but with allowCreate = FALSE
// for rare cases where we cannot allow GC, but we know that the other variant is already created.
MethodDesc* GetAsyncOtherVariantNoCreate(BOOL allowInstParam = TRUE)
{
return FindOrCreateAssociatedMethodDesc(this, GetMethodTable(), FALSE, GetMethodInstantiation(), allowInstParam, FALSE, FALSE, AsyncVariantLookup::AsyncOtherVariant);
}

// True if a MD is an funny BoxedEntryPointStub (not from the method table) or
// an MD for a generic instantiation...In other words the MethodDescs and the
// MethodTable are guaranteed to be "tightly-knit", i.e. if one is present in
Loading