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]>
2 lines
17 KiB
JSON
2 lines
17 KiB
JSON
{"schema_version":1,"stability":"stable-id","features":[{"id":"compile.assertions","status":"implemented","syntax":"#assert CONSTANT_EXPRESSION","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"The condition must be compile-time constant and effect-free.","accepted_example":"VALUE :: #run 41 + 1\n#assert VALUE == 42\n#program_export\nAnswer :: () -> s32 { return VALUE }\n","rejected_example":"#assert 0\n#program_export\nAnswer :: () -> s32 { return 0 }\n","rejection":"A false compile-time assertion fails checking.","evidence":["tests/compile_run.sh","check.assert"]},{"id":"compile.laws","status":"implemented","syntax":"#law NAME theorem bindings => condition; #proof NAME { steps; }","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"The kernel checks booleans, fixed-width modular integers, enum equality, and acyclic pure scalar procedures. Unsupported code and exhausted budgets are unknown. custom checks one example; forall checks a finite domain.","accepted_example":"#law Zero theorem x: s32 => x + 0 == x;\n#proof Zero { ring; }\n#program_export\nAnswer :: () -> s32 { return 42 }\n","rejected_example":"#law False theorem x: s32 => x + 1 == x;\n#proof False { ring; }\n#program_export\nAnswer :: () -> s32 { return 0 }\n","rejection":"An invalid certificate fails checking and cannot be waived.","evidence":["tests/laws.sh","tests/proofs.sh","tests/law_integers.sh","proofs/Scalar.lean"]},{"id":"compile.run","status":"implemented","syntax":"#run PURE_EXPRESSION","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"Compile-time execution is bounded and effect-free. Supported scalars, strings, records, and arrays can be evaluated; general metaprogramming and runtime effects remain unsupported.","accepted_example":"Double :: (value: s64) -> s64 { return value * 2 }\nVALUE :: #run Double(21);\n#program_export\nAnswer :: () -> s64 { return VALUE }\n","rejected_example":"counter: s64;\nTouch :: () -> s64 { counter += 1; return counter }\nVALUE :: #run Touch();\n","rejection":"Compile-time calls cannot mutate runtime storage.","evidence":["tests/compile_run.sh","tests/compile_values.sh"]},{"id":"execution.cpu-parallel","status":"implemented","syntax":"#parallel for RANGE { BODY }","target_support":[{"target":"c","status":"supported","limit":"Forward CPU regions execute on threads."},{"target":"go","status":"supported","limit":"CPU regions execute serially with a downgrade marker."},{"target":"zx","status":"supported","limit":"CPU regions execute serially with a downgrade marker."}],"limits":"Forward regions use CPU threads on C. Other targets and reverse regions run serially with a downgrade marker. Iterations may write only iteration-local storage; reductions and nested regions are unsupported.","accepted_example":"Square :: (value: s64) -> s64 { return value * value }\n#program_export\nAnswer :: () -> s64 {\n #parallel for 0..3 {\n local := Square(it)\n }\n return 42\n}\n","rejected_example":"shared: s64;\nAnswer :: () {\n #parallel for 0..3 {\n shared += it\n }\n}\n","rejection":"Parallel iterations cannot mutate shared storage.","evidence":["tests/parallel.sh"]},{"id":"execution.gpu-gap","status":"implemented","syntax":"#parallel_gpu for RANGE { BODY }","target_support":[{"target":"c","status":"unsupported","limit":"No GPU device backend; CPU execution is never selected."},{"target":"go","status":"unsupported","limit":"No GPU device backend; CPU execution is never selected."},{"target":"zx","status":"unsupported","limit":"No GPU device backend; CPU execution is never selected."}],"limits":"GPU-safe regions are checked, but no target has a GPU device backend. Native targets reject the selection with a Gap instead of running it on the CPU. Pointer storage, pointer-bearing calls, and allocator-backed Vec mutation are rejected.","accepted_example":"Square :: (value: s64) -> s64 { return value * value }\n#program_export\nAnswer :: () -> s64 {\n #parallel_gpu for 0..3 {\n local := Square(it)\n }\n return 42\n}\n","rejected_example":"shared: s64;\nAnswer :: () {\n #parallel_gpu for 0..3 {\n shared += it\n }\n}\n","rejection":"A GPU selection has no device backend; CPU execution is never selected.","evidence":["tests/capabilities.sh"]},{"id":"io.print","status":"implemented","syntax":"print(LITERAL_FORMAT, arguments...)","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"The format must be a string literal. Each % consumes one integer, float, bool, string, enum, record, or fixed-array argument; an enum prints as its member name and a record as {x = 1, y = 2}, with strings quoted, fixed arrays up to 16 elements, and Vecs and slices by count; %% prints one percent. Arguments are evaluated left to right before output, and floats use the shortest decimal that round-trips to the same value.","accepted_example":"#program_export\nAnswer :: () -> s32 {\n print(\"count=% percent=%%\\n\", 3)\n return 0\n}\n","rejected_example":"#program_export\nAnswer :: () -> s32 {\n format := \"count=%\\n\"\n print(format, 3)\n return 0\n}\n","rejection":"print requires a string literal format.","evidence":["tests/print.sh"]},{"id":"memory.heap-allocation","status":"implemented","syntax":"New(T) and free(pointer)","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"New allocates a zeroed value and free ignores null. Types holding owned Vec storage are rejected. Native callers must release allocations once and preserve pointer lifetimes; Python and the portable engine reject direct reads after free and double frees.","accepted_example":"#program_export\nAnswer :: () -> s32 {\n pointer := New(s32)\n if <<pointer != 0 { return 1 }\n <<pointer = 42\n value := <<pointer\n free(pointer)\n return value\n}\n","rejected_example":"#import \"vec\"\nHolder :: struct { items: Vec(s32); }\nAnswer :: () { pointer := New(Holder); free(pointer) }\n","rejection":"Heap allocation cannot bypass owned Vec cleanup.","evidence":["tests/heap_new.sh"]},{"id":"modules.named-imports","status":"implemented","syntax":"Alias :: #import \"module\" and explicit Alias.symbol access","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"The alias exposes public declarations; it does not re-export a dependency's private names or make every transitive import visible.","accepted_example":"Text :: #import \"text\";\n#program_export\nAnswer :: () -> s32 {\n if Text.LowerASCII(cast(u8)65) != cast(u8)97 { return 1 }\n return 0\n}\n","rejected_example":"Text :: #import <text>;\nAnswer :: () -> s32 { return 0 }\n","rejection":"Jai imports require a quoted module or file name.","evidence":["tests/features.sh","parse.syntax"]},{"id":"native.assembly","status":"implemented","syntax":"Function :: (parameters) -> Result #asm(\"architecture[+feature...]\", \"template\", \"outputs\", \"inputs\", \"clobbers\", \"options\") { portable body }; local #asm blocks use constraint:alias=binding operands","target_support":[{"target":"c","status":"supported","limit":"GNU extended assembly in functions and local blocks, with isolated CPU-feature variants on x86 and Linux/Android AArch64; unsupported platforms use the portable body."},{"target":"go","status":"supported","limit":"Checked Go body by default. -tags=ziran_asm enables the GNU cgo bridge with CGO_ENABLED=1, or direct AMD64 Go ABI0 for represented numeric/register-result forms with CGO_ENABLED=0. The direct path retains the checked body for pointer operands/results, stack changes, external calls/data and other unrepresented forms. Package builds include generated assembly companions; small native calls still have ABI overhead."},{"target":"zx","status":"supported","limit":"Executes the checked portable body; no native assembly emission."}],"limits":"Function variants require named scalar/pointer parameters and scalar/pointer or flat record results. Local blocks bind scalar/pointer locals or parameters; variants must bind the same names in the same order and their checked body must fall through. At most 30 input/output operands; outputs use = constraints and read/write values use tied inputs. CPU feature selection uses x86 GCC/Clang GNU-ABI drivers, Linux/Android AArch64 hardware capabilities, or direct Go ABI0 CPUID and OS register-state checks; unavailable variants use the checked body. Required features are combined with + and variants are tried in source order; duplicate/shadowed variants are rejected. Generic procedures retain assembly through specialization; operand shapes, types and portable bodies are checked for each concrete instance. asm goto, naked functions and standalone assembler files are not yet supported. Native assembly/fallback equivalence remains the author's obligation.","accepted_example":"#program_export\nAnswer :: () -> s64 {\n value: s64 = 41\n result: s64\n #asm(\"x86_64\", \"leaq 1(%[value]), %[result]\", \"=r:result\", \"r:value\", \"\", \"\") {\n result = value + 1\n }\n return result\n}\n","rejected_example":"Wrong :: (value: s64) -> s64 #asm(\"x86_64\", \"\", \"=r\", \"\", \"\", \"\") { return value }\n","rejection":"Input and output constraint counts must match parameters and results.","evidence":["tests/assembly.sh","tests/assembly_features.sh","tests/assembly_blocks.sh","tests/go_assembly.sh","tests/go_direct_assembly.sh","tests/generic_assembly.sh","bench/assembly.py","bench/cpu_features.py","bench/go_assembly.py","check.assembly"]},{"id":"numeric.implicit-widening","status":"implemented","syntax":"a narrower value where a wider type is expected, or mixed in a binary operator","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"Only lossless conversions are implicit: a wider integer of the same signedness, an unsigned integer in a wider signed type, and float32 in float64. The checker inserts an explicit cast, so every target sees the same conversion.","accepted_example":"#program_export\nAnswer :: () -> s64 {\n small: s32 = 40\n big: s64 = small\n return big + small\n}\n","rejected_example":"Narrow :: (x: s64) -> s32 { return x }\n","rejection":"Narrowing, sign changes, and integer-to-float conversions need an explicit cast.","evidence":["tests/features.sh"]},{"id":"numeric.integer-width-conformance","status":"implemented","syntax":"s8, u8, s16, u16, s32, u32, s64, u64, float32, float64, and cast(T) expressions","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"The stable differential matrix covers the published IDs below; broader operator and mixed-width combinations remain to be added.","accepted_example":"#program_export\nAnswer :: () -> s32 {\n value: s32 = 2147483647\n return value + 1\n}\n","rejected_example":"Answer :: () -> f64 { return 1.0 }\n","rejection":"Legacy f64 spelling is rejected; write float64.","evidence":["tests/numeric_semantics.sh","tests/numeric_conformance.json","numeric.wrap.add.s32"]},{"id":"ownership.automatic-vec-cleanup","status":"implemented","syntax":"Vec(T) scope cleanup and moves","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"Locals, parameters, and Vec fields in records/fixed arrays are dropped on scope exit. Moves invalidate their source. Globals are shared storage; indexed and pointer-backed field moves still have restrictions.","accepted_example":"#import \"vec\"\n#program_export\nAnswer :: () -> s32 {\n values: Vec(s32)\n VecPush(values, 42)\n return values[0]\n}\n","rejected_example":"#import \"vec\"\nAnswer :: () -> s32 {\n values: Vec(s32)\n VecPush(values, 42)\n moved := values\n return values[0]\n}\n","rejection":"Owned values cannot be read after moving.","evidence":["tests/vec.sh","tests/vec_move_expression.sh","tests/aggregate_vec_safety.sh"]},{"id":"ownership.local-text-view-mutation-check","status":"implemented","syntax":"TextView(bytes[:]) and lexical release at view scope close","target_support":[{"target":"c","status":"supported","limit":"Mutable backing bytes are observed as a borrow."},{"target":"go","status":"supported","limit":"Mutable backing bytes are snapshotted."},{"target":"zx","status":"supported","limit":"Mutable backing bytes are snapshotted."}],"limits":"Unknown heap aliases and host-backed views still need a complete lifetime model. Native and portable targets disagree when checked mutation restrictions are bypassed.","accepted_example":"Check :: () -> s32 {\n bytes: [1]u8 = .[97]\n {\n text := TextView(bytes[:])\n if text.count != 1 { return 1 }\n }\n bytes[0] = cast(u8)98\n return cast(s32)bytes[0]\n}\n","rejected_example":"Check :: () -> s32 {\n bytes: [1]u8\n text := TextView(bytes[:])\n bytes[0] = cast(u8)98\n return cast(s32)text[0]\n}\n","rejection":"Mutable backing storage cannot be changed while a view of it is live.","evidence":["tests/text_view_mutation.sh","tests/aggregate_view_lifetime.sh","tests/capabilities.sh"]},{"id":"ownership.record-vec-field-move","status":"implemented","syntax":"record.field Vec moves from local aggregate paths","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"Indexed fields, pointer-backed fields, global storage, and repeated moves in one expression remain rejected.","accepted_example":"#import \"vec\"\nInner :: struct { items: Vec(s32); other: Vec(s32); }\nCheck :: () -> s32 {\n value: Inner\n VecPush(value.items, 1)\n VecPush(value.other, 2)\n moved := value.items\n return moved[0] + value.other[0]\n}\n","rejected_example":"#import \"vec\"\nInner :: struct { items: Vec(s32); }\nBox :: struct { inners: [2]Inner; }\nCheck :: () -> s32 {\n value: Box\n VecPush(value.inners[0].items, 1)\n moved := value.inners[0].items\n return moved[0]\n}\n","rejection":"Indexed aggregate fields do not yet have a precise per-element ownership transfer.","evidence":["tests/aggregate_vec_safety.sh","tests/vec_move_expression.sh","tests/capabilities.sh"]},{"id":"procedures.defaults","status":"implemented","syntax":"Procedure :: (value: Type = expression, inferred := expression) -> Result","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"Named procedures expand omitted defaults in declaration scope. Explicit arguments run before omitted defaults. Defaults on procedure-type parameters remain unsupported; generic defaults retain documented specialization limits.","accepted_example":"Offset :: (base: s32 = 40, extra: s32 = 2) -> s32 { return base + extra }\n#program_export\nAnswer :: () -> s32 { return Offset() }\n","rejected_example":"Required :: (value: s32) -> s32 { return value }\nAnswer :: () -> s32 { return Required() }\n","rejection":"Required parameters without defaults cannot be omitted.","evidence":["tests/default_arguments.sh","tests/default_bounds.sh"]},{"id":"procedures.values","status":"implemented","syntax":"Callback :: #type (value: Type) -> Result; named capture-free procedure values","target_support":[{"target":"c","status":"supported","limit":""},{"target":"go","status":"supported","limit":""},{"target":"zx","status":"supported","limit":""}],"limits":"Named procedures can be passed, stored, returned, and called through checked procedure types. Local procedures cannot capture enclosing locals. Polymorphic procedures as values and defaults on procedure-type parameters remain unsupported; native callback ABI support depends on the target.","accepted_example":"Callback :: #type (value: s32) -> s32;\nIncrement :: (value: s32) -> s32 { return value + 1 }\nApply :: (callback: Callback) -> s32 { return callback(41) }\n#program_export\nAnswer :: () -> s32 { return Apply(Increment) }\n","rejected_example":"Callback :: #type (value: s32) -> s32;\nWrong :: (value: bool) -> s32 { return 0 }\nApply :: (callback: Callback) -> s32 { return callback(41) }\nAnswer :: () -> s32 { return Apply(Wrong) }\n","rejection":"Procedure values must match their checked parameter and result signature.","evidence":["tests/features.sh"]}]}
|