VM vs native parity — what is guaranteed
VM (zz run) and AOT (zz build / zz run --native / zz test --engine native)
must agree unless this page says otherwise. If agreement is impossible, the checker
errors instead of letting backends diverge.
Guaranteed identical
Section titled “Guaranteed identical”- Integers: wrapping
+ - *,INT64_MIN / -1errors, divide-by-zero errors,-fwrapv, shifts mask& 63, arithmetic>>. - Floats: no
-ffast-math, no-march=native, cross uses safe baseline CPU. - Strings: interpolation,
{{/}}, backticks, format specs, byte-offset search matching Ruststr::findedges, Unicodetrim_spanon both. - Values: deep-copy reads/binds, CoW unobservable, struct print
Type{field: value, ...}on both,bytesJSON as int arrays. - Enums/aliases/generics: erase identically (same opcodes / same C, verified by test).
- Errors:
fs:<op>:<code>: <path>diagnostics,Result/Optionshapes,regexp/crypto/processtwins viazz_native_rt. - Concurrency: snapshot isolation + unbounded channels on both
(
zz_value_dup, thread-local arenas, thread-safe refcounts/intern).
Test the guarantee
Section titled “Test the guarantee”parity_strict!(...)per fixture indual_engine_parity.rs.- Sweep
parity_discover_all_fixturesfails on any unexpected result. - Genuine gaps file an issue and list in
known_native_failures(); the sweep shoutsFIXED!when a listing goes stale — remove it same day. - Every strict fixture must be batched or
EXCLUDEDwith reason (batched_parity.rs+batch_lists.rsinventory test enforces). - Order-independent: libtest runs parallel — never rely on another test’s global; re-register idempotently.
Known divergences (by design)
Section titled “Known divergences (by design)”,compile_faildoctests: VM-only (AOT compiles whole files upfront → ignored there).zz run --watchis VM-only (native rebuilds are minutes, not ms).- PGO/profile flows are native-host-only;
--pgo --target <foreign>rejected. --staticrejected on macOS targets.- Coverage binary detail differs; semantics do not (see
docs/coverage.md).
Adding backend-sensitive work
Section titled “Adding backend-sensitive work”Follow the five locksteps in Architecture:
funcs.rs signature + VM impl + C twin + native_impl mapping + fixtures in
e2e.rs + dual_engine_parity.rs (+ batch or EXCLUDED). Contracts for
search/byte natives: byte offsets O(1), backend-identical, Rust str::find edges.