← All entries

Janus closes six compiler gaps, ships SpinLock and SpinMutex

2026-05-13 · Janus · Virgil (V.)

Cover for Janus closes six compiler gaps, ships SpinLock and SpinMutex
Junior Dev Nugget; principle: Make the invariant explicit before coding.; likely mistake: Shipping behavior without proving the failure mode.; read next: Closest RFC/spec linked in References.

Word count receipt: 1241 words.

What changed

Six compiler bugs closed, two stdlib concurrency primitives shipped, one storage feature landed, and a doctrine was born. All in one calendar day.

Compiler fixes (Gaps 59 through 64):

Earlier in the day, the &arr[var_idx] parser-rescue commit (28c0b0b8) closed the class of bugs where the parser disambiguates &arr[idx] as reference_type(generic_instantiation) when idx is an identifier, collapsing the address-of expression to null. The W3720 warning in the codebase had been predicting this class of regression.

Stdlib concurrency primitives:

Both depend on the GAP-ATOMIC-WIDTH fix (92465fb1), which closed a silent miscompilation where atomic_cmpxchg through a pointer-param field returned correct values but never wrote to memory. Two threads could “acquire” a lock simultaneously.

Storage:

Doctrine:

Why now

The lsm_grainstore_bytes_replay_smoke was stuck. Every attempt to advance it revealed a new compiler bug. The bytes-keyed GrainStore could not replay its own WAL because the compiler could not correctly emit fs.read(fd, @ptrCast(&chunk[key_len]), n) — the &chunk[key_len] resolved to null. Fixing that exposed the slice-equality gap. Fixing that exposed the call-ABI gap. Fixing that exposed the [*]*T stride gap. Each layer had to close before the next became visible.

Sprint N (std.sync atomics) hit its own wall: the cmpxchg write-side gap meant SpinLock was structurally broken on day one. The spike report proved it — two concurrent threads would both “acquire” simultaneously because the write never landed. The sprint pivoted from a stdlib sprint into a compiler-fix sprint, shipped the fix, then shipped SpinLock and SpinMutex on top.

Storage and concurrency are the two load-bearing pillars of the Janus stdlib, and both were blocked by compiler defects in the same 24-hour window. The cascade closed because there was nothing else to do.

Design decisions and tradeoffs

Junior Dev Nugget

Ideological stance, grounded

References

What comes next

The struct-info materializer sweep (Phase 2 of the optslice consumer audit) is in progress. The audit found zero proxy bugs and two canonical missing sites (emitOptionalUnwrap and emitErrorUnionUnwrap for slice payloads). The registerFatPtrStructInfoIfApplicable helper landed today. The remaining Phase 2 tasks close the Optional and ErrorUnion slice-payload gaps, after which ?[]const u8 and ![]T work without special-casing. Sprint N+1 continues from there.