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.

Codegen: unboxed-int workers for Int-heavy functions (issue #190)

ADR 0045's worker/wrapper unboxing, extended to Int (Revision 2): a
function whose parameters and result are known Int gets a worker f$ui
on raw int64_t's next to the boxed wrapper. Int arithmetic can leave
the 63-bit small range, where Louise promotes to a big integer, so the
worker is a fast path only: add/sub/mul check (__builtin_*_overflow plus
the small-range test; skipped where the ADR 0046 range analysis proves
the result small) and return TL_INT_BAIL on overflow, division and
remainder bail where the boxed path would panic or promote, and the
direct caller at the boundary recomputes the whole call with the boxed
wrapper — exactly the pre-worker cost, and exact. Recomputing re-runs
the body, so workers are planned only for functions fusion's purity
gate calls safe to re-run; unmarked parameters must be borrowed (the
recompute passes the boxed arguments again); a boxed Int may be a big
integer, so operands and results are unboxed in place only where proven
small, and the boundary calls the worker only for immediate or proven
arguments. FnDecl::float_sig generalises to unbox_sig (kind + marks);
float.rs becomes unbox.rs. LOUISE_NO_UNBOX_INTS turns the int workers
off.

fib(35): 1,395,730,589 -> 917,989,153 instructions (-34%), 0.15 s ->
0.12 s; arith bench -25%; trees/lists/floats +/-0.00%. tests/run gains
unbox_int (worker overflow in fact/power/a tail-recursive loop,
-2^62/-1, big-integer arguments at the boundary) and
unbox_int_div_panic (a zero divisor's bail recomputes and panics once);
bigint.lse's promotions are the existing coverage.

olivier · il y a 1 mois · 05a64e9fb62f21afc5f6e66d2dc66da82541b9f2

Parents 272f3e2

23 fichiers modifiés, 1659 ajouts, 570 suppressions

Mcrates/louise_codegen_c/src/emit/mod.rs+312−96
Mcrates/louise_codegen_c/src/emit/prelude.h+15−1
Dcrates/louise_codegen_c/src/float.rs+0−421
Mcrates/louise_codegen_c/src/lib.rs+1−1
Mcrates/louise_codegen_c/src/ranges.rs+7−0
Acrates/louise_codegen_c/src/unbox.rs+918−0
Acrates/louise_codegen_c/tests/int_workers.rs+223−0
Mcrates/louise_codegen_c/tests/never_unwinds.rs+8−1
Mcrates/louise_codegen_c/tests/preemption.rs+8−1
Mcrates/louise_core/src/callgraph.rs+1−1
Mcrates/louise_core/src/evidence.rs+1−1
Mcrates/louise_core/src/lower/derive.rs+1−1
Mcrates/louise_core/src/lower/mod.rs+38−19
Mcrates/louise_core/src/opt/cpr.rs+1−1
Mcrates/louise_core/src/opt/fuse.rs+1−1
Mcrates/louise_core/src/opt/specialise.rs+1−1
Mcrates/louise_core/tests/lowering.rs+23−14
Mcrates/louise_perceus/tests/programs.rs+1−1
Atests/run/unbox_int_div_panic.lse+13−0