tobogganSe connecter

louise

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

Core: one inlining budget per optimisation, one constant-dictionary rule (issue #225)

- **One budget.** `simplify::run_in` said growth was bounded over the
  whole pass, but `opt::run_with` runs it once per round of its fixed
  point and once after, and each run started a fresh budget: a function
  could grow 4× per run. A `simplify::Budget` is now shared by every run
  of one optimisation (`run_with_budget`; `run_in` keeps a budget of its
  own, for the tests).
- **Forced inlining moves once.** A closure used once is inlined
  whatever its size, since that moves its function's body instead of
  copying it — unless the function is referenced elsewhere too (an
  inlined caller copied the closure). The budget remembers the functions
  moved; a second forced inlining of one takes the cap like any other.
- **One constant-dictionary rule.** The simplifier and the C backend
  recognised constant dictionaries separately, and differently: the
  backend also required at most 254 fields, all variables, so a
  dictionary outside its rule was neither folded nor inlined.
  `FnDecl::is_constant_dictionary` is the one rule; the backend's walk
  only builds the C.
- **A guard for 9eed13b:** `never_inlines_a_constant_dictionary` checks
  that no function but a dictionary makes a dictionary's method
  closures after the simplifier. It fails with the rule removed.

Effect, against the parent commit: the optimised Core of 7 programs
changes (tests/run's combinators, dict, results, reuse, specialise and
time, and tests/bench/dict), all from the shared budget; the dictionary
rule and the move rule alone change nothing. No benchmark's release
executable changes (dict's is byte-identical: its difference is in code
the link drops).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

olivier · il y a 1 mois · e02d8a5fa246bd8ff60ac62d66c9855172d52c02

Parents acd3de5

5 fichiers modifiés, 167 ajouts, 57 suppressions

Mcrates/louise_codegen_c/src/emit/mod.rs+18−14
Mcrates/louise_core/src/opt/mod.rs+4−2
Mcrates/louise_core/src/opt/simplify.rs+48−41
Mcrates/louise_core/tests/simplify.rs+61−0