programs-react: render tailcall transform + fix TCO call stack#218
Merged
Conversation
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).
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Package-level change (programs-react + web theme CSS). No spec/schema changes.
Renders the
tailcalltransform context in the trace widgets and fixes a call-stack correctness bug it exposed.Changes
extractTransformFromInstruction— gather/pick-aware collector for compilertransformidentifiers, using the realProgram.Context.isTransformguard (from format: add transform context for compiler optimizations #212).buildCallStack: a TCO back-edge carries bothreturnandinvokeon 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 flaggedisTailCall.isTailCallattached inextractCallInfoFromInstructionand propagated throughResolvedCallFrame/ResolvedCallInfo.CallStackDisplay; tail-call banner variant inCallInfoPanel; CSS (--programs-transform-*, violet) mirrored into the web theme copies.Because
TraceVieweruses 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
TraceDrawerhas 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.