Skip to content

-mm=own: walk gaps of TSLANG 235; deferred releases; README GPU and own performance - #1135

Merged
ASDAlexander77 merged 2 commits into
mainfrom
own-borrow-gaps-deferred-release
Dec 5, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
own-borrow-gaps-deferred-release

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

-mm=own: the walk gaps of TSLANG 235

These walks free nothing but were refused. They now compile and print what gc prints:

  • A let that is never assigned, given to a call that lends it back, inside a loop: let c = this.head; while (..) { const e = nn(c); .. }.
  • A copy of a walking local that the loop condition did not narrow, from a local or a parameter head:
    • while (p) { const e = p; p = e.next; }
    • const e = p! under n > 0 || p !== null
  • A let given a lending call's result of a walking local, then stepped: let z = nn(c); z = z!.next.

How:

  • classifyLocalBorrowingLets takes copies of borrowing locals, through a fixpoint.
  • A slot that only borrows frees nothing where it is assigned again (slotEnds).
  • A copy re-roots the chain it reads.
  • walksDownOnly passes through copies, so a parameter walked through a copy is no longer a move.

These stay errors: a copy that is stored, or a copy whose list is cut or cleared while it is used (own_err_walk_copy_stored, _copy_cut, _alias_cut, _lent_copy_cleared).

-mm=own: deferred releases (first form)

A field assigned in this function while a local still uses its old value is no longer an error. For example, let q = a; q = q.next; a.next = null; print(q.i) now compiles. The old value moves into a function-local temporary, which is released at the function's exit (deferrableRelease / applyDeferredReleases).

The deferral applies only when all of these hold:

  • The release is rc's ReleaseSlot + Store into a PropertyRef.
  • The release runs at most once: its block is on no cycle.
  • The function has no invoke or landing pad.
  • The field gets a fresh value: a constant, null, a literal, new C(), or a local only ever given one.

The fresh-value rule matters. With this.head = h.next, the new value is part of the old one: the exit's release would free it, and own moves it out of the old value, so a later h.next read null. A probe caught this (it printed 10 where gc prints 12), so that shape stays refused (own_err_list_pop_used_after).

A cut on every turn of a loop also stays refused (own_err_deferred_release_in_loop, own_err_walk_const_head_cut). Where the TSLANG 219 count already applies, the count is used.

Former errors now accepted. This is wider than list walks. 15 tests that were refusals are now own/own_deferred_*.ts run tests, under the rule asked for: a release in the same function that conflicts with a live local borrow is deferred. They include:

  • spec 29: a moved-in value read after its field is overwritten (field_alias, union_moved, read_after_move_overwritten);
  • results lent out of the field (borrowed_result_outlives, lends_outlives, borrowed_result_holder_stored);
  • literals that borrow fields (borrowing_record_place_overwritten, borrowing_array_field_reset);
  • merges and split lets (merge_read_overwritten, split_let_field_overwritten);
  • fill_after_fill_call, list_lookahead_cut, weakref_after_release, moved_param_field_dropped, walk_lent_copy_cleared.

Each test was rewritten so its main reaches the assignment, allocates after it, reads afterwards and loops 1000 times. Each prints what gc prints. own_err_walk_lent_copy_cleared stays as a refusal guard, now clearing through a call, which is not deferred.

Other test changes

  • 00tslang_issue_235_own_gaps.ts and 00tslang_issue_235_own_deferred.ts run under gc, rc, none and own.
  • own_err_result_borrows_argument is accepted now: pts takes its own reference (TSLANG 219, USER RULING 11-27). It is renamed own_counted_result_borrows_argument.
  • own_err_list_cut_through_alias is still refused; the error is now reported at the use after the cut.

Docs

  • README: a GPU kernels section with the @kernel / gpuLaunch example, and a table comparing -mm=own with Rust and C++.
  • docs/own-memory-model.md: the overwrite example and the list-cut rule are updated. The old e4_overwrite example was already accepted by the TSLANG 219 count.
  • Design note: a new "What is built" section.
  • TSLANG_ISSUES.md: item 247.

CI (Linux)

The Ubuntu "debug programs, exe" leg periodically failed with "The hosted runner lost communication with the server" during the Build step. The cause was -j 8 on a 4-core, 16 GB runner: eight compiles of the MLIR sources at once ran it out of memory.

The fix:

  • -j 4, as create-release.yml already builds;
  • an "Add swap" step with 8 GB more swap;
  • rm -rf for the build-folder cleanup. Its error on a fresh runner was harmless (continue-on-error) but looked like the failure.

Verification

  • Full ctest (Windows release): 10,594 / 10,594 pass.
  • mm_fuzz: --deep (250 programs) and --classes (250 programs) give 0 failures, on top of an earlier --deep run of 300.
  • native_ts_graphics own-facts chain replay: 0 errors as written. The reverted-workarounds overlay is unchanged at 7 (overlay paths), and three more modules now compile.
  • Deferral probes, gc against own:
    • leak check: 20M deferred releases in an exe peak at 33 MB;
    • a cut on only one branch;
    • two cuts of the same field;
    • an async function with an await between the cut and the use, as an exe;
    • string, closure and any fields;
    • moved-in parameters.
  • Generators: a borrow carried across yield is refused, as before.

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits December 5, 2026 19:07
…at a local borrow outlives is deferred to the function's exit; README GPU and own performance

- copies of walking locals, never-assigned lets given to lending calls, and lets stepped from a lending
  call's result borrow what the walk borrows; a parameter walked through a copy is not a move
- a field given a fresh value while a local still uses its old one: the old value is kept in a
  function-local temporary and released at the exit (once, no loop, no try); 15 former refusals run as
  own_deferred_* tests; `this.head = h.next` (the new value part of the old) stays refused
- README: GPU kernels section with an example, -mm=own vs Rust/C++ table; TSLANG_ISSUES 247

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…16 GB runner out of memory and it lost contact; rm -rf for the build folder cleanup

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit d2cc9e0 into main Dec 5, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-borrow-gaps-deferred-release branch December 5, 2026 21:04
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