Repository navigation
Lift every JS continuation body into a standalone global function - #1383
Merged
nicolas-abril merged 7 commits intoOct 13, 2026
Merged
Conversation
Contributor
Author
|
Joint verification on main
No physical macOS/GPU/cluster gate claim. |
nicolas-abril
force-pushed
the
fix/js-top-level-continuations
branch
from
October 7, 2026 16:51
97e034e to
7ac3162
Compare
A lifted closure body returns its arrow, so a call through it costs no frame beyond the inline arrow's; its captures are the locals its emitted lines name that were allocated before it, so each closure scans only its own lines, not its whole term. Defs keep their $key$ names and closures take $0c<n>, beside $0m<n>. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Defs take name_id's JS names, a lifted closure opens on one line, its captures come from one pass over its text, and a tail apply jumps into a closure's entry by f.j alone: each run_clo now wraps a fresh arrow. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A closure's captures are the vars it reads from an outer depth, so its factory takes them as params without rescanning emitted text, which grew quadratic with nested IO steps. run_clo marks its own wrapper (j.f = f) so run_tail unwraps only that one, not a user function that happens to carry a j field. C and JS names both come from name_id, without uppercasing: closures are the def name, c and a file-wide count. process_run.c named CID_CON by hand; it now uses CID(Con).
nicolas-abril
force-pushed
the
fix/js-top-level-continuations
branch
from
October 12, 2026 17:28
36ef1ea to
ef8315c
Compare
Collaborator
|
Rebased on main and force-pushed ef8315c:
Unsupervised AI review. |
Contributor
Author
|
Verified the exact rebased head
No edits or pushes made to your revised branch. Thanks for preserving the |
comp.ts dropped js_sat, so the seam's patch found no declaration to
export and every bend-lint run threw a DriftError. The patch exports
name_id instead, and a rule's main is name_id("$", "main") after
js_lib, which returns the id js_lib gave it.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…loose ends - js_def's loop bodies scope each cycle member as its own def, so a closure in lq's body is $lq_cN, not the entry def's. - view_root reads a VIEW's root variable beside view_of, so the capture path no longer numbers VIEW's groups by hand. - A closure records each capture once, not once per read per level. - js_call returns null for an ADT head before emitting its arguments, so a captured type argument is no factory parameter. - js_lib frees the probes its binders took once the text is out. - The tests name C ids as name_id spells them now (FID_main_c*, FID_Xs_len, CID_False, ...). - js_closure_host makes its scratch directory in os.tmpdir(), so a killed run leaves nothing in the working tree. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Fixes #1086. Replaces the periodic lifting approach rejected in #1096 with normal lifting of every emitted continuation body.
Every live Lam/Mat/Efq closure now emits its body in a standalone global factory function, so nested continuation bodies no longer occur inside the parent's source. The factory takes the closure's captures as parameters: the variables its body reads from an outer depth, collected while the body is emitted (no scan of the emitted text). Word/Char/F32 VIEW operands capture the underlying variable.
run_closetsj.f = fsorun_tailunwraps only its own wrappers.C and JS names now come from one scheme,
name_id, which no longer uppercases. A closure is named after its def,cand a file-wide count ($main_c1,FID_main_c18). Names that differ only by.versus_get a_1suffix.effs/process_run.cwroteCID_CONby hand and now usesCID(Con).No period, parser/stack flag, source splitting, language-core edit, runtime ABI change or gate/cap change.
Tests:
io/do_deep(400 ordered IO steps, previously a Node stack overflow on load),compile/js_closure_views,js_closure_captures,js_closure_def_name,js_def_names,io/js_closure_host.Verified on macOS: repo 54/54, ping 55/55, test 1612/1612, cluster perf 124/124.
comp.tsis 63,257 tok (main 63,067). Compile time for 1000/2000 IO steps is linear (2000 steps used to overflow the stack). The original Linux checks are in the PR history. Linux, CUDA, Metal and--verdictwere not rerun after this revision.