Skip to content

Commit 7624a38

Browse files
VSadovjakobbotsch
andauthored
[RuntimeAsync] Switch the implementation to the new shape of runtime async methods. (#2818)
* update Roslyn ref to one that uses new IL shape * part1 * IsAsyncThunkMethod --> IsAsyncHelperMethod * reintroduce IsAsyncThunkMethod * fix shared generic test * fix after rebasing * typo * clarified a comment * PR feedback Co-authored-by: Jakob Botsch Nielsen <[email protected]> * switch to a newer Roslyn prototype * workaround - moved `GC.Collect/WFPF` into a noinline helper. * PR feedback * Revert "workaround - moved `GC.Collect/WFPF` into a noinline helper." This reverts commit ef45803. * reenable tiering for async methods * more isThunk-->isHelper renames * fixes tiered compilation * switch to a new ROslyn SHA * A few fixes after updating to new Roslyn compiler * add a testcase for PGO/OSR * PR feedback * file rename * 4 iterations / 100 msec delay --------- Co-authored-by: Jakob Botsch Nielsen <[email protected]>
1 parent d95f6ea commit 7624a38

35 files changed

+302
-201
lines changed

buildroslynnugets.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
setlocal ENABLEEXTENSIONS
22
pushd %~dp0
3-
set ASYNC_ROSLYN_COMMIT=fa251ef06afcc9d1c79761a112b89c6341c0ccfa
4-
set ASYNC_SUFFIX=async-10
3+
set ASYNC_ROSLYN_COMMIT=10a5611cb10cd64876a2638664f0740255197e1b
4+
set ASYNC_SUFFIX=async-11
55
set ASYNC_ROSLYN_BRANCH=demos/async2-experiment1
66

77
cd ..

eng/Versions.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
Any tools that contribute to the design-time experience should use the MicrosoftCodeAnalysisVersion_LatestVS property above to ensure
4444
they do not break the local dev experience.
4545
-->
46-
<MicrosoftCodeAnalysisCSharpVersion>4.13.0-async-10</MicrosoftCodeAnalysisCSharpVersion>
47-
<MicrosoftCodeAnalysisVersion>4.13.0-async-10</MicrosoftCodeAnalysisVersion>
48-
<MicrosoftNetCompilersToolsetVersion>4.13.0-async-10</MicrosoftNetCompilersToolsetVersion>
46+
<MicrosoftCodeAnalysisCSharpVersion>4.13.0-async-11</MicrosoftCodeAnalysisCSharpVersion>
47+
<MicrosoftCodeAnalysisVersion>4.13.0-async-11</MicrosoftCodeAnalysisVersion>
48+
<MicrosoftNetCompilersToolsetVersion>4.13.0-async-11</MicrosoftNetCompilersToolsetVersion>
4949
</PropertyGroup>
5050
<!--
5151
For source generator support we need to target multiple versions of Roslyn in order to be able to run on older versions of Roslyn.

src/coreclr/inc/corcompile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ enum EncodeMethodSigFlags
180180
ENCODE_METHOD_SIG_Constrained = 0x20,
181181
ENCODE_METHOD_SIG_OwnerType = 0x40,
182182
ENCODE_METHOD_SIG_UpdateContext = 0x80,
183-
ENCODE_METHOD_SIG_AsyncThunk = 0x100,
183+
ENCODE_METHOD_SIG_AsyncHelper = 0x100,
184184
};
185185

186186
enum EncodeFieldSigFlags

src/coreclr/inc/corhdr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,15 @@ typedef enum CorMethodImpl
648648
miNoOptimization = 0x0040, // Method may not be optimized.
649649
miAggressiveOptimization = 0x0200, // Method may contain hot code and should be aggressively optimized.
650650

651+
miAsync = 0x0400, // Method requires async state machine rewrite.
652+
651653
// These are the flags that are allowed in MethodImplAttribute's Value
652654
// property. This should include everything above except the code impl
653655
// flags (which are used for MethodImplAttribute's MethodCodeType field).
654656
miUserMask = miManagedMask | miForwardRef | miPreserveSig |
655657
miInternalCall | miSynchronized |
656658
miNoInlining | miAggressiveInlining |
657-
miNoOptimization | miAggressiveOptimization,
659+
miNoOptimization | miAggressiveOptimization | miAsync,
658660

659661
miMaxMethodImplVal = 0xffff, // Range check value
660662
} CorMethodImpl;
@@ -678,6 +680,7 @@ typedef enum CorMethodImpl
678680
#define IsMiAggressiveInlining(x) ((x) & miAggressiveInlining)
679681
#define IsMiNoOptimization(x) ((x) & miNoOptimization)
680682
#define IsMiAggressiveOptimization(x) (((x) & (miAggressiveOptimization | miNoOptimization)) == miAggressiveOptimization)
683+
#define IsMiAsync(x) ((x) & miAsync)
681684

682685
// PinvokeMap attr bits, used by DefinePinvokeMap.
683686
typedef enum CorPinvokeMap

src/coreclr/vm/class.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ HRESULT EEClass::AddMethodDesc(
741741
classification,
742742
TRUE, // fNonVtableSlot
743743
TRUE, // fNativeCodeSlot
744-
FALSE, /* IsAsyncThunkMethod */
744+
FALSE, /* HasAsyncMethodData */
745745
pMT,
746746
&dummyAmTracker);
747747

@@ -791,7 +791,7 @@ HRESULT EEClass::AddMethodDesc(
791791
pImport,
792792
NULL,
793793
Signature(),
794-
AsyncMethodType::NotAsync
794+
AsyncMethodKind::NotAsync
795795
COMMA_INDEBUG(debug_szMethodName)
796796
COMMA_INDEBUG(pMT->GetDebugClassName())
797797
COMMA_INDEBUG(NULL)

src/coreclr/vm/clrtocomcall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ I4ARRAYREF SetUpWrapperInfo(MethodDesc *pMD)
230230

231231
GCX_PREEMP();
232232

233-
if (pMD->IsAsyncThunkMethod())
233+
if (pMD->IsAsyncHelperMethod())
234234
{
235235
ThrowHR(COR_E_NOTSUPPORTED);
236236
}
@@ -509,7 +509,7 @@ UINT32 CLRToCOMLateBoundWorker(
509509
LPCUTF8 strMemberName;
510510
ULONG uSemantic;
511511

512-
if (pItfMD->IsAsyncThunkMethod())
512+
if (pItfMD->IsAsyncHelperMethod())
513513
{
514514
ThrowHR(COR_E_NOTSUPPORTED);
515515
}

src/coreclr/vm/clsload.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2802,7 +2802,7 @@ TypeHandle ClassLoader::PublishType(const TypeKey *pTypeKey, TypeHandle typeHnd)
28022802
{
28032803
MethodDesc * pMD = it.GetMethodDesc();
28042804
CONSISTENCY_CHECK(pMD != NULL && pMD->GetMethodTable() == pMT);
2805-
if (!pMD->IsUnboxingStub() && !pMD->IsAsyncThunkMethod())
2805+
if (!pMD->IsUnboxingStub() && !pMD->IsAsyncHelperMethod())
28062806
{
28072807
pModule->EnsuredStoreMethodDef(pMD->GetMemberDef(), pMD);
28082808
}

src/coreclr/vm/codeman.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,6 +3892,7 @@ BOOL EEJitManager::JitCodeToMethodInfo(
38923892

38933893
if (ppMethodDesc)
38943894
{
3895+
38953896
*ppMethodDesc = pCHdr->GetMethodDesc();
38963897
}
38973898
return TRUE;

src/coreclr/vm/commodule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ extern "C" INT32 QCALLTYPE ModuleBuilder_GetMemberRefOfMethodInfo(QCall::ModuleH
302302
COMPlusThrow(kNotSupportedException);
303303
}
304304

305-
if ((pMeth->GetMethodTable()->GetModule() == pModule) && !pMeth->IsAsyncThunkMethod())
305+
if ((pMeth->GetMethodTable()->GetModule() == pModule) && !pMeth->IsAsyncHelperMethod())
306306
{
307307
// If the passed in method is defined in the same module, just return the MethodDef token
308308
memberRefE = pMeth->GetMemberDef();

src/coreclr/vm/commtmemberinfomap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ void ComMTMemberInfoMap::GetMethodPropsForMeth(
688688
// Generally don't munge function into a getter.
689689
rProps[ix].bFunction2Getter = FALSE;
690690

691-
if (pMeth->IsAsyncThunkMethod())
691+
if (pMeth->IsAsyncHelperMethod())
692692
ThrowHR(COR_E_NOTSUPPORTED);
693693

694694
// See if there is property information for this member.
@@ -1607,7 +1607,7 @@ void ComMTMemberInfoMap::PopulateMemberHashtable()
16071607

16081608
// We are dealing with a method.
16091609
MethodDesc *pMD = pProps->pMeth;
1610-
if (pMD->IsAsyncThunkMethod())
1610+
if (pMD->IsAsyncHelperMethod())
16111611
{
16121612
ThrowHR(COR_E_NOTSUPPORTED); // Probably this isn't right, and instead should be a skip, but a throw makes it easier to find if this is wrong
16131613
}

0 commit comments

Comments
 (0)