coro: add the stackless preemptive runtime core - #2158
Closed
cpunion wants to merge 324 commits into
Closed
Conversation
feat(coro): add runnable stackless scheduler and panic prototype
runtime(coro): add stable wait registration and cancellation
Make one ProgramIR call-site plan authoritative for intrinsic semantics, no-init/patch/intrinsic elision, and worker certificates. Route analysis, preflight, and physical emission through the frozen plan, retire builder scratch after freeze, and fail closed on actual opcode/recipe/elision mismatches. Extend exact architecture gates and remove the helper planner LLSSA runtime-type dependency exposed by integration CI.
coro: integrate stackless async runtime and scheduler prototype
# Conflicts: # cl/compile.go # go.sum # internal/build/build.go # internal/build/collect.go # internal/build/fingerprint.go # internal/build/main_module.go # internal/crosscompile/crosscompile_test.go # internal/plan9asm/indexbyte_return_test.go # runtime/internal/lib/reflect/type.go # runtime/internal/lib/runtime/_wrap/runtime.c # ssa/abitype.go # ssa/stmt_builder.go
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
Author
|
Keeping this experimental coroutine line in cpunion/llgo for now. The upstream CI result has been recorded; development and validation will continue in the fork. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the integrated compiler/runtime core for #1546. It keeps ordinary Go source and standard-library calls synchronous in syntax, infers suspension transitively, and lowers the selected functions to LLVM stackless coroutines.
The implementation deliberately does not generate two complete bodies for every function. A source function has one primary body; an additional callable/dispatch representation is emitted only when a value can cross an open dynamic boundary such as
any, an interface, a function value, reflection, or foreign code.What this adds
G,P, executor ownership,OperationID,ParkState,WaitSetRecord, result leases, select winner claims, cancellation, detach, and producer quiescence.time.Sleep,time.Timer/Ticker, direct file syscalls,os.File, and loopback TCP with deadlines.Architectural cutover
This branch has completed the planned hard cutover for the core implementation:
EnableCoro*feature surface;The design and invariants are documented in:
doc/llvm-coro-runtime-design.mddoc/coro-ir-design.mddoc/coro-async-core-contract.mddoc/coro-callable-contract.mdValidation
Validated locally with Go 1.26.5, LLVM 19.1.7, Darwin/arm64:
go test ./ssa -count=1— pass (109 s)go test ./cl -count=1 -timeout=20m— pass (1106 s)go test ./internal/build -count=1 -timeout=20m— pass (582 s), including the five standard-library acceptance programs-race -shuffle=onThe dedicated
Coroutineworkflow adds LLVM 19, 20, 21, and 22 jobs, plus integration and target lanes. The regular upstream workflows are re-enabled for this integrated PR.Scope boundaries
This PR lands the reusable core and proven vertical slices; it does not claim that every target or every GOROOT test is complete. Follow-up work remains for dynamic P sizing/work stealing, full timer GC/
synctest/asynctimerchansemantics, broader FD/process/signal coverage, the ordinary JS/WASI command reactor pump, RTOS/bare-metal HAL adapters, precise moving-GC integration, and the remaining open dynamic FFI/tooling surface.LLVM dependency
go.modtemporarily replacesgithub.com/xgo-dev/llvmwithgithub.com/cpunion/llvm@bf5fb88be315for the LLVM 22 bindings used by the matrix. The corresponding upstream proposal was xgo-dev/llvm#43; this replacement can be removed once equivalent bindings are available upstream.Part of #1546.