Skip to content

← All updates

release

The native emitter reproduces itself bit-for-bit

The deepest self-hosting check there is: a compiler that emits machine code, applied to itself, producing the same machine code. Session 35 closed that loop.

The fixpoint, natively

  • fid-n5.exe emit compiler/main.fd → fid-n6.exe, byte-identical (12,304,896 bytes). The natively-emitted compiler reproduces itself bit-for-bit: no C toolchain anywhere in the loop.
  • Cross-emitter parity too: the native-emit binary and the C-compiled binary are byte-for-byte identical on the same source.
  • Faster than the C path: dump-c on the full compiler in 3m21s vs 4m21s for the C-built compiler. fid emit on a typical test file runs about 50 ms of actual codegen.

Speed work in the PE emitter

Bulk strlen/memcpy string stubs (was byte loops), rep movsq struct copies, word-at-a-time hashing, a store→load forwarding peephole (−1,468 loads in a small exe), cmp+jcc fusion, slot reuse that shrank stack frames from ~140 KB to ~1.28 KB max, and inlining of p_vec_len/p_map_len/*_is_empty.

Correctness catches

Windows guard-page stack probes for frames over 4 KB (the missing piece behind deep-recursion crashes), p_string_starts_with actually compares now (it was a stub returning true), and emit is deterministic: free-slot order no longer depends on HashMap iteration.