03Software Engineering5 of 44 runs pass

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.

#ModelRolloutsPass@1ScoreTime
1GPT-6 Astra xhigh2/450.02.3h
2Claude Opus 5.5 max2/450.03.2h
3GPT-6.1 Sol max1/425.02.9h
4GPT-5.6 Sol max0/402.9h
5Gemini 3.8 Flash high0/404.0h
6Qwen3.8 Max xhigh0/403.7h
7GLM 5.3 Flash max0/404.0h
8Muse Spark 1.3 max0/404.0h
9Kimi K3 max0/403.9h
10Grok 4.7 xhigh0/402.3h
11Claude Sonnet 5.5 max0/403.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.
All tasks