Commit 96d2c26
authored
First part of async support in native AOT (#121295)
Following works with runtime async enabled in Roslyn on native AOT:
```csharp
public class Async2Void
{
public static void Main()
{
var t = AsyncTestEntryPoint(123, 456);
t.Wait();
Console.WriteLine(t.Result);
}
private static async Task<int> AsyncTestEntryPoint(int x, int y)
{
int result = await OtherAsync(x, y);
return result;
}
private static async Task<int> OtherAsync(int x, int y)
{
Console.WriteLine(x);
Console.WriteLine(y);
return x + y;
}
}
```
The implementation strategy is as follows:
* In the compiler, whenever someone holds an `EcmaMethod` of an asyncv2
method, it means they're holding the `RuntimeAsync` flavor of the method
in CoreCLR VM parlance. The return value is a `Task`,
`MethodDesc.IsAsync` is true, `MethodSignature.IsAsyncCallConv` is
false. The IL is a thunk to the `AsyncVariantImplMethod` flavor.
* In the compiler, we have a new `MethodDesc` descendant:
`AsyncVariantImplMethod`. This is the actual method with async calling
convention that corresponds to some `EcmaMethod` with `IsAsync`==true.
For this one: the return value is unwrapped from `Task`,
`MethodDesc.IsAsync` is true, `MethodSignature.IsAsyncCallConv` is true.
The IL is the actual IL that corresponds to the wrapped `EcmaMethod` on
disk.
Cc @dotnet/ilc-contrib1 parent b1cb4c5 commit 96d2c26
File tree
7 files changed
+140
-6
lines changed- src
- coreclr/tools
- Common
- Compiler
- JitInterface
- TypeSystem/IL
- Stubs
- aot/ILCompiler.Compiler
- libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices
7 files changed
+140
-6
lines changedLines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1828 | 1828 | | |
1829 | 1829 | | |
1830 | 1830 | | |
1831 | | - | |
1832 | | - | |
1833 | | - | |
1834 | | - | |
1835 | | - | |
1836 | 1831 | | |
1837 | 1832 | | |
1838 | 1833 | | |
| |||
1848 | 1843 | | |
1849 | 1844 | | |
1850 | 1845 | | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
1851 | 1867 | | |
1852 | 1868 | | |
1853 | 1869 | | |
| |||
4316 | 4332 | | |
4317 | 4333 | | |
4318 | 4334 | | |
4319 | | - | |
| 4335 | + | |
4320 | 4336 | | |
4321 | 4337 | | |
4322 | 4338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1366 | 1366 | | |
1367 | 1367 | | |
1368 | 1368 | | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
1369 | 1372 | | |
1370 | 1373 | | |
1371 | 1374 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
309 | 311 | | |
310 | 312 | | |
311 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
312 | 328 | | |
313 | 329 | | |
314 | 330 | | |
| |||
354 | 370 | | |
355 | 371 | | |
356 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
357 | 386 | | |
358 | 387 | | |
359 | 388 | | |
| |||
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
223 | 247 | | |
224 | 248 | | |
225 | 249 | | |
226 | 250 | | |
| 251 | + | |
227 | 252 | | |
228 | 253 | | |
229 | 254 | | |
| |||
0 commit comments