Skip to content

[RuntimeAsync] R2R and Native AOT support #115098

@VSadov

Description

@VSadov
  • Update managed type system to understand MethodImpl.Async Pass async flag to jit in aot tools #120772
  • Create MethodDescs for async thunks (Async version of Task-returning, Task-returning version of Async)
  • Generate IL for the Async thunks that forward to Task-returning methods.
  • Generate IL for the Task-returning thunks that forward to Async methods.
  • Determine the best format for emitting async variants and resumption stubs into an R2R image. Emitting Async methods in ReadyToRun image #121559 - Repurposing the Generic instance methods table seems like the best solution for this.
  • Emit Task-returning thunks to the ReadyToRun image. These should go in the MethodDef table in the image. https://github.com/dotnet/runtime/pull/122651/checks?check_run_id=60179296318
  • Emit the AsyncResumptionStubs to the readytorun image. These likely will go into the InstantiatedMethodEntryPointTable with a new flag for ResumptionStubs. Also update R2RDump to read these methods correctly.
  • Update R2R dump to indicate the async thunks and any other information that is helpful.
  • Enable R2R for Async helpers. We explicitly make them BypassReadyToRun. This could be done today, they will just fail r2r compilation and not be emitted into the image.
  • Encode the AsyncResumptionStubs and read them from the R2R image at runtime. In the runtime they are encoded as owned by a dynamic type. I'm not sure what other issues we might find trying to encode them, but I imagine we could use another flag like what we plan to do for async resumption stubs.
  • Determine behavior expected for a generic method that returns T when instantiated with T as Task.
  • AsyncResumptionStubs call into the resumed method via a dummy MethodDesc that makes the hidden parameters explicit. We should investigate whether it makes more sense to use a different solution. Related: Investigate generating resumption stubs as funclet-like code in runtime async functions #121013
  • Known JIT helper THROW_EXACT is just mapped to throw instead of using proper handling.

Some relevant source files:
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/tools/Common/TypeSystem/Common/AsyncMethodDesc.cs
src/coreclr/tools/Common/TypeSystem/Common/MethodDelegator.cs
src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs
src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstanceEntryPointTableNode.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunTableManager.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/IL/ReadyToRunILProvider.cs
src/coreclr/vm/readytoruninfo.cpp
src/coreclr/vm/readytoruninfo.h

Sub-issues

Metadata

Metadata

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions