Stream: git-wasmtime

Topic: wasmtime / PR #4649 Backport: VCode emission: account for...


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

cfallin opened PR #4649 from backport-pr4644-0.40.0 to release-0.40.0:

This is a backport of #4644. The issue is a compiler panic reachable
via a Wasm module input, so merits a backport to the (pending)
release branch.

To determine whether we need to insert a "veneer island" of
branch-range extension veneers, we need to know ahead of emitting a
basic block the worst-case size of that block. This is because veneers
only go between blocks (we could plop one in the middle of a block but
that would require another jump around it and would probably pessimize
some code significantly), and we can't back up once we emit a block.

To compute this worst-case size, we take the number of instructions
and multiply by the largest possible size of one pseudoinst (e.g., on
aarch64, this is 44 bytes; it explicitly excludes the EmitIsland
pseudo-op which is used before large jumptable inline offset tables
are emitted). This is conservative, but it always works, and veneers
are somewhat rare in practice (function body >1MiB on aarch64 for
example).

Unfortunately this logic didn't account for the spill/reload/move
instructions inserted by the register allocator, and in one example in
issue #4629, a block had only one instruction but 482
edge-moves (!). This came at just the wrong time as we were
approaching the 1MiB limit on aarch64.

This PR fixes that issue, and fixes the logic to actually look at the
correct next block (next in final_order rather than numerically
next), as a bonus correctness fix.

Fixes #4629.

<!--

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 21:37):

cfallin requested alexcrichton for a review on PR #4649.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 09 2022 at 14:26):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 09 2022 at 14:26):

alexcrichton merged PR #4649.


Last updated: Dec 23 2024 at 12:05 UTC