Files
aji/docs/plan/phase-7-native-backend.md
T
dev d2932bd75a Phase 3 done: exit review, implemented_phase = 3
P3-10 and P3-11 moved to P7-10 and P7-11 (executor model for async and
blocking host operations); semantic development paused until the E-S
smoke test is analysed
2026-10-04 17:06:45 +03:00

28 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Phase 7 — Native backend
Non-normative. Part of the [implementation plan](README.md).
**Goal:** verified AIR compiled to native code through LLVM, with a native runtime whose behavior matches the interpreter.
**Exit criterion:** interpreted and native executions pass the same conformance corpus on Linux x86_64, Linux aarch64 and macOS aarch64.
**Spec inputs:** spec 00 §6, 07 §6–7, 09.
**Rule:** native code is produced only from verified safe AIR (spec 07 §7). Optimizations may remove checks only when their failure is provably impossible (spec 00 §6).
## Tasks
| ID | Status | Task | Depends | Output | Done when |
|---|---|---|---|---|---|
| P7-1 | todo | Decide LLVM integration (emit textual `.ll` and invoke an external `clang`/`llc`, or link the LLVM C API); record as DD | — | `design/decisions.md` | decision recorded with TCB and reproducibility rationale |
| P7-2 | todo | Freeze opcode numbering for 0.1; binary AIR format | — | spec 07 §6, `src/air/binary.zig` | binary ↔ text round-trip; version and feature bits encoded (spec 00 §5) |
| P7-3 | todo | AIR → LLVM lowering for P0–P2 features | P7-1 | `src/backend/llvm/` | P0–P2 corpus passes natively on Linux x86_64 |
| P7-4 | todo | Native runtime: allocator adapters, regions, islands, traps, capability materialization, I/O | P7-3 | `src/runtime/native/` | runtime is listed in the unsafe report; no hidden allocation |
| P7-5 | todo | Native scheduler, synchronization primitives, atomics lowering | P7-4 | backend + runtime | P3–P5 corpus and litmus pass natively |
| P7-6 | todo | FFI (`extern "C"`), `@repr(C)`, `@align`, packed fields | P7-3 | backend | E6101 accept/reject; ABI tests against C |
| P7-7 | todo | Targets: Linux aarch64, macOS aarch64 | P7-5 | CI matrix | corpus passes on all three targets |
| P7-8 | todo | Parity runner: interpreter vs native on the full corpus | P7-5 | `zig build parity` | identical stdout and trap records |
| P7-10 | todo | Task-aware I/O (`io.read_start`, `io.write_start`, `io.wait`) and async buffer claims: buffer state `available → IN_FLIGHT → available`; access while `IN_FLIGHT` is `E4303` (moved from P3-10; needs an RFC) | P7-5 | RFC, verifier + runtime | E4303 accept/reject; deterministic completion order |
| P7-11 | todo | `thread.block` and a blocking pool: blocking host APIs run off the executor and complete by waking their task (moved from P3-11; with P7-10 forms the executor model task → async/blocking operation → native async I/O or blocking pool → completion → wake) | P7-10 | RFC, runtime | a blocking host call never stalls other tasks; deterministic completion order in the interpreter |
| P7-9 | todo | Phase exit review | all | plan status | exit criterion passes |