tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Perceus: interprocedural borrow inference, bottom-up over recursive groups (#336 groundwork)

`borrow::infer` now processes the program in *units* — a recursive
group (`callgraph::recursive_groups`) merged with the chunks split from
its functions (`opt::split`) — ordered callees-first over the unit DAG.
Each unit's rules iterate to their fixpoint with every callee's
`borrowed` set already final, so "passed to a callee's borrowed
parameter" (which `uses_with` already models as non-consuming) is read
off final signatures instead of propagating through whole-program
re-scans. The result is the same greatest fixpoint the global loop
computed — a monotone removal system decomposed over the units' DAG —
and the Perceus snapshot tests, which print every borrowed parameter,
are byte-identical.

One deliberate strengthening: a split chain merged with its function's
recursive group is one unit, so a chunk's tail call *into* the group
(a recursive function big enough to be split) forces owned parameters
exactly as the group's internal tail calls do. The old code skipped
that edge (different group, different split origin), leaving a chunk
boundary that could not stay a `musttail`. Forcing only ever makes a
parameter owned, the safe direction; the rule's reason (a drop after
the call breaks the tail call) applies to the boundary as much as to
the group.

FnDecl-construction audit (every `unbox_sig: None` site, issue #336
item 3): each pass now documents whether it preserves or deliberately
resets `borrowed`/`shapes`/`fip`/`cpr_arity`/`unbox_sig`:

- `perceus/lib.rs` reuse copies: clone `borrowed` (the parameters are
  the original's; the appended token stays owned — the reuse consumes
  it); `unbox_sig` stays reset (heap cells, never raw doubles).
- `trmc.rs` sibling: resets `borrowed` (Perceus runs later and infers
  it, context parameter included); clones `shapes` (the body is the
  original's, rewritten); resets `fip` (a context per call allocates),
  `cpr_arity` (exits go through `ctx_apply`), `unbox_sig` (the extra
  parameter breaks the marks' alignment — and a TRMC function returns
  data, never a Float/Int).
- `evidence.rs` copies: run before Perceus (`borrowed` empty
  everywhere; cloned anyway); `shapes` cloned; `unbox_sig` reset is
  deliberate for now — the copy's parameter list is the original's, so
  preserving it is sound and is #337's follow-up.
- `opt/specialise.rs` copies: `borrowed` reset (Perceus later; the
  parameter list changes shape); `shapes` cloned; `unbox_sig` reset
  (specialised parameters become captures, so the marks no longer
  align; carrying the kept parameters' marks over is a follow-up).
- `opt/cpr.rs` worker: `cpr_arity: Some` is the point; `unbox_sig`
  reset is vacuous (a CPR candidate returns a tuple, so it never had
  one).
- `opt/split.rs` chunks: `borrowed` reset (Perceus infers the chunks;
  they are one unit for its tail-call rule); `shapes` renumbered with
  the chunk; `cpr_arity`/`unbox_sig` vacuously `None` (the pass refuses
  functions that have either).
- `opt/fuse.rs`, `opt/precompile.rs` generated functions: fresh,
  untyped variables — no shapes, no marks to carry (they come from the
  type checker at lowering).

`LOUISE_NO_BORROW` is untouched (early return before any analysis); the
native suite run with it set stays green. Verified with the debug
verifier (`verify_in` runs on every program a debug compiler builds)
and eight new unit tests for the fixpoint: borrowed-propagation through
call chains both directions, same-group and split-chain tail-call
forcing, the chunk-into-group strengthening, closure targets.

Bench (best of 5, ms, this machine; ±2% run-to-run):

    benchmark   before   after
    records     380      378/387  (0%/+1%)
    lists       143      135/136  (−5%/−4%)

Two full bench.sh runs (both directions of the comparison); churn's
apparent +25–33% did not reproduce in a locked A/B of the two binaries
(base 323/308, new 313/338 — the bench wanders ±10% on this shared
machine); everything else within ±5%.

olivier · il y a 3 sem. · 4da9d7cd586b0d0483625a55059661396dffce38

Parents a1859e1

9 fichiers modifiés, 425 ajouts, 36 suppressions