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: precompiled renderers for HTML templates (ADR 0054)

A render of a statically known tree — html.render(t), or render_into
once the simplifier has inlined render — becomes the sequence of
builder appends render_into would run: static parts (a whole static
subtree included) folded to one string constant at compile time, text
holes escaped in place, Raw holes appended as is, opaque element and
list holes rendered by the ordinary render_into/render_all into the
same builder. The Element tree is never built.

Components compose by translation: a hole that is a direct call of a
function whose body returns a literal tree (a match's arms included)
is translated with the call's arguments; anything else falls back to
tree + render_into. render_all(list.map(xs, f), b) becomes
list.fold(xs, b, f$render) with a generated step function: the rows
of a table never exist as trees.

Effect order is preserved by the commute rule: the pass deletes only
constructions (pure by definition), and a component call's non-tree
bindings move from the call to the render only when what moves is
boring (pure and panic-free — fusion's gate) or everything between
the two positions is. The interpreter runs the same rewritten Core
and the unoptimised pipeline is untouched, so the differential tests
check the pass (issue #219). LOUISE_NO_PRECOMPILE turns it off;
together with LOUISE_NO_STATIC_CTORS it reproduces the old code
exactly.

tests/run/html_precompile.lse pins the behaviour on both backends:
hole effect order through a fused map, the commute rule's negative
(an effect between map and render keeps the list), an escaped tree
matched on, the same component twice in one literal, all void
elements, flags, raw. crates/louise_codegen_c/tests/precompile.rs
pins the emitted C's shape.

Bench (this host; release for instructions and wall, checked runtime
for allocs): html 864.4M -> 326.7M instructions (-62%), 3.20M ->
1.00M allocs (-69%), 146 -> 64 ms; ssr 4,741.5M -> 1,587.0M (-67%),
16.88M -> 2.81M allocs (-83%), 618 -> 221 ms. Checksums unchanged.

olivier · il y a 1 mois · 9eb123fcaef001262f5ccd66553817d09eea5e97

Parents 29a8c0e

8 fichiers modifiés, 2023 ajouts, 53 suppressions