compiler(coro): lower static child awaits and root factories - #18
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the first scheduler handoff slice for the experimental LLVM coroutine physical ABI, enabling a physical coroutine to await a statically resolved coroutine child (ordinary child await) and generating typed factories and descriptors for explicit async roots. It introduces the EnableCoroChildAwait configuration, upgrades the physical ABI version to V1, adds task-aware frame allocation/free hooks, and implements child-await lowering and explicit async root factory emission. The review feedback identifies critical opportunities to prevent potential nil pointer dereferences by adding defensive nil checks for p.compilation.CoroPlan in both tryCompileCoroStaticAwait and emitCoroRootFactory before accessing its fields.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
PhysicalABIV1/SchedulerChildAwaitABIV0lifecycle identities and task-aware frame hooksCallDirect + DirectCorocall as a stackless child handoff(g, out, startup) -> handlefactory only for explicitAsyncDemandrootsllvm.usedThe generated parent evaluates arguments left-to-right, creates the child only through its initial suspend, publishes the parent/child relationship, calls
__llgo_coro_await_prepare_v1, and suspends. Generated Go code never directly resumes or destroys the child; those operations remain scheduler-owned.Scope
This is an ABI/lowering slice, not a runnable scheduler. It remains opt-in and fail-closed for CFG/recursion, dynamic calls, spawn, park, preemption, channel/select, defer/panic, methods/closures/generics, aggregate results, and main/init bootstrap. The next slice will add the explicit descriptor registry, frame registry, root bootstrap, and deterministic single-P scheduler.
Validation
llvm.used, GlobalDCE, object retention, and manual Darwin-dead_strip/ Linux--gc-sectionsfinal-link checksgo test -race ./internal/corogo test ./ssaandgo test ./internal/buildThe local full
go test ./clstill reports pre-existing Go 1.26 float-format golden differences; the same failure reproduces on the Phase 9 base and is unrelated to this diff.LLVM 22 binding baseline: cpunion/llvm#4 (merged), upstream xgo-dev/llvm#43 (all checks green, awaiting approval).
Progresses xgo-dev#1546.