@@ -1394,16 +1394,18 @@ PrepareCodeConfigBuffer::PrepareCodeConfigBuffer(NativeCodeVersion codeVersion)
13941394
13951395// CreateDerivedTargetSigWithExtraParams:
13961396// This method is used to create the signature of the target of the ILStub for
1397- // instantiating, unboxing, and async variant stubs, when/where we need to
1398- // introduce a generic context/async continuation .
1399- // And since the generic context/async continuations are hidden parameters,
1397+ // instantiating and unboxing stubs, when/where we need to
1398+ // introduce a generic context.
1399+ // And since the generic contexts are hidden parameters,
14001400// we're creating a signature that looks like non-generic but with additional
14011401// parameters right after the thisptr
14021402void MethodDesc::CreateDerivedTargetSigWithExtraParams (MetaSig& msig, SigBuilder *stubSigBuilder)
14031403{
14041404 STANDARD_VM_CONTRACT;
14051405
14061406 BYTE callingConvention = IMAGE_CEE_CS_CALLCONV_DEFAULT;
1407+ if (msig.HasAsyncContinuation ())
1408+ callingConvention = IMAGE_CEE_CS_CALLCONV_ASYNC;
14071409 if (msig.HasThis ())
14081410 callingConvention |= IMAGE_CEE_CS_CALLCONV_HASTHIS;
14091411 // CallingConvention
@@ -1475,9 +1477,6 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
14751477
14761478 _ASSERTE (msig.HasThis ());
14771479
1478- // TODO: (async) instantiating/unboxing stubs https://github.com/dotnet/runtime/issues/117266
1479- _ASSERTE (!msig.HasAsyncContinuation ());
1480-
14811480 ILStubLinker sl (pTargetMD->GetModule (),
14821481 pTargetMD->GetSignature (),
14831482 &typeContext,
@@ -1499,12 +1498,17 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
14991498 pCode->EmitLoadThis ();
15001499 pCode->EmitLDFLDA (tokRawData);
15011500
1502- #if defined( TARGET_X86)
1501+ #ifdef TARGET_X86
15031502 // Push the rest of the arguments for x86
15041503 for (unsigned i = 0 ; i < msig.NumFixedArgs ();i++)
15051504 {
15061505 pCode->EmitLDARG (i);
15071506 }
1507+
1508+ if (msig.HasAsyncContinuation ())
1509+ {
1510+ pCode->EmitLDNULL ();
1511+ }
15081512#endif
15091513
15101514 // Push the hidden context param
@@ -1515,7 +1519,12 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
15151519 pCode->EmitSUB ();
15161520 pCode->EmitLDIND_I ();
15171521
1518- #if !defined(TARGET_X86)
1522+ #ifndef TARGET_X86
1523+ if (msig.HasAsyncContinuation ())
1524+ {
1525+ pCode->EmitLDNULL ();
1526+ }
1527+
15191528 // Push the rest of the arguments for not x86
15201529 for (unsigned i = 0 ; i < msig.NumFixedArgs ();i++)
15211530 {
@@ -1540,7 +1549,8 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
15401549 pTargetMD->GetModule (),
15411550 pSig, cbSig,
15421551 &typeContext,
1543- &sl);
1552+ &sl,
1553+ pTargetMD->IsAsyncMethod ());
15441554
15451555 ILStubResolver *pResolver = pStubMD->AsDynamicMethodDesc ()->GetILStubResolver ();
15461556
@@ -1593,9 +1603,6 @@ Stub * CreateInstantiatingILStub(MethodDesc* pTargetMD, void* pHiddenArg)
15931603
15941604 ILCodeStream *pCode = sl.NewCodeStream (ILStubLinker::kDispatch );
15951605
1596- // TODO: (async) instantiating/unboxing stubs https://github.com/dotnet/runtime/issues/117266
1597- _ASSERTE (!msig.HasAsyncContinuation ());
1598-
15991606 // Build the new signature
16001607 SigBuilder stubSigBuilder;
16011608 MethodDesc::CreateDerivedTargetSigWithExtraParams (msig, &stubSigBuilder);
@@ -1607,25 +1614,37 @@ Stub * CreateInstantiatingILStub(MethodDesc* pTargetMD, void* pHiddenArg)
16071614 pCode->EmitLoadThis ();
16081615 }
16091616
1610- #if defined( TARGET_X86)
1617+ #ifdef TARGET_X86
16111618 // Push the rest of the arguments for x86
16121619 for (unsigned i = 0 ; i < msig.NumFixedArgs ();i++)
16131620 {
16141621 pCode->EmitLDARG (i);
16151622 }
1616- #endif // TARGET_X86
16171623
1624+ if (msig.HasAsyncContinuation ())
1625+ {
1626+ pCode->EmitLDNULL ();
1627+ }
1628+
1629+ // Push the hidden context param
1630+ // InstantiatingStub
1631+ pCode->EmitLDC ((TADDR)pHiddenArg);
1632+ #else
16181633 // Push the hidden context param
16191634 // InstantiatingStub
16201635 pCode->EmitLDC ((TADDR)pHiddenArg);
16211636
1622- #if !defined(TARGET_X86)
1623- // Push the rest of the arguments for not x86
1637+ if (msig.HasAsyncContinuation ())
1638+ {
1639+ pCode->EmitLDNULL ();
1640+ }
1641+
1642+ // Push the rest of the arguments for x86
16241643 for (unsigned i = 0 ; i < msig.NumFixedArgs ();i++)
16251644 {
16261645 pCode->EmitLDARG (i);
16271646 }
1628- #endif // !TARGET_X86
1647+ #endif
16291648
16301649 // Push the target address
16311650 pCode->EmitLDC ((TADDR)pTargetMD->GetMultiCallableAddrOfCode (CORINFO_ACCESS_ANY));
@@ -1644,7 +1663,8 @@ Stub * CreateInstantiatingILStub(MethodDesc* pTargetMD, void* pHiddenArg)
16441663 pTargetMD->GetModule (),
16451664 pSig, cbSig,
16461665 &typeContext,
1647- &sl);
1666+ &sl,
1667+ pTargetMD->IsAsyncMethod ());
16481668
16491669 ILStubResolver *pResolver = pStubMD->AsDynamicMethodDesc ()->GetILStubResolver ();
16501670
0 commit comments