diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-13 09:28:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-13 09:28:38 -0300 |
| commit | 5c0230ea5a77f85de77ad4354788cd6c27aa1ef6 (patch) | |
| tree | e01a903bdee092965b86e118dfaab85c3bd60004 /anim | |
| parent | 5a40dca5adb6e9e650f55f3ec6f254a13bf50493 (diff) | |
| download | computeranim-5c0230ea5a77f85de77ad4354788cd6c27aa1ef6.tar.gz computeranim-5c0230ea5a77f85de77ad4354788cd6c27aa1ef6.zip | |
debugger: follow natural V8 deoptimization with adaptive live views
Diffstat (limited to 'anim')
| -rw-r--r-- | anim/src/disasm.zig | 10 | ||||
| -rw-r--r-- | anim/src/graph.zig | 41 |
2 files changed, 47 insertions, 4 deletions
diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig index afeef1b..b3049f1 100644 --- a/anim/src/disasm.zig +++ b/anim/src/disasm.zig @@ -1221,6 +1221,7 @@ pub fn plainRow(u: ui.Ui, row: Insn, y: f32) void { /// The same instruction atoms for a live debugger: one moment, without /// indexing an animation's entire recording. Only observed operands are annotated. pub fn liveRow(at: ui.Ui, row: Insn, y: f32, width: f32, moment: Recording.Moment, regs: zt.Regs, options: struct { + compact: bool = false, current: bool = false, executed: bool = false, lead: usize = 0, @@ -1229,13 +1230,16 @@ pub fn liveRow(at: ui.Ui, row: Insn, y: f32, width: f32, moment: Recording.Momen heat: ui.Heat = .none, }) void { const base_y = rows.baseline(y); - _ = at.address(c.address, base_y, row.addr, .{ .ink = ui.rgb(theme.color.region.code_), .lead = options.lead }); - const shift = @as(f32, @floatFromInt(@max(ui.digits(row.addr), 7) - 7)) * adv; + if (options.compact) { + at.text(.mono, size, c.address, base_y, at.print("…{x:0>4}", .{row.addr & 0xffff}), theme.color.region.code_); + at.hitAddress(row.addr, .{ .x = c.address, .y = y, .w = 5 * adv, .h = 24 }); + } else _ = at.address(c.address, base_y, row.addr, .{ .ink = ui.rgb(theme.color.region.code_), .lead = options.lead }); + const shift: f32 = if (options.compact) -64 else @as(f32, @floatFromInt(@max(ui.digits(row.addr), 7) - 7)) * adv; const u = at.moved(shift, 0); const room = width - shift - m.side; const pad = row.padding(); const mn = row.mnemonic(); - if (row.line) |line| u.text(.mono, size, c.line, base_y, u.print("{d}", .{line}), t.faint); + if (!options.compact) if (row.line) |line| u.text(.mono, size, c.line, base_y, u.print("{d}", .{line}), t.faint); u.text(.mono_bold, size, c.mnemonic, base_y, mn, if (pad) t.faint else theme.color.code.keyword); var name_buf: [192]u8 = undefined; const name = if (target(row)) |to| (moment.string(to, &name_buf) catch null) orelse "" else ""; diff --git a/anim/src/graph.zig b/anim/src/graph.zig index 9eb6f2d..03d8fc8 100644 --- a/anim/src/graph.zig +++ b/anim/src/graph.zig @@ -109,7 +109,7 @@ pub const Edge = struct { /// Its length along its way. pub fn length(e: *const Edge) f32 { var total: f32 = 0; - for (e.path()[0 .. e.n -| 1], e.path()[@min(1, e.n)..]) |a, b| total += dist(a, b); + for (e.path()[0..e.n -| 1], e.path()[@min(1, e.n)..]) |a, b| total += dist(a, b); return total; } @@ -2007,6 +2007,45 @@ fn drawMark(u: ui.Ui, v: Instant) void { /// its size: over the program column the function's graph in the form /// the scene names (`rings`; `layers` where it has no loop), centred in /// its pane, a block a pill. Its rows are the disassembly under the source. +/// Bounded live-stop graph: blocks and observations only, never inferred execution counts. +pub fn live(u: ui.Ui, m: zt.store.Moment, pc: u64, observed: [3]u64, opacity: f32) f32 { + const arena = u.f.scratch; + const probe = zt.telescope.blocks(m, pc, &.{}) orelse { + u.text(.sans, 20, 20, 38, "Control-flow blocks were not captured here", t.dim); + return 64; + }; + const raw = arena.alloc(zt.telescope.Block, @min(probe.count, 4096)) catch return 0; + const found = zt.telescope.blocks(m, pc, raw) orelse return 0; + const nodes = arena.alloc(Node, found.blocks.len) catch return 0; + const spans = arena.alloc(Span, nodes.len) catch return 0; + for (found.blocks, nodes, spans, 0..) |b, *n, *span, k| { + n.* = .{ .start = b.start, .len = b.len, .end = b.end, .w = 270, .h = 64 }; + span.* = .{ .start = b.start, .len = b.len, .node = @intCast(k) }; + } + var edges: std.ArrayList(Edge) = .empty; + for (found.blocks, 0..) |b, k| { + if (b.to) |to| if (blockAt(nodes, to)) |at| edges.append(arena, .{ .from = @intCast(k), .to = at, .kind = if (b.end == .branch) .taken else .jump }) catch return 0; + if (b.falls) |to| if (blockAt(nodes, to)) |at| edges.append(arena, .{ .from = @intCast(k), .to = at, .kind = .fall }) catch return 0; + } + var g: Graph = .{ .start = found.start, .len = found.len, .nodes = nodes, .spans = spans, .edges = edges.items, .here = blockAt(nodes, pc), .text = found.text, .exact = false }; + place(arena, &g, .layers) catch return 0; + const v = u.moved(16, 16); + var path: [most]ui.Vec = undefined; + for (g.edges) |edge| v.route(vecs(&path, edge.path()), if (edge.kind == .fall) t.faint else theme.color.rule, .{ .width = 1.5, .head = gm.head, .radius = 0 }); + for (g.nodes) |node| { + const current = node.contains(pc); + const seen = for (observed) |addr| { + if (node.contains(addr)) break true; + } else false; + const ink = if (current) theme.mark(.current).solid else t.dim; + const n = v.faded(if (current or seen) 1 else @max(0.15, opacity)); + pill(n, .{ .x = node.x, .y = node.y, .w = node.w, .h = node.h }, ui.rgb(theme.color.raised), ui.rgb(ink), if (current) 2 else 1, false); + _ = n.address(node.x + 16, node.y + 26, node.start, .{}); + n.text(.mono, 16, node.x + 16, node.y + 49, n.print("{s} · {d} bytes", .{ @tagName(node.end), node.len }), ink); + } + return g.h + 32; +} + pub const Blocks = struct { cursor: cursors.Cursor, stage: *const Stage, |
