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: drop specialisation (issue #34)

Matching a value and then dropping it read its fields with a dup each
and released the cell, whose drop then decremented each field again.
A new step after dup/drop insertion (tilc_perceus/src/specialise.rs)
turns

    let a = x.0; dup a; let b = x.1; dup b; drop x

into `release x [0: a, 1: b]` (Expr::Release): if x is unique, its
fields are moved out (set to unit) and the cell is freed with tl_free,
or with tl_drop_slow when other fields remain; otherwise the fields are
dup'd and x dropped, as before. The fields' counts are never touched on
the unique path.

It only rewrites the statements just before the drop (projections,
dups and other drops, none of which can unwind), so no code moves
across a call; the emitter's unwinding bookkeeping treats a release as
consuming x and giving each field a reference. verify checks that each
released variable is the projection of the field it names, each field
once.

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

olivier · il y a 1 mois · 43ac8c2199f61419ac88509619ddd663c0f62d3f

Parents 27250c5

11 fichiers modifiés, 316 ajouts, 34 suppressions

Mcrates/tilc_codegen_c/src/emit.rs+34−0
Mcrates/tilc_perceus/src/borrow.rs+6−4
Acrates/tilc_perceus/src/specialise.rs+168−0
Mcrates/tilc_perceus/src/verify.rs+25−6
Mcrates/tilc_perceus/tests/programs.rs+40−0
Mcrates/tilc_perceus/tests/snapshots/programs__borrowing_and_reuse_of_a_small_program.snap+1−3
Mcrates/tilc_perceus/tests/snapshots/programs__rc_of_a_small_program.snap+7−15