@@ -1394,16 +1394,18 @@ PrepareCodeConfigBuffer::PrepareCodeConfigBuffer(NativeCodeVersion codeVersion)
1394
1394
1395
1395
// CreateDerivedTargetSigWithExtraParams:
1396
1396
// 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,
1400
1400
// we're creating a signature that looks like non-generic but with additional
1401
1401
// parameters right after the thisptr
1402
1402
void MethodDesc::CreateDerivedTargetSigWithExtraParams (MetaSig& msig, SigBuilder *stubSigBuilder)
1403
1403
{
1404
1404
STANDARD_VM_CONTRACT;
1405
1405
1406
1406
BYTE callingConvention = IMAGE_CEE_CS_CALLCONV_DEFAULT;
1407
+ if (msig.HasAsyncContinuation ())
1408
+ callingConvention = IMAGE_CEE_CS_CALLCONV_ASYNC;
1407
1409
if (msig.HasThis ())
1408
1410
callingConvention |= IMAGE_CEE_CS_CALLCONV_HASTHIS;
1409
1411
// CallingConvention
@@ -1475,9 +1477,6 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
1475
1477
1476
1478
_ASSERTE (msig.HasThis ());
1477
1479
1478
- // TODO: (async) instantiating/unboxing stubs https://github.com/dotnet/runtime/issues/117266
1479
- _ASSERTE (!msig.HasAsyncContinuation ());
1480
-
1481
1480
ILStubLinker sl (pTargetMD->GetModule (),
1482
1481
pTargetMD->GetSignature (),
1483
1482
&typeContext,
@@ -1499,12 +1498,17 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
1499
1498
pCode->EmitLoadThis ();
1500
1499
pCode->EmitLDFLDA (tokRawData);
1501
1500
1502
- #if defined( TARGET_X86)
1501
+ #ifdef TARGET_X86
1503
1502
// Push the rest of the arguments for x86
1504
1503
for (unsigned i = 0 ; i < msig.NumFixedArgs ();i++)
1505
1504
{
1506
1505
pCode->EmitLDARG (i);
1507
1506
}
1507
+
1508
+ if (msig.HasAsyncContinuation ())
1509
+ {
1510
+ pCode->EmitLDNULL ();
1511
+ }
1508
1512
#endif
1509
1513
1510
1514
// Push the hidden context param
@@ -1515,7 +1519,12 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
1515
1519
pCode->EmitSUB ();
1516
1520
pCode->EmitLDIND_I ();
1517
1521
1518
- #if !defined(TARGET_X86)
1522
+ #ifndef TARGET_X86
1523
+ if (msig.HasAsyncContinuation ())
1524
+ {
1525
+ pCode->EmitLDNULL ();
1526
+ }
1527
+
1519
1528
// Push the rest of the arguments for not x86
1520
1529
for (unsigned i = 0 ; i < msig.NumFixedArgs ();i++)
1521
1530
{
@@ -1540,7 +1549,8 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM
1540
1549
pTargetMD->GetModule (),
1541
1550
pSig, cbSig,
1542
1551
&typeContext,
1543
- &sl);
1552
+ &sl,
1553
+ pTargetMD->IsAsyncMethod ());
1544
1554
1545
1555
ILStubResolver *pResolver = pStubMD->AsDynamicMethodDesc ()->GetILStubResolver ();
1546
1556
@@ -1593,9 +1603,6 @@ Stub * CreateInstantiatingILStub(MethodDesc* pTargetMD, void* pHiddenArg)
1593
1603
1594
1604
ILCodeStream *pCode = sl.NewCodeStream (ILStubLinker::kDispatch );
1595
1605
1596
- // TODO: (async) instantiating/unboxing stubs https://github.com/dotnet/runtime/issues/117266
1597
- _ASSERTE (!msig.HasAsyncContinuation ());
1598
-
1599
1606
// Build the new signature
1600
1607
SigBuilder stubSigBuilder;
1601
1608
MethodDesc::CreateDerivedTargetSigWithExtraParams (msig, &stubSigBuilder);
@@ -1607,25 +1614,37 @@ Stub * CreateInstantiatingILStub(MethodDesc* pTargetMD, void* pHiddenArg)
1607
1614
pCode->EmitLoadThis ();
1608
1615
}
1609
1616
1610
- #if defined( TARGET_X86)
1617
+ #ifdef TARGET_X86
1611
1618
// Push the rest of the arguments for x86
1612
1619
for (unsigned i = 0 ; i < msig.NumFixedArgs ();i++)
1613
1620
{
1614
1621
pCode->EmitLDARG (i);
1615
1622
}
1616
- #endif // TARGET_X86
1617
1623
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
1618
1633
// Push the hidden context param
1619
1634
// InstantiatingStub
1620
1635
pCode->EmitLDC ((TADDR)pHiddenArg);
1621
1636
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
1624
1643
for (unsigned i = 0 ; i < msig.NumFixedArgs ();i++)
1625
1644
{
1626
1645
pCode->EmitLDARG (i);
1627
1646
}
1628
- #endif // !TARGET_X86
1647
+ #endif
1629
1648
1630
1649
// Push the target address
1631
1650
pCode->EmitLDC ((TADDR)pTargetMD->GetMultiCallableAddrOfCode (CORINFO_ACCESS_ANY));
@@ -1644,7 +1663,8 @@ Stub * CreateInstantiatingILStub(MethodDesc* pTargetMD, void* pHiddenArg)
1644
1663
pTargetMD->GetModule (),
1645
1664
pSig, cbSig,
1646
1665
&typeContext,
1647
- &sl);
1666
+ &sl,
1667
+ pTargetMD->IsAsyncMethod ());
1648
1668
1649
1669
ILStubResolver *pResolver = pStubMD->AsDynamicMethodDesc ()->GetILStubResolver ();
1650
1670
0 commit comments