diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/tape.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/core/tape.zig b/core/tape.zig index c32c4453..ddfaa4b1 100644 --- a/core/tape.zig +++ b/core/tape.zig @@ -1041,10 +1041,40 @@ pub inline fn enter(p: ?*Pardes, input: Input) Entered { // fails when it does. if (std.debug.runtime_safety) if (p) |core| if (if (on) |t| core.tape != t else core.tape.stepping()) @panic("tape: a core's field is not the tape being stepped (tape.on)"); + // The rule the field is read by next (9b), checked beside `on` first. + // Where they disagree (9b-0's list, both the rule's to keep): a + // client's core freed (Replica.deinit, inside a Stepping scope: `on` + // records its `deinit` into a buffer let go at once; the rule records + // nothing), and a test that drives an authority's core outside a + // Stepping scope (no `on`: unrecorded; the rule records it, as a real + // session's every entry is). + if (std.debug.runtime_safety) { + const t = tapeOf(p, &input); + const listed = if (on != null) input == .deinit and t.replica else !t.replica; + if (records(t) != (on != null) and !listed) @panic("tape: the idle rule and tape.on disagree"); + } const t = on orelse return .{}; return t.enterInput(p, &input); } +/// The tape an entry steps: its core's; for a session not made yet, the one +/// its options name, or the one `Pardes.create` takes. +fn tapeOf(p: ?*Pardes, input: *const Input) *Tape { + if (p) |core| return core.tape; + const opts = switch (input.*) { + .init => |o| o, + .init_from_dump => |d| d.opts, + else => return &none, + }; + return opts.tape orelse on orelse &none; +} + +/// Whether an entry on `t` is recorded: not on the tape nobody records, nor +/// on a replica's between its steps (a client's frame drawn, its core freed). +fn records(t: *const Tape) bool { + return !(t.through or (t.replica and !t.replaying())); +} + pub inline fn leave(p: ?*Pardes, e: Entered) void { if (e.outer) on.?.leaveInput(p); } |
