Skip to content

mem: --mem lists every move, unique or not, and a field move's region safety - #76

Merged
vic merged 1 commit into
mainfrom
mem-moves
Nov 12, 2026
Merged

vic merged 1 commit into
mainfrom
mem-moves

Conversation

@vic

@vic vic commented Nov 12, 2026

Copy link
Copy Markdown
Owner

--mem now lists every move of a value and says whether moving it is safe for its regions.

  • moves[] = {kind, def, from, to, unique, fromRegions, toRegions, safe, why}. Kinds: bind (val, var), assign, pattern, field (into a new box), ret (into its def's result), arg (into a callee's param), result (a callee's result into its call). from/to are node ids (a var's id is its vars id). unique: the source is unshared, so the value moves and nothing else reads it.
  • Safety: only a field move stores a box into memory. It is safe when every region of the stored value outlives (or is) the new box's own region (why: outlives), else safe: false, why: shorter, fromRegion, intoRegion. Every other move stores nothing (why: noStore).
  • New Datalog: outl(R1, R2): R2 is handled inside R1 (the innermost handle around it in its def), or at the top of a def that runs in R1, and on through outl. own(N, R): the region of the box made at site N itself. marg/mres: the moves across a call.
  • The M1 walk honors a chosen region: f{r}(..) runs f in r (before, it always ran in the innermost handle). Mem.At keeps the handles in scope by name.

New test tests/s2/mem/moves.srs: a box of r stored into a box of t inside r (safe); MW.into{r} stores a box of t into a box of r (unsafe: shorter); MW.local stores a box of r into a box of its own region q, two outl steps away (safe); bind, arg and pattern moves. Checked by hand; the program runs and prints 6.

On s2c: 47,565 moves (arg 15,978, pattern 13,776, result 6,698, field 5,701, ret 4,506, bind 903, assign 3), 0 unsafe.

Checks:

  • All old fields of the mem tests are unchanged (jq drops moves and compares).
  • 830-output identity; fixpoint; seed updated.
  • Speed on s2c: normal compile unchanged (538,804,583 -> 538,804,646). --mem 1.715 G -> 1.894 G (+10.4%).

Mutants (each builds):

mutant killed by
no own rule mem/moves and 6 more
no outl rule for lexical nesting mem/moves
no outl rule for a def's top region mem/moves (MW.local)
no outl transitivity mem/moves (MW.local)
a chosen region is ignored mem/moves (MW.into{r})
a box arg is tagged bind, not field all 12 mem tests
no marg rule all 12 mem tests

…result), unique or not, and a field move's region safety
@vic
vic merged commit 5f01736 into main Nov 12, 2026
3 checks passed
@vic
vic deleted the mem-moves branch November 17, 2026 16:48
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