diff options
Diffstat (limited to 'src/tape.zig')
| -rw-r--r-- | src/tape.zig | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/tape.zig b/src/tape.zig index 1ca064bc..7b7c02f2 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -216,6 +216,9 @@ pub const Tape = struct { /// checks. speculating: bool = false, poisoned: bool = false, + /// What stopped it: a host function's or a site's name, or a poison's + /// reason (PARDES_REPLICA_STATS counts them). + poisoned_by: []const u8 = "", /// The allocator of the core a replay makes (a replica's rollback epoch, /// src/rollback.zig), when it is not the tape's own. core_gpa: ?std.mem.Allocator = null, @@ -801,6 +804,7 @@ fn hostCall(comptime i: usize, comptime R: type, ctx: ?*anyopaque, args: anytype return r; } t.poisoned = true; + t.poisoned_by = name; return poisonOf(R); } const real = @field(t.real.vtable.*, name).?; @@ -839,7 +843,7 @@ pub fn value(comptime s: Site, comptime f: anytype, args: anytype) @typeInfo(@Ty /// lives to the step's end (scratch, or the authority's own), and the /// caller copies what it keeps. pub fn authority(comptime f: anytype, args: anytype) @typeInfo(@TypeOf(f)).@"fn".return_type.? { - poison(); + poison("the authority's own state"); return value(.authority, f, args); } @@ -872,6 +876,7 @@ fn call(comptime s: Site, a: ?std.mem.Allocator, comptime f: anytype, args: anyt // the authority's answer. if (yields and t.speculating) { t.poisoned = true; + t.poisoned_by = @tagName(s); return poisonOf(R); } if (comptime s == .clock or s == .mtime) if (t.speculating) if (t.guess) |g| { @@ -995,11 +1000,12 @@ pub fn screenAuthority() bool { return if (on) |t| t.screen_state and !t.replay and !t.speculating else false; } -/// What a speculation reached is the authority's: the input is undone and -/// waits for the authority's order. -pub fn poison() void { +/// What a speculation reached is the authority's (`why`): the input is +/// undone and waits for the authority's order. +pub fn poison(why: []const u8) void { if (on) |t| if (t.speculating) { t.poisoned = true; + t.poisoned_by = why; }; } @@ -1098,6 +1104,7 @@ pub fn beginSpeculation(t: *Tape) void { t.replay = false; t.speculating = true; t.poisoned = false; + t.poisoned_by = ""; t.no_digest = true; t.buf.clearRetainingCapacity(); t.seeFields(); |
