Repository navigation
-mm=own: what an append-only global keeps is immortal (keepers, @immortalizes) - #687
Merged
ASDAlexander77 merged 1 commit intoOct 25, 2026
Conversation
…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
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>
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.
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: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
retainedXCallbacksarrays 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.mdTests
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 prints2 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,_loopand_some_pathsnow empty their global once, so it is not a keeper and they still test escape errors.🤖 Generated with Claude Code