Commit Graph
5 Commits
Author SHA1 Message Date
waoziandClaude Opus 5.5 931fed4c86 Run ZX natively by default and integrate the finished assembly lanes
One commit, because the parts below only build together.

Allocator: an interval needed at the current instruction is never
evicted, and the allocated-program verifier checks that every operand sits
where the allocation says.

AArch64 encoder: compiler_aarch64.zi encodes allocated machine IR with the
shared ARM byte helpers, maps the function-address relocation,
sign-extends signed 8- and 16-bit loads and rejects what it cannot encode
with a named diagnostic. It has no AOT ELF writer yet.

Native default with checked pointers and no fallback: on linux-x86_64,
`ziran run app.zx`, `zi2zx run`, the embedding API's Auto and the Kryon
players run a bundle's verified program as native code in W^X memory.
Stray and freed pointers, double free, bounds and read-only stores trap. A
native gap is a named preflight error, nothing falls back to the engine,
and `--backend engine` picks it explicitly. zx2native uses the same
preflight. Native code exchanges module state for hot reload, checks the
stack, zeroes fresh locals, spends fuel at the engine's checkpoints and
returns records, arrays and strings from host calls. `zi2zx --debug` source
origins name lines in native traps and `zx2native --emit map`. The host
value API drops its VM prefix (HostValue, HOST_*). A call with a record
result loads the hidden result address into rax only after its stack
arguments are stored, and an indirect target stays in r10: rax could hold
a stack argument (Kryon's text-field clip guard arrived as an address) or
the target (indirect calls returning records crashed).

Self-hosting ports: compiler_backend_process, compiler_backend_cache,
compiler_native_names and compiler_runtime_emit replace the zir_c_build,
zir_c_cache and zir_c_process C, with checked bootstrap C and Makefile
rules. zir_c.toolchain again reports "compiling OUT failed:" with the head
of the compiler output and a truncation marker. The parallel scheduler no
longer stalls on a held compiler after reaping a finished job, and poll or
read errors now fail the build. A fresh BUILD_DIR (Kryon's runtime build)
builds: generated files have pattern rules, objects wait for the headers
they include, and engine flags are per object instead of leaking into zi2c.

Legacy removals F1-F10 and N1-N4: the duplicate LirX64 encoder and its
spec test, zir_c_*, zir_runtime and zir_native, nine zero-reference spec
tests, vec_capacity, the zx_metadata and native_cache_names benchmarks,
build-android-host.sh and two shell wrappers are deleted; zx2native is
machine-only; `zi2zx` rejects `--opt` on ZX input; the bootstrap is
regenerated. ASSEMBLY docs, the legacy-removal plan, the milestones and the
remaining-work plan record the current position.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 14:04:48 -03:00
waozi 6582e55feb Name the host interface in revision-28 ZX
An optional section records the type spellings and record field names
of every host capability's parameters and result, which an embedder's
host values carry and the structural payload does not. Any pointer
crosses a host boundary as an opaque handle, and platform services are
recognised only in the ziran.platform module.
2026-11-14 10:22:36 -03:00
waozi ab18ff0972 Lower string literals and counts in the direct backend
`string` lowers to the record {data: *u8, count: s64}. Literals become
deduplicated read-only byte-array globals; empty literals use a null
data pointer. Copies, reassignment, returns, .count and .data work
from source and saved IR through the portable engine and match the C
backend.

The verifier allows read-only globals only for byte-array constants of
exact length, and allows byte-array constants only as their
initializers. The engine copies the bytes per instance and traps any
store through them. Indexing, comparison and concatenation are rejected
explicitly. Native output and machine IR reject read-only data until a
read-only section exists.

bench/zx_compare.zi now lowers to a verified revision-28 container.
2026-11-12 20:18:22 -03:00
waozi 525ebb743b Lower host_api calls to explicit capabilities in the direct backend
`#foreign host_api` declarations with bool, integer and float
signatures now lower from source and saved IR to bodiless Host
functions called by host.call. The verifier keeps host signatures
bodiless and scalar, forbids direct calls, procedure values and entry
use of them, and lets host.call reach nothing else.

Revision-28 containers store the reachable capability count recomputed
from verified instructions. The reader rejects a manifest whose count
differs. The portable engine gains LirExecBindHost: a run with an
unbound capability stops before the entry executes, and host results
must use canonical bits for their declared type. Native output and
machine IR reject host calls explicitly until the native host ABI
exists.

This removes one of the two constructs that block bench/zx_compare.zi
on the new path. String values remain.
2026-11-12 19:54:05 -03:00
waozi bb89cbe24b Add the revision-28 executable ZX container and machine IR boundary
The experimental direct backend now writes and reads an opt-in
revision-28 ZX container that holds verified lowered instructions.
Stripped files run through the portable engine without source or
semantic IR. Bounded validation covers framing, identities, symbols
and reachability, and versions 26/27 are rejected with a rebuild
diagnostic. Default ziran/zi2zx output is unchanged.

Address-taken local scalars lower to fresh checked frame storage in
the portable engine and native x86-64, including aliases across calls
and recursion and stale-token traps. A verified target-neutral machine
IR keeps Allocate as an explicit effectful operation ahead of register
allocation.

ASSEMBLY/milestones.md reviews the ten-step plan and reorders delivery
around a Linux x86-64 vertical slice. It starts with an Alpha
physical-host baseline and adds staged interim comparisons. Plan
statuses now match the implementation.
2026-11-12 19:11:59 -03:00