Skip to content

Make the tracing core the only build, with in-wasm classification maps - #54

Merged
asterick merged 1 commit into
mainfrom
asterick/tracing-only-core
Jun 7, 2026
Merged

asterick merged 1 commit into
mainfrom
asterick/tracing-only-core

Conversation

@asterick

@asterick asterick commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

Phase A of the debugger-panel rewrite (see the design discussion): classification has to live in the core, and once it does, the dual-build stops earning its keep.

  • trace_access moves into the wasm bridge. It was an env import — a wasm→JS call on every instruction fetch, read, write, and immediate, landing in an empty JS stub. Now each access ORs its TraceType flags into in-core maps; JS reads them as zero-copy Uint8Array views (Minimon.biosTrace / .cartridgeTrace).
  • Two maps, two lifetimes: 4KB BIOS map (universal — the front-end will persist it across sessions), 2MB cartridge map (cleared on eject; will persist per cartridge ROM-hash). RAM and hardware registers (0x1000-0x20FF) are always data and aren't tracked.
  • Single build: libminimon.tracing.wasm is gone; libminimon.wasm is always -D TRACING. The .tracing toggle, binary swap in init(), trace() stub, and the Settings toggle are all removed. Native harness/libretro builds compile without TRACING and are untouched.

Verification

Browser, after 300k BIOS steps: 309 BIOS bytes classified code, 795 data, remainder untouched; the PC's byte carries INSTRUCTION|IMMEDIATE|BRANCH_TARGET|READ; the cartridge map accumulates BIOS probe reads and eject() zeroes it. Settings shows only the Running toggle; no console errors.

make -C core/test check passes (no core/src changes — the harness baselines are untouched by construction); npm run check + vite build clean.

Next: PR B (shared UI components), PR C (document model + per-cartridge persistence), PR D (the panel).

🤖 Generated with Claude Code

trace_access was a wasm->JS import called on every instruction fetch,
read, write, and immediate — millions of boundary crossings per
emulated second, landing in an empty JS stub. It is now implemented
inside the wasm bridge: each access ORs its TraceType flags into one
of two classification maps that JS reads as zero-copy Uint8Array views
(Minimon.biosTrace / .cartridgeTrace).

Two maps, two lifetimes, per the debugger design: the 4KB BIOS map is
universal (the BIOS never changes; the front-end will persist it), the
2MB cartridge map dies with the cartridge (cleared on eject). RAM and
hardware registers are always data and aren't tracked.

With the boundary cost gone there is no reason for a non-tracing
build: the dual libminimon.wasm/libminimon.tracing.wasm outputs become
a single always-tracing binary, and the .tracing toggle, the binary
swap in Minimon.init(), the trace() stub, and the Settings toggle are
all removed. The native (harness/libretro) builds still compile
without TRACING and are unaffected.

This is phase A of the debugger-panel rewrite: the maps feed the
code/data/unknown segmentation of the upcoming document model.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant