Skip to content

-mm=own: facts from objects, fresh results, __MEMORY_MODEL__/__OS__/__ARCH__ - #686

Merged
ASDAlexander77 merged 2 commits into
mainfrom
own-object-facts-target-constants
Oct 25, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
own-object-facts-target-constants

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

  • Per-module facts for statically linked modules. Every module built under -mm=own whose object another module may link now publishes __tsownfacts_<file>_<hash>. It is a char array listing, for each function:
    • whether it destroys nothing;
    • which places it overwrites;
    • with the new fresh field, that its result is the caller's to own.
  • Reading the facts. --own-facts=<obj> reads these facts. The driver also reads them from the static default library, which is built with --export=none, so the facts no longer depend on the export marker.
  • Fresh results. this.eye = transform3(this.eye, m) across modules is now accepted. A function that returns a borrow cannot be called from another module: that is already an error in its own module.
  • Compile-time constants. __MEMORY_MODEL__, __OS__ (win32 / linux / android / darwin) and __ARCH__ (x64 / ia32 / arm64 / arm / wasm32) are string constants. A compare of one with a string literal is folded, so the branch not taken is never generated. Only these constants' ops are folded: folding every literal-typed compare broke 46 tests, because narrowed fields and ~1 carry literal types that differ from their runtime values.

Spec: docs/superpowers/specs/2026-10-25-own-facts-from-objects-design.md

Tests

  • test-own-facts-objects: no facts → error, facts → links and prints 11, an overwriting callee → error.
  • 00memory_model_constant.ts under gc, rc, own and none (JIT and compile).
  • Full ctest: 5,758 of 5,758 pass.
  • native_ts_graphics built with this compiler: gc 247 of 247; own builds and passes every test that links.

🤖 Generated with Claude Code

…_/__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>
…rtalizes) (#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>
@ASDAlexander77
ASDAlexander77 merged commit 3fa111a into main Oct 25, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-object-facts-target-constants branch October 25, 2026 11:50
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