dotnet / dotnet/runtime

Investigate generating resumption stubs as funclet-like code in runtime async functions

Open
#121,013 4 comments 0 reactions 1 assignee Claimed by @jakobbotsch View on GitHub
area-CodeGen-coreclr runtime-async
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

The resumption stubs are responsible for calling into the runtime async function, setting the frame up in the way it expects (by passing zeroed arguments). Furthermore it must propagate the return value into the next continuation if it completes without suspending.

Today these resumption stubs are IL stubs, but it introduces complexity for R2R and it means that the runtime async function takes an additional continuation parameter that in normal synchronous code is always null.

Instead we should consider if we can create multiple entry points for runtime async functions: one used when starting the call, and multiple more entry points used for resumption. The resumption entry points would be funclet-like pieces of code that perform the same responsibilities as the current IL stub, but with additional flexibility in how the stack frame is set up.

There will be some complexity around these since they will show up during stack walks and around whether or not they should be represented as actual funclets, or something more lightweight. See discussion starting around https://github.com/dotnet/runtime/pull/120303#issuecomment-3427210147.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.