Skip to content

← All updates

session

One integer meaning, sound builds, a real allocator

Session 36 was a semantics-and-soundness session: fewer ways for the three backends to disagree, and a real memory story underneath them.

Integers mean one thing now

  • add/sub/mul/neg are checked at the declared width on the interpreter, C, and native paths: i8 overflows at i8, not at i64. @wrapping wraps at the declared width, division by zero always panics, and u64 is genuinely unsigned. (Lowering used to carry i64 for every integer op, which was the root cause of most backend disagreements.)

Memory, actually managed

  • p_free is honest: double-free and freeing a pointer that is not a live heap block panic on all backends. It already caught a real leak: rc.fd counters allocated through plain malloc were never freed.
  • Size-class allocator behind malloc/free.
  • Automatic Vec reclamation: an IR escape pass frees local Vecs that provably never escape: the dropped-Vec benchmark went from 544 MB peak to 6 MB.

Faster self-hosting

Self-hosted type checking of the compiler went from about 205 s to 15 s, with Vec_get/Vec_len inlined natively.

Bugs that were invisible

p_system crashed every native program on return; a pert_str_hash edge case could lose HashMap keys near page ends; hex literals above i64::MAX read as 0 on fidesc; native panics now actually print (via a vectored exception handler for stack overflow and invalid access). The Rust suite sits at interp 286/286, C 285/285, PE 287/287, with 66/66 expected-fail tests correctly rejected, and every stdlib module now compiles standalone in CI (scripts/check-stdlib.sh).