tobogganSe connecter

louise

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

Codegen: record workers — single-constructor parameters and results flattened (#337)

ADR 0069 (in this PR, reviewed here; #44 notified, not blocking).
Generalizes ADR 0045's wrapper/worker split past Float/Int, as issue
#337 asks: `UnboxedSig` gains a `Record` kind for "single known
constructor, all-`tl_value` fields" (every user-constructor field is a
`tl_value`, so this is placement, not representation — no ABI change,
as ADR 0045 established).

- Lowering records a record signature when a monomorphic function has a
  single-constructor or tuple parameter; the result flattens when it is
  one of 1–4 fields (a `tl_pair{n}` by value, CPR's shape; larger stays
  boxed). A Float/Int result wins over a record parameter's mark
  (one kind per worker; mixed signatures are a follow-up).
- The planner (`unbox.rs`, `plan_record`) flattens the marked
  parameters, then every construction that never escapes (its uses are
  projections, drops, worker-call slots, a static switch, or a
  flattened return): its fields are locals and it is never allocated.
  It trims a marked parameter never used as a record (a pass-through
  only pays the boundary) and, past REGS+XARGS (32), the widest
  parameters. Refusals, the wrapper covering the semantics: an early
  `exit`; a cross-function tail call (`musttail` needs the uniform
  shape); a CPR worker (`cpr_arity`, as floats/ints).
- FBIP flattens instead of refusing: a flat value's `release` moves the
  bound fields, drops the rest, and makes the token unit (reusing a
  unit token allocates, exactly as a token that lost its cell), so the
  release/rebuild loop becomes field moves. Only a token released from
  a *boxed* value keeps its construction boxed (a real cell is worth
  keeping).
- Boxing stays centralized: `atom`'s record form (`atom_boxed`) emits
  the `tl_alloc` + field stores at an escape; `tl_unbox_fields`
  (prelude.h) moves a consumed box's fields out (unique: freed without
  touching them; shared/immortal: dupped, then dropped) at the worker
  boundary, the self-call jump, and a flattened return of a boxed
  record. `atom` panics on a flat variable — an expression position
  means the planner missed an escape.
- `unwind_ret` dummies take the record shape (`(tl_pair{n}){ TL_UNIT,
  … }`); unwind paths drop a flat variable field by field.
- Kill switch: `LOUISE_NO_UNBOX_RECORDS`.

Tests: tests/run/record_worker.lse (self-recursion flat throughout,
worker→worker, escape, borrowed parameter, FBIP shape) and
tests/run/record_edge.lse (wide result staying boxed, a two-constructor
type, a record through a closure call, worker→worker across functions,
a build-and-match local never allocated); five planner unit tests in
unbox.rs. Differential: bit-for-bit (the interpreter is untouched) and
0 live blocks everywhere; fuzzer lane green.

Benches (instructions, perf stat, LOUISE_THREADS=1; base <sha>):
<numbers>

olivier · il y a 3 sem. · 4da6efee339f65430f1035ffdf0e40e504a2f24e

Parents 0efa5a7

14 fichiers modifiés, 1815 ajouts, 95 suppressions

Mcrates/louise_codegen_c/src/emit/effects.rs+11−8
Mcrates/louise_codegen_c/src/emit/mod.rs+682−52
Mcrates/louise_codegen_c/src/emit/prelude.h+14−0
Mcrates/louise_codegen_c/src/lib.rs+10−0
Mcrates/louise_codegen_c/src/unbox.rs+736−10
Mcrates/louise_core/src/lower/mod.rs+46−7
Mcrates/louise_core/tests/split.rs+2−0
Mdocs/adr/0068-borrowed-closures.md+8−11
Adocs/adr/0069-record-workers.md+122−0