Browse Source

Reuse locals in adapter trampolines (#4646)

This commit implements a scheme I've been meaning to work on in the
adapter compiler where instead of always generating a fresh local for
all operations locals may now be reused. Locals generated are explicitly
free'd when their lexical scope has ended, allowing reuse in translation
of later types in the adapter.

This also implements a new scheme for initializing locals where
previously a local could simply be generated, but now the local must be
fused with its initializer where a `local.{tee,set}` instruction is
always generated. This should help prevent a bug I ran into with strings
where one usage of a local was forgotten to be initialized which meant
that when it was used during a loop it may have had a stale value from
before.

Modeling this in Rust isn't possible at compile time unfortunately so I
opted for the next best thing, runtime panics. If a local is
accidentally not released back to the pool of free locals then it will
panic. The fuzzer for simply generating and validating adapter modules
should be good at exercising this and it weeded out a few forgotten
free's and should be good now.
pull/4648/head
Alex Crichton 2 years ago
committed by GitHub
parent
commit
c816a52746
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 663
      crates/environ/src/fact/trampoline.rs

663
crates/environ/src/fact/trampoline.rs

File diff suppressed because it is too large
Loading…
Cancel
Save