Phase 5: atomics through every layer (RFC 0015)

AIR: linear atomic<T> (AtomicScalar), atomic.new/take/load/store/RMW/
cmpxchg (two results)/fence with explicit orderings; feature atomics
published. Verifier: ordering tables (E4201), ordinary access (E4202),
effects [atomic] / [atomic, atomic.weak], linearity, take while lent
(E4101, also for mutex.take). Interpreter: timestamped message machine
(src/interp/weak.zig); views travel through spawn/join, channels, mutexes,
close and cancel; seq_cst reads the latest message and programs without
weak reads make no extra draw (existing records unchanged). aji explore:
exhaustive exploration that branches only before visible operations.
Litmus: 20/20 tests give exactly the oracle's sets; differential test
(1500 random programs) found no unsound outcome. .aji layer 10, Quick
Reference atomics, source coverage 67/67, audit report atomic_operations.
AIR bundle +5.9 %, QUICK.md +0.5k.
This commit is contained in:
dev committed 2026-10-06 08:05:01 +03:00
1 parent ce9ef03bc0
commit 4242132b2a
70 files changed
+2630 -80

No files matched your search

+12
View File
@@ -50,6 +50,13 @@ pub fn check(c: *Context) !void {
.task_join => if (m.declares("cancellation")) try need(c, f, inst, "task.wait"),
.task_join_cancel, .channel_send, .channel_recv, .select, .mutex_lock => try need(c, f, inst, "task.wait"),
.channel_make => try need(c, f, inst, "mem.alloc"),
// Atomics (spec 04 §25, spec 05 §13): every memory operation needs
// `atomic`; a non-`seq_cst` access also needs `atomic.weak`.
.atomic_fence => try need(c, f, inst, "atomic"),
.atomic_load => |x| try needAtomic(c, f, inst, x.ord != .seq_cst),
.atomic_store => |x| try needAtomic(c, f, inst, x.ord != .seq_cst),
.atomic_rmw => |x| try needAtomic(c, f, inst, x.ord != .seq_cst),
.atomic_cmpxchg => |x| try needAtomic(c, f, inst, x.success != .seq_cst or x.failure != .seq_cst),
.own_new, .own_array, .region_create, .region_new, .region_array, .island_create, .island_alloc, .arc_new => if (!contains(f.effects, "mem.alloc")) {
try c.report("E3101", inst.span, "allocation requires the effect mem.alloc", &.{
.{ .name = "function", .value = .{ .str = f.name } },
@@ -68,6 +75,11 @@ pub fn check(c: *Context) !void {
}
}
fn needAtomic(c: *Context, f: air.Function, inst: air.Inst, weak: bool) !void {
try need(c, f, inst, "atomic");
if (weak) try need(c, f, inst, "atomic.weak");
}
/// Adds `suggested_effects` to every E3101 reported for `f` since diagnostic
/// `first`: the complete, sorted effect list the function needs (its declared
/// effects plus every missing one). Effects stay declared by the programmer;