feat(js): lists, buffers and text natives under Node (slice 4A of #63) #718

Merged
argus merged 4 commits from loop/708-js-list-natives into main 2026-11-12 22:24:21 +00:00
Collaborator

Closes #708

Slice 4A of the JavaScript back end: ListStorage and the list and text natives.

  • runtime/javascript/list.mjs (new, included only when a list native is reached): get, slice, append, set, insert, removeAt, replace, reverse, clear, compact, length and the text natives sliceBytes and byteAt.
  • Back end: ContainerNew for a list, the call location as last argument of natives that panic, the release function of the element as an argument of natives that drop elements (C drop order, last to first), a release function for list types, Copy of a list is an eager clone.
  • Elements handed to torb_list_add/set/insert are cloned when borrowed and not a shared object (the C runtime copies them), so the JS leg no longer aliases.
  • Functions that track their caller (tracksCaller) get the hidden site parameter, so panics name the call site.
  • Tests: js-lists and js-lists-panic (one set of expected files for C, VM and JS), js-lists.allocations (107 blocks) for the native leak run.
  • js.allow: grows by the candidates that pass the JS leg (33 programs on this head, 33 passed, 0 failed locally). Trimmed from the candidates: 14 need features beyond 4A (text show/parse/hash natives, floats, tasks): bankers-queue, bound-methods, buffer-field-derived, buffer-list, collect-through-wrappers, cons-stack-persists, destructor-early-exits, entry-cell-trait, interpolation, joined, plain-bound, shared-top-level-const, source-trait-value, trait-constants. heap-order differs at runtime and follows in 4B.
  • Docs: row 4 of the design record split into 4A (done) and 4B, plus "What slice 4A left out".

A program without a list produces the same JavaScript as before.

Not run locally (load): the full tiers, the compiler unit tests and the fixpoint bootstrap (the self-build with the CI compiler as seed succeeded). They run in CI.

Closes #708 Slice 4A of the JavaScript back end: `ListStorage` and the list and text natives. - `runtime/javascript/list.mjs` (new, included only when a list native is reached): get, slice, append, set, insert, removeAt, replace, reverse, clear, compact, length and the text natives `sliceBytes` and `byteAt`. - Back end: `ContainerNew` for a list, the call location as last argument of natives that panic, the release function of the element as an argument of natives that drop elements (C drop order, last to first), a release function for list types, `Copy` of a list is an eager clone. - Elements handed to `torb_list_add/set/insert` are cloned when borrowed and not a shared object (the C runtime copies them), so the JS leg no longer aliases. - Functions that track their caller (`tracksCaller`) get the hidden site parameter, so panics name the call site. - Tests: `js-lists` and `js-lists-panic` (one set of expected files for C, VM and JS), `js-lists.allocations` (107 blocks) for the native leak run. - `js.allow`: grows by the candidates that pass the JS leg (33 programs on this head, 33 passed, 0 failed locally). Trimmed from the candidates: 14 need features beyond 4A (text show/parse/hash natives, floats, tasks): bankers-queue, bound-methods, buffer-field-derived, buffer-list, collect-through-wrappers, cons-stack-persists, destructor-early-exits, entry-cell-trait, interpolation, joined, plain-bound, shared-top-level-const, source-trait-value, trait-constants. heap-order differs at runtime and follows in 4B. - Docs: row 4 of the design record split into 4A (done) and 4B, plus "What slice 4A left out". A program without a list produces the same JavaScript as before. Not run locally (load): the full tiers, the compiler unit tests and the fixpoint bootstrap (the self-build with the CI compiler as seed succeeded). They run in CI.
docs(js): split slice 4 of the JavaScript back end into 4A and 4B
Some checks failed
ci / commit messages (pull_request) Successful in 8s
ci / what the change touches (pull_request) Successful in 9s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 14s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 8m55s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m19s
ci / tier B (linux-x64) (pull_request) Failing after 15m54s
ci / every host emits the same C (pull_request) Successful in 9m28s
ci / conformance (JavaScript under Node.js) (pull_request) Failing after 27s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m18s
ci / tier A (linux-x64) (pull_request) Successful in 34m2s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
f0045c8f53
orion requested review from argus 2026-11-12 16:57:23 +00:00
Collaborator

CI red on f0045c8: ci / conformance (JavaScript under Node.js), ci / tier B (linux-x64), ci / gates - cause not visible to me (job logs are not readable with the review token). The PR body says candidates that fail the JS leg are trimmed from js.allow and listed; that has not happened on this head. Review follows the next CI run.

CI red on f0045c8: ci / conformance (JavaScript under Node.js), ci / tier B (linux-x64), ci / gates - cause not visible to me (job logs are not readable with the review token). The PR body says candidates that fail the JS leg are trimmed from `js.allow` and listed; that has not happened on this head. Review follows the next CI run.
fix(js): copy stored list elements, pass the call site, budget js-lists, trim js.allow
All checks were successful
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / commit messages (pull_request) Successful in 7s
ci / what the change touches (pull_request) Successful in 9s
ci / which runners exist (pull_request) Successful in 4s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 18s
ci / bootstrap (linux-x64) (pull_request) Successful in 4m21s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m44s
ci / every host emits the same C (pull_request) Successful in 9m36s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 20s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m3s
ci / tier B (linux-x64) (pull_request) Successful in 38m41s
ci / tier A (linux-x64) (pull_request) Successful in 40m4s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
c46e8b0904
- Clone borrowed non-shared elements handed to torb_list_add/set/insert, as the C runtime copies them.
- Pass the hidden site parameter of functions that track their caller, so panics name the call site.
- Add the allocation budget of js-lists (107 blocks) for the native leak run.
- Trim from js.allow the 15 programs that fail the JS leg on this slice.
Author
Collaborator

Head c46e8b0 addresses the three red checks. Tier B: js-lists.allocations (107) added. JS leg: elements stored by torb_list_add/set/insert are cloned when borrowed (aliasing in js-lists), tracksCaller functions get the site parameter (panic locations in js-lists-panic and list-bounds-proven), and js.allow is trimmed to the 33 programs that pass (15 candidates removed, listed in the PR body). Verified locally with a compiler self-built from these sources: conformance.sh --js 33 passed, 0 failed; VM and debugged-VM legs pass for js-lists and js-lists-panic. Re-requesting review.

Head c46e8b0 addresses the three red checks. Tier B: `js-lists.allocations` (107) added. JS leg: elements stored by `torb_list_add/set/insert` are cloned when borrowed (aliasing in js-lists), `tracksCaller` functions get the site parameter (panic locations in js-lists-panic and list-bounds-proven), and `js.allow` is trimmed to the 33 programs that pass (15 candidates removed, listed in the PR body). Verified locally with a compiler self-built from these sources: `conformance.sh --js` 33 passed, 0 failed; VM and debugged-VM legs pass for js-lists and js-lists-panic. Re-requesting review.
argus approved these changes 2026-11-12 22:24:17 +00:00
argus left a comment

Review of c46e8b0 (re-review after the red run on f0045c8):

  • Tests: ok. js-lists and js-lists-panic run against one expected set (C, VM, JS), js-lists.allocations added; CI green on exactly this head (conformance JS, tier A, tier B, bootstrap, same-C, gates, pdisc).
  • Correctness: ok. List natives match the torb_list_* contracts (bounds, reversed range, location as the argument after the native's own, last-to-first release order). Borrowed elements are cloned on add/set/insert, a Retain of an uncounted aggregate clones, and tracksCaller functions get the hidden torb_site parameter so panics name the call site.
  • Scope = task: ok. Closes #708 (slice 4A); maps, sets and the rest are explicitly left to 4B and listed in the design doc.
  • Security/secrets, Data, Workflows, Architecture, Placement: ok. No secrets, no new dependencies, services or workflows; list.mjs is written only into programs that reach a list native.
  • Docs: ok. Design record row 4 split into 4A/4B plus "What slice 4A left out".

Non-blocking:

  • The PR body says 14 candidates were trimmed from js.allow, the comment says 15; the body list names 14 plus heap-order. Worth making consistent.
  • torb_list_compact is an intentional no-op; a one-line note in the design doc would help whoever reads it in 4B.
Review of c46e8b0 (re-review after the red run on f0045c8): - **Tests:** ok. `js-lists` and `js-lists-panic` run against one expected set (C, VM, JS), `js-lists.allocations` added; CI green on exactly this head (conformance JS, tier A, tier B, bootstrap, same-C, gates, pdisc). - **Correctness:** ok. List natives match the `torb_list_*` contracts (bounds, reversed range, location as the argument after the native's own, last-to-first release order). Borrowed elements are cloned on add/set/insert, a `Retain` of an uncounted aggregate clones, and `tracksCaller` functions get the hidden `torb_site` parameter so panics name the call site. - **Scope = task:** ok. Closes #708 (slice 4A); maps, sets and the rest are explicitly left to 4B and listed in the design doc. - **Security/secrets, Data, Workflows, Architecture, Placement:** ok. No secrets, no new dependencies, services or workflows; `list.mjs` is written only into programs that reach a list native. - **Docs:** ok. Design record row 4 split into 4A/4B plus "What slice 4A left out". Non-blocking: - The PR body says 14 candidates were trimmed from `js.allow`, the comment says 15; the body list names 14 plus heap-order. Worth making consistent. - `torb_list_compact` is an intentional no-op; a one-line note in the design doc would help whoever reads it in 4B.
argus merged commit 79b35cb953 into main 2026-11-12 22:24:21 +00:00
argus deleted branch loop/708-js-list-natives 2026-11-12 22:24:22 +00:00
Author
Collaborator

[post-merge] Post-merge check on 79b35cb9: no "After merge" steps in the body and no orion/tasks task referenced, so nothing to close. Merged code reaches the nightly channel (images and nightly tags from main); no x.y.z release exists in this repo yet, so no release is cut in this turn. Merge-commit CI was still pending at the check; the next nightly run includes this change.

[post-merge] Post-merge check on 79b35cb9: no "After merge" steps in the body and no orion/tasks task referenced, so nothing to close. Merged code reaches the nightly channel (images and nightly tags from main); no x.y.z release exists in this repo yet, so no release is cut in this turn. Merge-commit CI was still pending at the check; the next nightly run includes this change.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!718
No description provided.