Skip to content

Commit d60da5d

Browse files
committed
allow EnC on ordinary Task-returning methods.
1 parent 15369d4 commit d60da5d

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3235,6 +3235,19 @@ void MethodDesc::ResetCodeEntryPointForEnC()
32353235
ppCode, pCode));
32363236
*ppCode = (PCODE)NULL;
32373237
}
3238+
3239+
// update of a Task-returning method effectively updates both variants,
3240+
// so reset the entry for the other variant as well.
3241+
if (IsTaskReturningMethod())
3242+
{
3243+
// TODO: (async) revisit and examine if the following is sufficient for actual runtime async methods when EnC is supported.
3244+
// for now we only expect to see ordinary Task-returning methods here (not thunks).
3245+
_ASSERTE(!IsAsyncThunkMethod());
3246+
3247+
MethodDesc *otherVariant = GetAsyncOtherVariantNoCreate();
3248+
_ASSERTE(otherVariant != NULL);
3249+
otherVariant->ResetCodeEntryPointForEnC();
3250+
}
32383251
}
32393252

32403253

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 varaint 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)