Commit Graph
17 Commits
Author SHA1 Message Date
waozi 436d73cf3a Regenerate the bootstrap without the TinyCC guard
The checked-arithmetic helpers every generated module carries no longer
test __TINYC__.
2026-11-15 21:56:20 -03:00
waozi d2db9d35fe Extend verified direct assembly execution and optimization 2026-11-11 21:28:27 -03:00
waozi 4dc2da6b09 Publish measured desktop, Android and web target matrix
Compare five real examples across four targets on three measured platforms, preserving raw samples, independent output verification and artifact provenance.

Complete the WebAssembly support needed by the examples, inspect ZX bundles, prune generated C dependencies while preserving C++ linkage, and validate native script execution. Optimize only the temporary bootstrap seed and retain fresh-build measurements and historical benchmark records under bench/results.

Local tests: all 522 cases passed across the full run and corrected header-test rerun; all 16 bootstrap modules match. Playground runtime, bundle runtime, private browser layouts and matrix controls, published artifacts and local site links passed.
2026-11-10 23:50:12 -03:00
waozi e821e57722 Read integer literals and skip source comments in the Ziran compiler modules
compiler_text owns the language's integer literal rule (decimal, 0x, 0b,
leading-0 octal, _ separators, full u64 range); ZirIntegerLiteral and enum
values both use it, so enums now accept 0b and _ like the rest of the
language. compiler_scan's NextCodeToken skips line and nested block
comments for the C lexer, whose own copy of that loop is gone.
2026-11-07 12:56:00 -03:00
waozi 31e97f3585 Run std/simd multiplies, narrowing and gathers inline under TinyCC
Under TinyCC on x86-64 the 32-bit multiplies, rounding shifts, half
widening and the signed narrowings are SSE2 assembly macros, and a gather
reads its lanes straight from the table, two to a 64-bit word, instead
of four memcpy calls. Each result is stored as one 128-bit block: the
next operation's 64-bit half loads still forward from it. TinyCC's
assembler learns pmuludq and pshufd.

Where nothing inlines (TinyCC, unoptimized GCC and Clang), zi_simd_at,
zi_simd_gather_check and SliceRange check in place and call only to
report. A whole slice a[:] is the view itself in C, and a vector load,
store or gather of a whole named array addresses the array directly.
TinyCC zeroes small braced locals with stores instead of memset.

AV1's s32x4 self-guided restoration (tree-s3) against its scalar form
(tree-s2), `ziran run`, best of 3 on one core:
  d352  cached 95 -> 76 ms (scalar 79 -> 71), uncached 356 -> 336 ms (scalar 328 -> 325)
  d1080 cached 488 -> 408 ms (scalar 484 -> 408), uncached 793 -> 703 ms (scalar 802 -> 703)
The bootstrap C is regenerated.
2026-11-07 04:51:58 -03:00
waozi 52dbc1d640 Spell the runtime's macro temporaries __zi_*
Where a compiler never inlines (TinyCC, unoptimized GCC or Clang), checked
division and shifts (ZiDivS32 and the rest) and index reads (ZIRAN_INDEX,
SliceIndex, ZirVecIndex) are statement-expression macros. Their
temporaries were spelled zi__a, zi__index and the like, so an operand
named the same read the macro's own uninitialized local: ZiDivS32(zi__a,
zi__b, ...) divided garbage, and a slice index named zi__slice_index
aborted. They are now spelled __zi_*, which C reserves and the C emitter
renames in programs, as the std/simd macros already are.
tests/macro_temporaries.sh checks both spellings at -O0, -O2 and under
`ziran run`. The bootstrap C carries the new prelude.
2026-11-07 03:55:53 -03:00
waozi f0e2e2fcfa Emit calls of small same-module procedures as their bodies in C
TinyCC never inlines, so under `ziran run` every call of a tiny helper
paid a full call with all its locals on the stack. Generated C now writes
a call of a small straight-line procedure of the same module (no loops,
no module variables, scalars, pointers and small records only) as its
body in a block: arguments still run once, left to right, a return jumps
past the body, and the inlined call still costs the step its entry did.
Calls of foreign procedures stay out of inlined bodies, and private
procedures are declared ZIRAN_MAYBE_UNUSED for when every caller inlined
them.

A 1080p AV1 decode runs about 7% faster under `ziran run` and 4% faster
at -O0 with the same output; -O3 is unchanged. The bootstrap C is
regenerated. tests/call_site_inlining.sh covers argument order, name
clashes, early returns and the warning-free build.
2026-11-06 19:03:21 -03:00
waozi 0d655212ae Check indexes, shifts and divisions in place under non-inlining compilers
TinyCC and unoptimized GCC or Clang never inline, so every bounds check,
checked shift and checked division in generated C cost a helper call.
Under those compilers the helpers are now statement-expression macros that
check in place and call out only to fail; optimized builds keep the
functions. A 1080p AV1 decode runs about 17% faster under `ziran run`
(TinyCC) and 24% faster at -O0, with the same output; -O3 is unchanged.
2026-11-06 18:07:21 -03:00
waozi e834d1ccfe Prove two-dimensional indexes from guards
Generated C leaves out the bounds check of an index such as
row * stride + column when a guard bounds it: an earlier if that returns,
breaks or continues, an enclosing if or while condition, or the earlier
operands of && and ||, until a value they compare changes. Indexes and
guard comparisons become polynomials over parameters, invariant locals
and slice counts; each loop counter is replaced by its upper bound, and
the index is proven below the count or length when every step is exact.
Guards that miss the read, values moved after the guard and else-if
exits keep their checks.

On the AV1 benchmark (fixed binaries, interleaved, one core) 1080p q20
drops from 185.1 to 182.2 ms and 720p 4:4:4 is unchanged, but 1080p
10-bit q30 rises from 201.5 to 212 ms. All of that comes from the one
check left out of FindCdefDirection's sample read; the function alone runs
faster without it (102 against 105 ns per call), so the loss is a layout
effect in the decoder's context.
2026-11-06 12:41:04 -03:00
waozi f3202b3d66 Leave out bounds checks generated C proves always pass 2026-11-06 07:37:16 -03:00
waozi e859f7854f Inline small public procedures across modules through header copies 2026-11-06 06:51:58 -03:00
waozi 5f04bc5e3e Divide and shift through width-specific checked helpers in generated C 2026-11-06 06:11:13 -03:00
waozi 320637d835 Keep final short-circuit calls in native C expressions 2026-10-23 15:50:56 -03:00
waozi 244f36d7b0 Omit redundant C operand snapshots and regenerate bootstrap seeds 2026-10-23 15:47:12 -03:00
waozi ca0f6c2940 Reduce generated native runtime header dependencies 2026-10-15 22:21:02 -03:00
waozi bf880017f8 Avoid redundant aggregate temporaries and preserve value arguments 2026-10-02 04:44:41 -03:00
waozi 6c9e029987 Compile enum validation and constant evaluation from Ziran source 2026-10-01 10:42:57 -03:00