tobogganSe connecter

louise

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

Perceus: reuse matched cells in place (FBIP) (issue #34)

A release (drop specialisation) of a value matched by a switch now keeps
its cell when a constructor or tuple at least as large as the fields
read is built after it: `release x [...] reuse as t`, then `reuse t in
C(...)` (Value::Reuse). When x is unique, tl_reuse_token drops the
fields that were not moved out and keeps the cell, all fields unit;
otherwise the token is unit. The construction writes the cell in place
(new tag, same size) when the token is a cell of its size, and
otherwise frees it and allocates, as the size of a matched cell is not
known statically. So map, filter, reverse and tree updates rebuild
unique structures without allocating.

The token is an ordinary owned variable: on every path after the
release the first suitable construction consumes it, and branches
without one drop it on entry, so tail calls stay tail calls. Unwinding
(panics, final ctl, cancelled ctl bodies, killed actors) drops it like
any reference the frame holds: a unique block of units is just freed.
Only switched values give tokens: tuples and dictionaries are projected
without a switch, and a constant dictionary is never unique.

Tests: tests/run/reuse.til (unique and shared inputs, size and tag
changes, tuples, borrowed parameters whose fields escape, a borrowed
map and dictionaries) and tests/run/reuse_unwinding.til (reuse while
final ctl unwinds, while a ctl body is suspended or cancelled, and in
an actor that panics), on both backends, without leaks, also with 4
threads and under ASan+UBSan.

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

olivier · il y a 1 mois · 2f1bc40b969f663ac15eb4d5cd1a94bd86445449

Parents 43ac8c2

11 fichiers modifiés, 539 ajouts, 46 suppressions