Repository navigation
Description
Compiling runtime-async methods in ReadyToRun images requires 3 method entrypoints to be generated for each async method in metadata (Task-returning, async call conv, and resumption stub). The current ReadyToRun image format has the RuntimeFunctions table (a blob store with the native assembly code for each compiled method body), the MethodDefEntryPoints table (a per-assembly sparse array that maps from metadata token to an offset in the RuntimeFunctions blob), and the InstanceMethodEntryPoints table (a image-wide hash table that maps from the method's R2R signature (different than it's metadata signature) to an offset in the RuntimeFunctions table).
I see two obvious ways to emit async methods into a ReadyToRun image:
- Use the InstanceMethodEntryPoint table for async variants and resumption stubs in addition to generic instantiation methods.
- Create a new AsyncMethodDefEntryPoints sparse array table with 3 indices into the RuntimeFunctions table for each non-generic method (Task-returning, async, resumption stub), and create a new AsyncInstanceMethodEntryPoints table for generic instantiations of async methods.
Emitting async methods into the InstanceMethodEntryPoints table in option 1 requires adding extra information to the signature of each method in the table about which of the 3 async methods it is, which should fit in 2 bits.
I think the best starting point is to reuse InstanceMethodEntryPoints table for async variants and resumption stubs.
Documentation of readytorun format is at docs/design/coreclr/botr/readytorun-format.md.
Relevant runtime code is in src/coreclr/vm/readytoruninfo.h/cpp. Relevant code in crossgen2 is in src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/InstanceEntryPointTableNode.cs and src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodEntryPointTableNode.cs.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsNo status
Activity
MihuBot commentedon Nov 12, 2025
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
jkotas commentedon Nov 12, 2025
+1. I assume that we would add a new bits to
ReadyToRunMethodSigFlagsHow are we going to deal with resumption stubs at runtime? Are we going to create DynamicMethodDescs for them and fix the runtime to allow DynamicMethodDescs to point to R2R code?
An alternative is to merge the resumption stub with the method that it is tightly coupled with (#121013). If we went with this plan, the resumption stubs would not need to be tracked in InstanceMethodEntryPoint and we would not need to create DynamicMethodDescs for them at runtime. We would still have to fix the runtime to make this configuration work.
[RuntimeAsync] Remove async TODOs where issues are not blocking and t…