Skip to content

-mm=own: what an append-only global keeps is immortal (keepers, @immortalizes) - #687

Merged
ASDAlexander77 merged 1 commit into
own-object-facts-target-constantsfrom
own-immortal-keepers
Oct 25, 2026
Merged

ASDAlexander77 merged 1 commit into
own-object-facts-target-constantsfrom
own-immortal-keepers

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Stacked on #686. Merge that first; this PR's base then becomes main.

Summary

  • Keepers. A keeper is a non-exported array global that is only ever pushed onto: no pop, splice, element store or replacement. What it holds lives to the end of the program.

  • Marking. A value pushed into a keeper is made immortal (ts.MakeImmortal, ts.MarkImmortalCell) where its origin is known:

    • a bound method's object;
    • a closure's box, its cells and its by-value copies;
    • a fresh value.

    Marking checks the header first, so stack objects and read-only literals are never written. A pushed value of unknown origin is an error.

  • Parameters. A function that pushes a parameter keeps it for good, and its callers mark the argument (a fixpoint over calls). A function another module may call has to say so with @immortalizes("p"). That is checked against the body, and the marker is carried in re-parsed and printed declarations. A function that keeps for good may not be called through a value, and its class family members must agree.

  • Inference and stack promotion. Inference treats these values as immortal: their retains are erased, and they may be pushed, stored or captured anywhere. Stack promotion treats them as escaping, with the reason "kept for good".

  • Why. Generated wrappers keep callbacks in retainedXCallbacks arrays for gc. Under own that push is now accepted, and own proves the callback lifetimes itself.

Spec: docs/superpowers/specs/2026-10-25-own-immortal-keepers-design.md

Tests

  • own_immortal_keepers: run under own, gc, rc and none. Callbacks registered from functions that have already returned still read correct state after their memory was handed out again.
  • test-own-keepers-objects: the keeper sits in a library object; the importer marks what it passes, and the program prints 2 102 2.
  • own_err_keeper_* covers five shapes: unknown origin, exported without the marker, a marker that disagrees with the body, called through a value, and a popped array (no keeper, so the old move error stays).
  • own_err_closure_escape_twice, _loop and _some_paths now empty their global once, so it is not a keeper and they still test escape errors.
  • Full ctest: 5,773 of 5,773 pass.

🤖 Generated with Claude Code

…rtalizes)

- A keeper is a non-exported array global only ever pushed onto: what it
  holds lives to the end of the program. A value pushed into one is made
  immortal (ts.MakeImmortal, ts.MarkImmortalCell) where its origin is known:
  a bound method's object, a closure's box, cells and copies, a fresh value.
- A function that pushes a parameter keeps it for good; its callers mark the
  argument (a fixpoint over calls). One another module may call says so with
  @immortalizes("p"), checked against the body and carried in declarations.
- Inference treats such values as immortal; stack promotion as escaping.
- Tests: own_immortal_keepers (all models), own-keepers-objects.cmake,
  own_err_keeper_*. Closure-escape error tests now empty their global so it
  is no keeper.
  Spec: docs/superpowers/specs/2026-10-25-own-immortal-keepers-design.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 86f6da4 into own-object-facts-target-constants Oct 25, 2026
@ASDAlexander77
ASDAlexander77 deleted the own-immortal-keepers branch October 25, 2026 11:26
ASDAlexander77 added a commit that referenced this pull request Oct 25, 2026
…_ARCH__ (#686)

* -mm=own facts from objects, fresh results, and __MEMORY_MODEL__/__OS__/__ARCH__

- Every own module whose object another module may link publishes
  __tsownfacts_<file>_<hash> (no-drops names, overwritten places, and a
  `fresh` field when the result is the caller's to own), whatever it
  exports: the default library's static lib.obj is built --export=none.
- --own-facts=<obj> reads them; the static default library's are read too.
  Imported calls get __own_no_drops / __own_drop_fields / __own_fresh_result.
- __MEMORY_MODEL__, __OS__ and __ARCH__ are compile-time string constants;
  a compare of one with a string literal is folded, so the branch not
  taken is not generated. Only those constants' ops are folded.
- Tests: own-facts-objects.cmake, 00memory_model_constant.ts (all models).
  Spec: docs/superpowers/specs/2026-10-25-own-facts-from-objects-design.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* -mm=own: what an append-only global keeps is immortal (keepers, @immortalizes) (#687)

- A keeper is a non-exported array global only ever pushed onto: what it
  holds lives to the end of the program. A value pushed into one is made
  immortal (ts.MakeImmortal, ts.MarkImmortalCell) where its origin is known:
  a bound method's object, a closure's box, cells and copies, a fresh value.
- A function that pushes a parameter keeps it for good; its callers mark the
  argument (a fixpoint over calls). One another module may call says so with
  @immortalizes("p"), checked against the body and carried in declarations.
- Inference treats such values as immortal; stack promotion as escaping.
- Tests: own_immortal_keepers (all models), own-keepers-objects.cmake,
  own_err_keeper_*. Closure-escape error tests now empty their global so it
  is no keeper.
  Spec: docs/superpowers/specs/2026-10-25-own-immortal-keepers-design.md

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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