cfallin opened PR #12841 from cfallin:isle-debug-build-splitting to bytecodealliance:main:
As investigated in #12821, ISLE-generated Rust code with many locals in one large function body results in unreasonably-large stack frames when rustc's optimizations (and therefore LLVM's mem2reg) are disabled. In
constructor_simplify, a single function body generated from all mid-end rewrite rules, I was seeing a stack-frame size of0x44000bytes (272 KiB) on x86-64 (while in an opt build it is0x1000bytes (4 KiB)). With a recursion depth of 5 (the default limit) for rewrites of RHS-created nodes, this has the potential to overrun a 1 MiB stack; and is generally quite wasteful.In [another branch] I attempted to make
islecdo manual regalloc of a sort just for multi-extractor iterators; but soon realized that the problem has to do with all locals (which becomeallocas in LLVM IR), not just the iterators. We could do the equivalent thing to share all locals but this would become grossly un-idiomatic for e.g. LHSes of destructuring in Rust.Instead, this PR leverages previous work in #12303 (thanks Bongjun!) that splits function bodies in the generated Rust code from ISLE with a configurable threshold. This PR enables that feature and makes the threshold quite low in debug builds. This has the natural effect of splitting locals among many smaller stack frames, which are dynamically pushed only when matching enters a particular subtree; so stack usage more closely mirrors the actual live-set of values bound during matching.
With this change, the stack frame for the top-level
constructor_simplifyis < 4 KiB on x86-64 in a debug build.Fixes #12821.
[another branch]: https://github.com/cfallin/wasmtime/tree/isle-iterator-reuse
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
cfallin requested fitzgen for a review on PR #12841.
cfallin requested wasmtime-compiler-reviewers for a review on PR #12841.
fitzgen submitted PR review:
Nice!
fitzgen added PR #12841 Cranelift: perform aggressive splitting of generated ISLE function bodies in debug builds. to the merge queue
fitzgen merged PR #12841.
fitzgen removed PR #12841 Cranelift: perform aggressive splitting of generated ISLE function bodies in debug builds. from the merge queue
Last updated: Apr 12 2026 at 23:10 UTC