Commit Graph
191 Commits
Author SHA1 Message Date
waozi 7ac6643d04 Enforce named trust-boundary validation 2026-11-15 18:27:45 -03:00
waozi a86e6da41f Keep binary readers compatible with checked variants 2026-11-15 17:58:57 -03:00
waozi 68a0737e70 Add explicit scoped context 2026-11-15 15:53:25 -03:00
waozi 65cd4c7e1e Add checked temporary storage 2026-11-15 15:45:19 -03:00
waoziandClaude Opus 5.5 9ad5f481ef Name the tools by what they turn into what, and run verified ZX natively
The tools are renamed after their input and output: zi2zx lowers source
or ZIR to executable ZX, zx2native turns ZX into a native ELF, zx2wasm
into a wasm32 module, and zi2c, zi2go and zi2zir keep their roles under
cmd/ folders of the same names. zi2asm and the cmd/zir-* folders are
gone, and tests/tool_names.sh keeps the old names out. zx2native keeps
the direct encoder as its default; the machine pipeline replaces it once
it reaches parity.

The embedding API can run a verified bundle as x86-64 machine code in
memory. Code is written to RW pages, relocated, then switched to RX,
never RWX, and each instance gets its own data
(cmd/zir/zir_native_memory.c, zir_host_native.c). Backend selection is
BundleBackendPolicy: Engine and Native are strict, and Auto chooses by
platform only, never by whether one program fits. A native gap is a
named error, never a switch to the engine. Desktop x86-64 Auto stays on
the engine until the native backend is complete.

cmd/compiler_machine_image.zi adds the target-neutral machine image
contract. The machine verifiers reject unknown relocation kinds,
out-of-range symbols and addends, non-host external calls, native-width
mismatches and missing stack or fuel facts. The machine pipeline lowers
and encodes more of LIR. Docs, site pages, Kryon's build references and
the benchmarks use the new names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-14 22:07:42 -03:00
waozi 490c107fda Update the docs for the instruction engine after removing the portable VM 2026-11-14 17:54:14 -03:00
waozi cb0a762fd4 Migrate to one ZX format and delete the old route
zi2zx bundle and ziran run always write and run revision-28 executable
ZX. The semantic bundle reader and writer, the portable VM, the
TinyCC-compiled and linked native bundles with the vendored TinyCC,
bundle libraries, the VM profile, --vm, BundleInstantiatePortable,
libziran-vm.a and the ZIR-based Wasm lowering with zi2wasm are removed;
the Wasm tier, the embedding API and every tool run revision 28. Tests
of the removed VM internals and libraries are removed, and the rest run
on revision 28. Engine problems read as the diagnostics users rely on.
2026-11-14 14:03:01 -03:00
waozi 37a64372a6 Add target-aware package application APIs 2026-11-13 04:20:48 -03:00
waozi 10e854af6b Add native std facades, fix ASCII lowercase and move site examples
Portable standard facades for byte text, environment, timers, randomness,
mapped files, streams, worker pools, directory trees and threads; full ASCII
lowercase in std/unicode; examples move to examples/ with generated site
pages; Go output handles mixed-width slice bounds.
2026-11-12 19:15:45 -03:00
waozi 4838ce9b2f Improve runtimes, add an experimental direct backend, and prune Ziran tests
Prepare short portable helpers and scalar record reads, improve JSON SIMD scanning, expose one-line execution, and publish qualified Alpha benchmark artifacts. Add the experimental verified lowered execution, serialization and Linux x86-64 backend with source maps.

Physically remove 263 redundant test entry points and unused helpers, migrate retained helpers to Ziran, and execute the full retained suite without sharding. Allow ignored backup state for the managed physical Alpha workflow.

Local validation: all 268 retained tests passed across the full run and corrected targeted reruns; bootstrap matches. Current assembly verifier, x86-64, executor and serializer tests passed. Website examples and all 4661 local links passed. Six Alpha JSON/text workloads retain verified artifacts, raw samples and explicit unsupported Wasm diagnostics. The mobile sub-500 ns target remains pending.
2026-11-11 18:46:34 -03:00
waozi ca392c9085 Discover generic bundle runtime providers 2026-11-10 21:57:59 +00:00
waozi d4ef3bb7dd Remove module root limits and integrate compiler runtime updates 2026-11-09 16:46:51 -03:00
waozi ad289402c7 Add bounded portable bundle execution and preserve runtime fixtures 2026-11-08 12:16:30 -03:00
waozi e1e10237f4 Add explicit filesystem path query results 2026-11-08 02:31:33 -03:00
waozi c373715862 Add exclusive file copies and directory-name cleanup 2026-11-07 21:26:51 -03:00
waozi 677ee203ab Add native-width SIMD vectors (s16xN and friends)
u8xN .. f64xN hold two 128-bit blocks in a #target procedure's AVX2 clone
and in AVX2 builds, and one in base C, other clones, Go, TinyCC and the
VM. Simd.Lanes(T) and Simd.Blocks(T) give the count: a constant for fixed
vectors, the tier's width for native ones. Per-block operations work on
each block; WidenLow/High, MulWideLow/High and Narrow number lanes across
the vector; Make and Splat repeat one block.

Native vectors stay plain values: the checker rejects them in globals,
fields, arrays, pointers, slices, size_of, #foreign signatures and across
#target boundaries. tests/simd_native.sh checks that every compiler,
width, forced tier, Go, bundle and VM run gives the same hash, and that
Blocks reports the width each build picks.
2026-11-07 09:17:19 -03:00
waozi cef1a98d95 std/resample: NEON and SIMD128 kernels in std/simd
The ARMv7, AArch64 and WebAssembly row kernels move from #asm to std/simd,
making the same bytes. Each tap's bytes widen to 32 bits and take its whole
weight; the horizontal kernel takes four taps a step and walks pointers with
32-bit counts, which ARMv7 and wasm32 keep in one register.

On a Cortex-A53 (ARMv7) resizes run 3 to 10% faster than the assembly, and
under wasmtime about twice as fast.

ziran_simd.h: Clang's ARMv7 backend copied an unaligned 8-byte load that it
merged into a widening through the stack; Simd.LoadLow now keeps it one
vld1.

tests/lanczos_isa_bitexact.sh runs the WebAssembly modules standalone with
WASI_RUN (such as wasmtime run), without JavaScript.
2026-11-07 07:20:21 -03:00
waozi b90408fd76 Read std/resample's odd last tap with one load and round in the wide sum
An odd tap after earlier ones is the high half of the 8 bytes ending there,
so one load replaces four byte reads, and the AVX2 kernel carries the
rounding in its 256-bit accumulator. The 1.5x AVX2 upscale that ran 9%
slower than the old assembly now runs 2% faster, with the same bytes.
2026-11-07 06:27:54 -03:00
waozi dc2b2dc312 Give std's size_t libc parameters pointer-sized types
getcwd, readlink, read, write, bcopy, mempcpy, poll and curl_ws_recv took u64
or s64 for size_t, ssize_t and nfds_t values. On wasm32 that linked with a
function signature mismatch and trapped when called. A check now reads std's
bindings for these functions, and another builds file_tree_linux for wasm32.
2026-11-07 02:51:07 -03:00
waozi 43345a103f Run 256-bit SIMD as 128-bit halves below AVX2 and add Sign and AbsDiff
std/simd helpers below AVX2 take 256-bit vectors by pointer and run them
as two 128-bit halves, so no helper passes a 32-byte vector by value
(no -Wpsabi note) and GCC no longer scalarizes generic 256-bit operations.
Halves come from a 16-byte aligned union: memcpy went through the stack,
and an under-aligned union made GCC 14 fold misaligned memory operands
into SSE instructions (an internal compiler error).

Faster lowerings: NEON single-instruction reductions, x86 lane-swap
reduction trees and SSE4.1 phminposuw, pmuludq/pmuldq MulWide,
saturating Narrow from unsigned and 32-bit sources, AddPairs, MulAddPairsSat,
SSE2 Abs, u16 Min and Max, AVX2 16-bit ShiftLanes, and WebAssembly
MulHighRound.

Sign(a, b) and AbsDiff(a, b) have C (SSSE3 psign, NEON vabd, SIMD128),
Go, VM and scalar versions.

zi_ref fixes found on ARMv7: f32 arithmetic uses the exact scalar path
because NEON flushes subnormals, and the byte-shift loop is flat because
NDK Clang 19 miscompiled the nested one. zi_ref is marked unused for
programs that never take a scalar path.
2026-11-06 20:12:39 -03:00
waozi 38710d1fd9 Mark std foreign procedures that only read their strings #reads
StringRaw, BytesNil, the ed25519 seed, sign and verify calls, json
ValidRaw, net ParseRaw and hmac Sum256 only read their string and byte
arguments during the call, so Text passed to them is freed.
2026-11-06 17:28:46 -03:00
waozi 1ff8ffaa23 Write std/resample's x86-64 kernels with std/simd
The SSE2 and AVX2 #asm row kernels are now #target std/simd procedures
that make the same bytes as the scalar reference. The 128-bit kernels run
in each SSE2 to SSE4.1 copy; the AVX2 kernels take eight weight pairs a
step. On a Ryzen 9 9950X, summed over four sizes, the AVX2 horizontal
pass is about 11% faster than the assembly with GCC and 12% with Clang,
up to 23% on large downscales, and the vertical pass is unchanged. The
128-bit kernels are about 6% faster with GCC and 15% with Clang. NEON and
WebAssembly SIMD128 keep their #asm kernels. tests/lanczos_isa_bitexact.sh
also runs the SSE2, SSSE3 and SSE4.1 copies. ziran_simd.h now silences
Clang's -Wpsabi warnings too.
2026-11-06 16:55:23 -03:00
waozi dc515999bf Return owned Text from the standard text producers
TextReplace, TextJoin, TextLower, TextHex, Float64Repr, the JsonWrite
family, JoinPath, ResolvePath, WorkingDirectory, CreateTemporaryDirectory,
CopyText, ReadStandardInput, DecodeReplace and the unicode case transforms
now return Text. Callers written for a string still get one; a caller that
keeps the result as Text frees it with its owner. 1000 rounds of four
producers leave 4000 allocations when used as strings and none as Text.
2026-11-06 13:41:28 -03:00
waozi 796b560a83 Add SIMD vector types and check std/simd operations
u8x16, s8x16, u16x8, s16x8, u32x4, s32x4, u64x2, s64x2, f32x4 and f64x2,
and their 256-bit forms, are builtin value types laid out as lane arrays.
Simd.Op calls through an import of std/simd check their operands and
constants, and become reserved zi_simd_* calls in saved IR; operators on
vectors are rejected. include/ziran_simd.h holds the exact lane semantics
every backend follows.
2026-11-06 12:54:07 -03:00
waozi 92d81d2661 Keep Text call results where an owner takes them, as strings elsewhere
A Text call result stays owned in a declared, assigned or returned Text,
a Text parameter, element or field, and a discarded statement, which
frees it. Elsewhere the checker rewrites it into vec.TextDetach(result),
a string that keeps its bytes as BuilderFinish strings do, so callers
written for string results keep working. BuilderFinish in an owning
position becomes vec.TextFromBuilder. Dotted module_name.Procedure names
resolve, as types already did, through modules reached only by other
imports, in the checker and in generated C.
2026-11-06 12:51:58 -03:00
waozi 1889a8fb89 Add owned Text to std/vec with TextView lending
Text is a record whose one field is bytes: Vec(u8), so it moves and drops
like any Vec-owning record. TextView borrows a Text place, a Text place
used where a string is expected lends the same view, and TextCopy copies a
string into one. The lifetime checker also rejects moving owned storage
while its view is live. Existing string APIs are unchanged.
2026-11-06 12:00:19 -03:00
waozi d17fa57e35 Run std/resample's rows with WebAssembly SIMD128 kernels 2026-11-05 23:39:22 -03:00
waozi 5e49140f67 Poll std/thread_linux threads on macOS, which has no pthread_tryjoin_np
ThreadRun marks the record once the notification has returned, and on
macOS ThreadFinished joins only after that, so a join waits for nothing
but the thread's exit and thread-local destructors. Linux and Android
keep their nonblocking joins. Native C builds define POSIX_THREADS on
macOS too, so any program importing std/thread_linux failed to link
there. modules.html also picks up std/resample's ARMv7 summary.
2026-11-05 22:41:35 -03:00
waozi a0ff750cf2 Run std/resample's rows with ARMv7 NEON kernels
The horizontal and vertical Lanczos/bicubic/box rows get arm+neon
variants, chosen once from the kernel's hardware capabilities, that make
the scalar loops' bytes. A32 has too few registers for every argument,
so the kernels read theirs from a small record.

tests/lanczos_isa_bitexact.sh runs the ARMv7 build on the device that
ARMV7_ADB_SERIAL names, as well as under QEMU_ARM, and requires NEON there.
2026-11-05 20:48:42 -03:00
waozi d7f688846b Add std/resample: Pillow's resize as bit-exact SSE2, AVX2 and NEON row kernels
Allocation-free axis weights, row kernels and a two-pass plan over
premultiplied RGBA with fractional source boxes and row ranges for worker
threads. tests/lanczos_isa_bitexact.sh checks every kernel against the
scalar loops and those against std/image on x86-64, AArch64 and ARMv7.
2026-11-05 18:27:37 -03:00
waozi 1c897d763f Add checked edits, Unicode normalization and owned JSON, file and process APIs
ziran edit previews and applies checked source edits, and ziran compact and
expand give .zi files a lossless compact transport. Diagnostics bound each
message and report truncation. The standard library adds Unicode 17 NFC,
lowercase and properties, owned JSON documents with Into accessors and
erasers, file identity snapshots, 32-argument process channels with optional
stderr discard, socket write shutdown, longer Curl header values and fallible
image resampling. Checks cover the new APIs, and stale tests now match the
bounded diagnostics, the 4 ms kernel timestamp tick and the check runner.
2026-11-05 11:47:14 -03:00
waozi 24c22d9f22 Add fallible bounded vector capacity operations 2026-11-05 01:36:06 -03:00
waozi abb165ca84 Add Unicode printability and replacement decoding 2026-11-04 04:34:09 -03:00
waozi e02041a458 Parse the full signed 64-bit JSON integer range 2026-11-04 02:46:07 -03:00
waozi baf4a3ad98 Add portable float text and bicubic thumbnail APIs 2026-11-04 02:36:54 -03:00
waozi 4d3c91df7a Add portable Unicode case and character APIs 2026-11-04 02:03:44 -03:00
waozi 5f6d33a393 Add native tooling APIs and Win32 range workers 2026-11-04 00:50:34 -03:00
waozi 7160106b2a Snapshot Wasm byte ranges directly into browser Blobs 2026-10-31 21:04:26 -03:00
waozi dd1c95df7f Remove the Python target 2026-10-31 02:46:00 -03:00
waozi eb0e596b5e Add bounded UTF-8 repair copy 2026-10-30 19:43:01 -03:00
waozi 7f8b98bea3 Add bounded hex decoding to text tools 2026-10-30 19:08:06 -03:00
waozi a323e35d53 Probe Ogg Vorbis streams before decoding them
std/vorbis reads a stream's channels, rate and length from its pages and
identification header, without decoding or a library, so a program can
bound a stream before any decoder allocates for it. VorbisDecode probes
first and decodes only streams whose library totals match the probe.
2026-10-29 20:26:38 -03:00
waozi 893571caaf Decode in-memory Ogg Vorbis streams over libvorbisfile
std/vorbis_linux decodes one whole Ogg Vorbis stream to 16-bit PCM with a
frame limit, refusing truncated, chained or damaged streams and trailing
bytes. Its records mirror the Xiph headers, and a guard after the decoder
state is checked on every call. Only programs that import it link the
library. tests/vorbis_linux.sh compares with ffmpeg's decode and the
headers' record sizes; CI installs ffmpeg and libvorbis-dev for it.
2026-10-29 20:23:05 -03:00
waozi 68e76ca202 Open a child's redirect files before it changes directory
StartProcess changed into `directory` first, so a relative output_path
resolved under the child's folder: Wurm's private UI test asked for
build/research/ui/app.log from build/ and failed to start on a fresh
checkout (it only passed where a stale build/build/ existed). Input,
output and error now open relative to the caller, as the options
document, and std_tools_linux.sh checks it.
2026-10-29 15:33:07 -03:00
waozi 2ce4cfe6b5 Crop, flip, turn and bound pictures in std/image
CropImage, FlipLeftRight, RotateHalf and RotateRight match Pillow's crop and
transposes, and AlphaBounds gives getchannel("A").getbbox(), so art tools
that crop atlas cells and turn sprites need no Pillow.
2026-10-29 14:23:17 -03:00
waozi 41244ad308 Composite part of a picture in std/image
AlphaComposite takes an optional source box, as Pillow's alpha_composite
does, so a sprite sheet draws one sprite without copying it out first.
2026-10-29 13:12:19 -03:00
waozi 39eea24a21 Draw a picture between pixels and fill its shape in std/image
AlphaCompositeAt draws at a fractional position, blending the pixels it
falls between as a canvas's drawImage does; Silhouette fills a picture's
shape with one colour. Shovey's art outlines are drawn with both.
2026-10-29 13:11:07 -03:00
waozi c5735c828d Read, change and write pictures in std
std/image holds RGBA pictures and resizes (nearest, box, Lanczos),
composites, pastes, rotates and quantizes them with Pillow's arithmetic,
so tools give the same pixels Pillow gave. std/png_linux reads every
standard PNG and writes RGBA, RGB and palette files, std/jpeg writes
baseline JPEGs, and std/zlib_linux handles whole zlib, gzip and raw
deflate streams.
2026-10-29 13:09:30 -03:00
waozi 53113cac55 Write to standard error and read standard input from native std
std/stdio_linux gives native tools PrintError, WriteOutput and
ReadStandardInput instead of declaring write and read themselves.
2026-10-29 12:45:51 -03:00
waozi 1c9c24b03f Read, edit and write JSON documents in std
std/json_document reads a document into a tree that programs query,
change and write back. JsonWrite lays the text out as Python's json.dumps
does for the same indent, separators, ensure_ascii and sort_keys, so
native tools can rewrite JSON files Python wrote without changing their
bytes.
2026-10-29 12:44:09 -03:00