Skip to content

Commit afa0f6b

Browse files
VSadovCopilot
andauthored
[RuntimeAsync] Do not fail EnC on ordinary Task-returning methods when async feature is turned on. (#115954)
* allow EnC on ordinary Task-returning methods. * Typo in a comment Co-authored-by: Copilot <[email protected]> * update only the variant that owns IL * typo in a comment --------- Co-authored-by: Copilot <[email protected]>
1 parent 3b5bcb4 commit afa0f6b

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/coreclr/vm/encee.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,6 @@ HRESULT EditAndContinueModule::UpdateMethod(MethodDesc *pMethod)
344344
}
345345
CONTRACTL_END;
346346

347-
if (pMethod->HasAsyncMethodData())
348-
{
349-
// TODO: (async) revisit and examine if this can be supported
350-
LOG((LF_ENC, LL_INFO100, "**Error** EnC for Async methods is NYI"));
351-
return E_FAIL;
352-
}
353-
354347
// Notify the debugger of the update
355348
if (CORDebuggerAttached())
356349
{

src/coreclr/vm/method.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,6 +3220,17 @@ void MethodDesc::ResetCodeEntryPointForEnC()
32203220
_ASSERTE(!IsVersionableWithPrecode());
32213221
_ASSERTE(!MayHaveEntryPointSlotsToBackpatch());
32223222

3223+
// Updates are expressed via metadata diff and a methoddef of a runtime async method
3224+
// would be resolved to the thunk.
3225+
// If we see a thunk here, fetch the other variant that owns the IL and reset that.
3226+
if (IsAsyncThunkMethod())
3227+
{
3228+
MethodDesc *otherVariant = GetAsyncOtherVariantNoCreate();
3229+
_ASSERTE(otherVariant != NULL);
3230+
otherVariant->ResetCodeEntryPointForEnC();
3231+
return;
3232+
}
3233+
32233234
LOG((LF_ENC, LL_INFO100000, "MD::RCEPFENC: this:%p - %s::%s - HasPrecode():%s, HasNativeCodeSlot():%s\n",
32243235
this, m_pszDebugClassName, m_pszDebugMethodName, (HasPrecode() ? "true" : "false"), (HasNativeCodeSlot() ? "true" : "false")));
32253236
if (HasPrecode())

src/coreclr/vm/method.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,13 @@ class MethodDesc
16571657
return FindOrCreateAssociatedMethodDesc(this, GetMethodTable(), FALSE, GetMethodInstantiation(), allowInstParam, FALSE, TRUE, AsyncVariantLookup::AsyncOtherVariant);
16581658
}
16591659

1660+
// same as above, but with allowCreate = FALSE
1661+
// for rare cases where we cannot allow GC, but we know that the other variant is already created.
1662+
MethodDesc* GetAsyncOtherVariantNoCreate(BOOL allowInstParam = TRUE)
1663+
{
1664+
return FindOrCreateAssociatedMethodDesc(this, GetMethodTable(), FALSE, GetMethodInstantiation(), allowInstParam, FALSE, FALSE, AsyncVariantLookup::AsyncOtherVariant);
1665+
}
1666+
16601667
// True if a MD is an funny BoxedEntryPointStub (not from the method table) or
16611668
// an MD for a generic instantiation...In other words the MethodDescs and the
16621669
// MethodTable are guaranteed to be "tightly-knit", i.e. if one is present in

0 commit comments

Comments
 (0)