Skip to content

programs-react: render tailcall transform + fix TCO call stack#218

Merged
gnidan merged 1 commit into
transform-contextfrom
ui-tailcall-transform
Jul 2, 2026
Merged

programs-react: render tailcall transform + fix TCO call stack#218
gnidan merged 1 commit into
transform-contextfrom
ui-tailcall-transform

Conversation

@gnidan

@gnidan gnidan commented Jul 2, 2026

Copy link
Copy Markdown
Member

Package-level change (programs-react + web theme CSS). No spec/schema changes.

Renders the tailcall transform context in the trace widgets and fixes a call-stack correctness bug it exposed.

Changes

  • extractTransformFromInstruction — gather/pick-aware collector for compiler transform identifiers, using the real Program.Context.isTransform guard (from format: add transform context for compiler optimizations #212).
  • TCO call-stack fix in buildCallStack: a TCO back-edge carries both return and invoke on one instruction. Previously the return-first gather popped the frame to empty on every tail-recursive iteration. Now the top frame is replaced in place (frame reuse) and flagged isTailCall.
  • isTailCall attached in extractCallInfoFromInstruction and propagated through ResolvedCallFrame/ResolvedCallInfo.
  • Tail-call chip in CallStackDisplay; tail-call banner variant in CallInfoPanel; CSS (--programs-transform-*, violet) mirrored into the web theme copies.

Because TraceViewer uses these components, it renders the chip automatically once fed a trace with a tailcall. All API changes are additive.

Scope note

This is the reusable programs-react layer. The interactive docs TraceDrawer has its own inline call-stack impl on a different data shape; its tailcall support + the optimizer-level selector (#6) + drawer-layout work (#9) will follow in a coordinated pass on that file.

Tests

9 new unit tests in mockTrace.test.ts (extraction, isTailCall flag, TCO frame replacement). Full programs-react suite: 31 passing. Root build clean.

Add tailcall (transform context) support to the trace widgets:

- extractTransformFromInstruction: gather/pick-aware collector for
  compiler transform identifiers (duck-typed until #212's guard lands)
- extractCallInfoFromInstruction: attach isTailCall when a tailcall
  transform is present alongside the invoke/return
- buildCallStack: a TCO back-edge carries both return and invoke on
  one instruction; replace the top frame in place (reuse) instead of
  popping to empty, and mark it isTailCall. Fixes a real call-stack
  correctness bug for tail-recursive loops.
- CallStackDisplay: tail-call chip on the reused frame
- CallInfoPanel: tail-call banner variant
- Propagate isTailCall through ResolvedCallFrame / ResolvedCallInfo
- CSS (+ web theme copies) for the transform/tailcall styling

Tested: 9 new unit tests in mockTrace.test.ts covering extraction,
the isTailCall flag, and frame replacement. Does not touch the docs
TraceDrawer opt level or examples (held for product decisions).
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-02 03:38 UTC

@gnidan gnidan merged commit 3d5b461 into transform-context Jul 2, 2026
4 checks passed
@gnidan gnidan deleted the ui-tailcall-transform branch July 2, 2026 03:34
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