Coroutines in Haxe
Add native coroutines to the Haxe compiler: a state-machine transform that survives pauses anywhere, on eval and JavaScript.
Results
Each square represents one run. Score is the percentage of runs that pass: 0, 25, 50, 75, or 100 for four runs.
| # | Model | Rollouts | Pass@1 | Score | Time |
|---|---|---|---|---|---|
| 1 | GPT-6 Astra xhigh | 2/4 | 2.3h | ||
| 2 | Claude Opus 5.5 max | 2/4 | 3.2h | ||
| 3 | GPT-6.1 Sol max | 1/4 | 2.9h | ||
| 4 | GPT-5.6 Sol max | 0/4 | 2.9h | ||
| 5 | Gemini 3.8 Flash high | 0/4 | 4.0h | ||
| 6 | Qwen3.8 Max xhigh | 0/4 | 3.7h | ||
| 7 | GLM 5.3 Flash max | 0/4 | 4.0h | ||
| 8 | Muse Spark 1.3 max | 0/4 | 4.0h | ||
| 9 | Kimi K3 max | 0/4 | 3.9h | ||
| 10 | Grok 4.7 xhigh | 0/4 | 2.3h | ||
| 11 | Claude Sonnet 5.5 max | 0/4 | 3.3h |
Background
Haxe is a statically typed language whose OCaml compiler targets JavaScript, C++ and its own eval interpreter from one codebase. It has no direct-style async: users chain callbacks or promises by hand. Starting from the commit before upstream #12479, the agent adds native coroutines. Functions marked @:coroutine suspend at calls to other coroutines and compile into state machines. A suspension can happen anywhere an expression can, so the transformed code must resume with every local, captured variable, pending operand and exception handler intact.
Task
The agent implements coroutines against a supplied runtime API (the haxe.coro package of continuations, contexts, schedulers and cancellation, added unchanged). A coroutine yields only when a callee suspends; an exception from the outermost coroutine returns through its result or completion, never thrown past the caller. Coroutines work on eval and JavaScript, non-coroutine code behaves as before on every target, and hxcoro works unmodified. The compiler may not special-case the test framework or hxcoro.
Workspace
The offline sandbox (4 CPUs, 8 GB, 4 hours) holds the Haxe repository at the parent of the upstream merge, built for incremental rebuilds, with OCaml 5.3.0, its dependencies and Node.js 18. It also holds the runtime API and hxcoro's source without its test suite, plus eight example programs with expected output. hxcoro's tests and graded programs are held out.
Verification
The compiler is rebuilt from the committed HEAD and tested on eval and JavaScript. All 15 existing upstream suite runs must pass with no new failures, and every graded hxcoro test must pass on both targets. 237 hidden programs run in eight families: sequential control flow, value positions, exceptions, captured variables, concurrent tasks on a virtual-time scheduler, failures, suspension in unusual positions, and direct calls from ordinary code. A program passes only if its output matches on both targets, and each family must reach 90%.
Environment
- Toolchain
- OCaml 5.3.0, opam, dune, Node.js 18, neko 2.3 (haxelib)
- Compute
- 4 CPUs · 8 GB RAM
- Network
- Offline
- Time limit
- 4 hours
References
- Haxe (GPL-2.0-or-later and MIT): The compiler the agent extends, checked out at the parent of #12479, the upstream change that added coroutines.
- hxcoro: The coroutine library (schedulers, structured concurrency, suspension helpers) that must run unmodified on the new compiler; its test suite is part of grading.