Stream: git-wasmtime

Topic: wasmtime / PR #4646 Reuse locals in adapter trampolines


view this post on Zulip Wasmtime GitHub notifications bot (Aug 08 2022 at 20:38):

alexcrichton opened PR #4646 from reuse-locals to main:

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.

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Aug 08 2022 at 20:38):

alexcrichton requested fitzgen for a review on PR #4646.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 08 2022 at 21:00):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 08 2022 at 21:07):

alexcrichton has enabled auto merge for PR #4646.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 08 2022 at 21:18):

alexcrichton merged PR #4646.


Last updated: Oct 23 2024 at 20:03 UTC