brain

tamnd's digital brain — notes, problems, research

43815 notes

Cosmopolitan Libc

One binary, six operating systems, two ISAs. The APE format and cosmocc toolchain.

native-codegenruntime
Hare

Tiny systems language built on QBE, deliberately constrained, BSD/Linux-only, manual memory.

native-codegenaot
The Go Runtime as a Library

cgo, c-shared, c-archive: keep vm3 in Go and call into it from native code.

native-codegenruntime
Julia

JIT-first scientific language adding a real AOT path via juliac and a trimming-based static binary mechanism.

native-codegenaot
V Language

Statically-typed Go-influenced language that defaults to emitting C, with experimental native and LLVM backends and a multi-mode memory model.

native-codegenaot
DynASM as a Code-Generation Backend for Mochi

Mike Pall's preprocessor-driven assembler with runtime patching; LuaJIT's secret weapon.

native-codegenbackends
golang-asm as a Code-Generation Backend for Mochi

Go's internal assembler exported as a library, already used by Mochi's vm2jit.

native-codegenbackends
Copy-and-Patch as a Code-Generation Backend for Mochi

Stencil-based binary stitching from OOPSLA 2021, now shipping in CPython 3.13/3.14.

native-codegenbackends
glibc

The default Linux libc, and the reasons "fully static linking" is officially unsupported.

native-codegenruntime
chibicc: A Minimal C Compiler as a Mochi Backend Reference

Rui Ueyama's ~10k LOC C compiler that emits x86-64 GAS assembly directly from a recursive-descent parser. The clearest published example of a single-pass codegen pipeline that produces correct code with no IR, no SSA, no register allocator.

native-codegennaive
libgccjit as a Code-Generation Backend for Mochi

GCC as a shared library, used by Emacs native compilation, GCC Rust, GDC, Cython.

native-codegenbackends
RISC-V RV64GC

The general-purpose 64-bit RISC-V baseline plus vector and recent extensions.

native-codegentargets
The Per-Opcode Template JIT Pattern

The general pattern that Sparkplug, Liftoff, JSC Baseline, and the HotSpot template interpreter all instantiate. Per-op native template, fixed register convention, stub calls for slow paths, optional inline caches as patchable code regions.

native-codegennaive
WebAssembly

Wasm 3.0 (2025) as the stable target, plus WASI Preview 2/3 and the component model.

native-codegentargets
musl libc

The static-friendly C library that makes "build once, ship anywhere" actually work on Linux.

native-codegenruntime
Other ISAs: PowerPC, MIPS, LoongArch, s390x, Apple GPU/Metal

Survey of niche or specialized architectures that MEP-42 should be aware of but probably defer.

native-codegentargets
Wasm Baseline Compilers: Liftoff, RabaldrMonkey, Winch

A converged design pattern across three independent implementations: per-opcode template emission, a virtual operand stack with lazy register promotion, no IR, no global optimization. The current state of the art in "fast and simple" Wasm code generation.

native-codegennaive
AArch64 Windows (Windows-on-ARM64)

Windows 11 on Snapdragon X / X2 Elite, Surface Pro X lineage, and ARM64EC interop.

native-codegentargets
Skipping the Linker Entirely

Emitting a self-contained executable from the compiler, no external linker required.

native-codegenlinkers
Copy-and-Patch Compilation

Stencil-driven code generation that harvests pre-compiled opcode snippets at build time and stitches them into native code at runtime via relocation patches. No IR, no register allocator, no instruction selector. The technique CPython 3.13+ ships in production.

native-codegennaive
Crystal

Ruby-syntax statically-typed language with global type inference, LLVM backend, and Boehm GC.

native-codegenaot
Zig Self-Hosted Compiler

Systems language rebuilding its compiler around its own native backends, with LLVM demoted to an optional path.

native-codegenaot
Classical Single-Pass Code Generation

Tree-walk to tuples to native assembly. The textbook recipe from the Dragon Book and Cooper/Torczon, still the right starting point when you want correctness before performance.

native-codegennaive
GraalVM Native Image

Closed-world AOT compilation that turns a managed JVM application into a self-contained native executable.

native-codegenaot
.NET NativeAOT

Microsoft's production successor to CoreRT: trimmed CoreCLR plus RyuJIT-as-AOT, shipping single-file native binaries.

native-codegenaot
LLVM as a Code-Generation Backend for Mochi

The workhorse SSA infrastructure, version 20 era, evaluated for MEP-42.

native-codegenbackends
MIR as a Code-Generation Backend for Mochi

Vladimir Makarov's lightweight JIT+AOT, fast compile times, lazy basic-block versioning.

native-codegenbackends
GNU ld (bfd) and gold

The historical Linux workhorse and its dying sibling.

native-codegenlinkers
QBE as a Code-Generation Backend for Mochi

Quentin Carbonneaux's deliberately tiny SSA backend, "70% of LLVM in 10% of the code."

native-codegenbackends
Apple's New Linker (ld_prime / ld_new)

The closed-source Mach-O linker that ships in Xcode 15 and later.

native-codegenlinkers
Cranelift as a Code-Generation Backend for Mochi

Bytecode Alliance's Rust-native SSA backend, ISLE-driven, ~10x faster compile than LLVM.

native-codegenbackends
x86_64 System V AMD64 ABI

The default 64-bit Unix ABI: Linux, macOS, FreeBSD, OpenBSD, NetBSD, illumos.

native-codegentargets
mold: The Modern Linker

The fastest production ELF linker, single-author, MIT licensed.

native-codegenlinkers
x86_64 Windows (Microsoft x64) ABI

The 4-register fast-call convention used by every Windows-on-AMD64 binary.

native-codegentargets
AArch64 AAPCS64

The base 64-bit Arm calling standard, with Apple and Microsoft deltas called out.

native-codegentargets
Sparkplug: V8's Non-Optimizing Baseline JavaScript Compiler

A single-pass, IR-free transpiler from Ignition bytecode to native machine code, designed to add a fast tier between an interpreter and an optimizer with minimal engineering cost.

native-codegennaive
JavaScriptCore Baseline JIT

Apple WebKit's original template-style baseline compiler, the longest-running production baseline JIT for a dynamic language, and the design template for every modern four-tier VM.

native-codegennaive
LLD: The LLVM Linker

One binary, four object formats, cross-link from any host.

native-codegenlinkers
Rust Polonius (2026)

The state of Rust's borrow checker as the Polonius "alpha" lands behind a nightly feature gate, and what a non-ownership language can still steal from it.

memory-safetyownership
V8 Pointer Compression Cage

A direct ancestor of vm3's 32-bit slab index. V8 squeezes 64-bit pointers down to 32-bit offsets within a per-isolate 4 GB virtual region (the "cage"). Cut V8's heap by 43%, Chrome renderer memory by 20%.

memory-safetyruntime
Scala 3 Capture Checking

Capability tracking in the type system. Each value's type may carry a capture set listing which capabilities it could reference. Foundation for capability-based effects, separation checking (System Capybara), and ownership for resources.

memory-safetyownership
W^X Enforcement in Modern JITs

What every shipping JIT must do on day 1 to be production-grade: never have a code page that is both writable and executable to the same thread at the same time.

memory-safetyruntime
Spectre Mitigations in Hosted JITs

Speculative-execution attacks haven't gone away. As of May 2026, every shipping JIT either implements index masking + bounds-check hardening, or relies on process-level Site Isolation, or both.

memory-safetyruntime
Perceus (Koka)

"Garbage-free" precise reference counting with reuse — in-place updates without locks, statically inserted at compile time.

memory-safetyruntime
MSWasm — Memory-Safe WebAssembly

A WebAssembly extension that replaces linear memory with segments and handles. Handles are unforgeable, typed pointers carrying bounds and provenance — closely modelled on CHERI capabilities but pure software.

memory-safetyruntime
Project Verona Regions

Microsoft Research's experimental concurrent-ownership language. Ownership is over **regions** (groups of objects) instead of individual objects. Cowns (concurrent owners) serialise access; behaviours schedule work over multiple cowns atomically.

memory-safetyownership
WebAssembly Segmented Memory (and friends)

The CG-track answer to "what's beyond a single 4 GB linear memory?" Multiple memories shipped in Wasm 3.0 (Sep 2025). Memory64 shipped at the same time. A formal "segmented memory" proposal in the MSWasm vein has not yet entered the CG track but is influencing design.

memory-safetyruntime
WasmGC

Native GC primitives in a portable bytecode. Ratified in Wasm 3.0 (Sep 2025), shipped in all major browsers by Dec 2024. Dart, Kotlin, OCaml, Java/Scala/Scheme can now compile to Wasm without bundling a GC.

memory-safetyruntime
CompCert and the Verified-Compiler Toolchain

The production-grade formally verified C compiler, the CompCertO / Owlang line, and why it matters for JIT verification.

memory-safetyverification
curl, Daniel Stenberg, and the "Is C/C++ The Actual Problem?" Debate

Stenberg's curl CVE data, the Hyper / Rust experiment, and the unresolved 2026 question of whether memory-safe languages are the whole answer.

memory-safetyindustry
Inko — Singly-Owned Values

Single ownership with deterministic destruction, multiple simultaneous borrows allowed, runtime borrow-count enforcement. No GC, no compile-time borrow checker, no lifetime variables. Concurrency uses `uni T` (unique values) for safe inter-process transfer.

memory-safetyownership
EU Cyber Resilience Act and Memory Safety

The CRA's 2026-2027 enforcement timeline and the implicit pressure toward memory-safe languages.

memory-safetyindustry
Separation Logic for Managed (GC'd) Heaps

Iris-based separation logics with space credits, tracing GC, and the 2025 IrisFit + Nextgen-Modality lines.

memory-safetyverification
Lobster — Compile-Time Reference Counting

A pragmatic language by Wouter van Oortmerssen that elides 95% of refcount ops at compile time through flow-typed lifetime analysis. Cycles handled by a cleanup at program exit.

memory-safetyruntime
Aeneas

Rust verification by functional translation: compile Rust to a pure lambda calculus, verify there.

memory-safetyverification
MTE in a Managed Runtime

MTE in a Managed Runtime

memory-safetyhardware
MarkUs and quarantine-style UAF prevention

MarkUs and quarantine-style UAF prevention

memory-safetyhardware
ZGC — Generational, Colored-Pointer GC (OpenJDK)

Java's flagship low-latency collector. Sub-millisecond pauses on multi-TB heaps via colored 64-bit pointers and concurrent everything.

memory-safetyruntime
CISA Secure-by-Design Pledge and the January 2026 Memory-Safety Deadline

The voluntary US federal pledge that has set the de-facto industry baseline for memory-safety roadmaps.

memory-safetyindustry
DoD Safe Coding Practices and Military / Aerospace Memory-Safety Procurement (2024-2026)

The DoD's evolving acquisition posture on memory-safe languages, the SWFT framework, and aerospace coding standards.

memory-safetyindustry
CakeML and the Verified-JIT Line

The bootstrapping verified ML compiler, its 2024 PLDI agenda, and the FM-JIT verified-JIT effort that builds on it.

memory-safetyverification
CHERIoT

CHERIoT

memory-safetyhardware
Google: Android Rust, Chrome Rust, V8 Sandbox

Google's published 2022-2026 data on memory-safety progress — Android's 76% → <20% trajectory, the CVE-2025-48530 near-miss, the V8 sandbox.

memory-safetyindustry
White House ONCD "Back to the Building Blocks" (February 2024)

The White House Office of the National Cyber Director's memory-safety report and the C/C++-adverse federal stance.

memory-safetyindustry
CHERI (Next Generation)

CHERI (Next Generation)

memory-safetyhardware
Intel CET Shadow Stack + IBT

Intel CET Shadow Stack + IBT

memory-safetyhardware
Use-After-Free Landscape: Temporal vs Spatial, kCFI, and the Proven-by-Construction Story

The 2024-2026 industry picture on temporal memory safety, kernel mitigations, and the convergence of UAF defences.

memory-safetyindustry
Hylo (formerly Val)

Mutable value semantics with subscript-based projection borrowing, no lifetime variables, and the Law of Exclusivity enforced at call sites.

memory-safetyownership
Arm MTE

Arm MTE

memory-safetyhardware
Capability-Machine Formalism and Endorsement Relations

Cerise, the CHERI-C Coq memory model, and capability-safety logical relations as the formal model behind handle-based runtimes.

memory-safetyverification
Microsoft "70% of CVEs Are Memory Safety" Statistic

The canonical industry data point on memory-safety vulnerability prevalence, and every follow-up through 2026.

memory-safetyindustry
Kani

AWS's bit-precise bounded model checker for Rust, deployed in CI on Firecracker and the standard library.

memory-safetyverification
Swift consuming / borrowing / inout & Noncopyable Types

Swift 6.x has shipped a complete move-only/noncopyable system layered on top of ARC. Parameter conventions are explicit; the law of exclusivity (Swift's variant from 2017) supplies the static aliasing discipline.

memory-safetyownership
RustBelt and Iris

Foundational separation-logic verification of Rust's safe / unsafe core, and its 2024-2026 RefinedRust successor.

memory-safetyverification
JavaScriptCore — Riptide

WebKit's retreating-wavefront concurrent garbage collector. Marks objects while JS runs, throttles allocation when it falls behind, and uses logical versioning to skip clearing bitmaps.

memory-safetyruntime
V8 Sandbox

A purely software in-process sandbox for the V8 JS heap. Ban raw pointers, replace with offsets into a 1 TB sandbox region and indices into out-of-sandbox pointer tables. About 1% perf cost, enabled by default in Chrome 123. Every modern JIT is moving this direction.

memory-safetyruntime
MEP-41 Research Substrate: Memory Safety Advances 2023–May 2026

MEP-41 Research Substrate: Memory Safety Advances 2023–May 2026

memory-safetyoverview
NSA "Software Memory Safety" Guidance (2022) and the June 2025 Reissue

The NSA's formal language-level guidance, the named-language list, and the joint CISA reissue.

memory-safetyindustry
Mojo (2026)

A Rust-like ownership system with simpler call-site syntax, taped onto a Python-shaped surface, sitting on MLIR, headed to open source in fall 2026.

memory-safetyownership
Linear Haskell

Linearity attached to function arrows, not to types. Backwards-compatible: ordinary code continues to type-check unchanged. Experimental since GHC 9.0; still labelled experimental in 9.12 / 9.15 (2024–2026).

memory-safetyownership
MMTk and LXR

A research framework that cleanly separates GC plans from policies, plus the LXR collector that proves a stop-the-world RC+mark-region design can beat industrial concurrent GCs on tail latency.

memory-safetyruntime
Formal Models of the Rust Borrow Checker

Stacked Borrows, the 2025 Tree Borrows replacement, and the trajectory of NLL / two-phase formalisation.

memory-safetyverification
Verus

Microsoft Research's SMT-backed Rust verifier, the leading tool for verified systems software at scale in 2025-2026.

memory-safetyverification
Pony Reference Capabilities

Six capabilities (iso, trn, ref, val, box, tag) make actor-based concurrency data-race-free at compile time. Production at WallarooLabs and Microsoft; foundation for Verona's region work.

memory-safetyownership
Creusot

A deductive verifier for safe Rust that compiles to Why3 and discharges to off-the-shelf SMT solvers.

memory-safetyverification
Arm PAC + BTI

Arm PAC + BTI

memory-safetyhardware
Intel LAM (Linear Address Masking) and the x86 top-byte-tag story

Intel LAM (Linear Address Masking) and the x86 top-byte-tag story

memory-safetyhardware
Chrome Memory-Safety Data and the Rust-in-Chrome Rollout

Chrome Security's published per-quarter memory-safety data for 2024-2026, the JSON / PNG / fonts Rust rollouts, and the V8 sandbox.

memory-safetyindustry
Austral

Strict linear types as the load-bearing primitive for memory and protocol safety, plus capability-based effect control. Spec-and-compiler-small enough to read in a weekend.

memory-safetyownership
Jane Street OxCaml — Modes (Uniqueness, Locality, Linearity)

Orthogonal modes layered onto OCaml's type system. Mode is a property of a value, separate from its type, tracked through inference. Production in Jane Street; open-sourced as OxCaml in 2025.

memory-safetyownership
Scudo & friends: hardened allocators in production

Scudo & friends: hardened allocators in production

memory-safetyhardware
Arm Morello

Arm Morello

memory-safetyhardware
Vale Generational References

The direct intellectual ancestor of vm3's handle design: a per-allocation generation counter, a per-reference remembered generation, and a check on every dereference. Same idea, different layer.

memory-safetyownership
V8 — Orinoco + Oilpan

Chrome's two cooperating collectors. Orinoco runs V8's young-generation JS heap in parallel; Oilpan is Blink's traced C++ GC, recently hosted inside V8 as a library, learning to do generational collection with conservative stack scanning.

memory-safetyruntime
Android Scudo + MTE inside ART

The canonical "secure allocator inside a managed runtime." Scudo is Android's hardened native heap, used for ART's non-managed allocations (JIT code, off-heap buffers, JNI). Pairs with ARM MTE on Armv9 hardware for hardware-checked tagging.

memory-safetyruntime
Roc — Perceus in production-ish

The biggest real-world deployment of Perceus reference counting, layered with Morphic alias analysis and "seamless slices" so functional code rarely allocates.

memory-safetyruntime
Colophon

This book describes the Zig programming language as of Zig 0.16.

zigbook
Appendix J. Index

A

zigbook
Appendix I. Exercise Answers

These are short answers or sketches for selected exercises from the book. Many exercises have several reasonable solutions. The important part is clarity and correctness.

zigbook
Appendix H. Zig 0.16 Migration Notes

This appendix records the kinds of changes that matter when moving older Zig code to Zig 0.16. It is a practical checklist, not a full release history.

zigbook