Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.0.0] ISLE: Make block codegen non-recursive #8947

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

alexcrichton
Copy link
Member

This is a backport of #8935 to the 23.0.0 release branch

* ISLE: Make block codegen non-recursive

In bytecodealliance#8919 we learned that `Codegen::emit_block` can overrun the stack
when generating Rust source for deeply-nested blocks. Stack usage can be
worse than one might expect because ISLE is called from a build script,
and those are always built in debug mode.

This commit avoids the problem by using an explicit heap-allocated stack
instead of recursion.

I recommend turning on the "ignore whitespace" option in your diff tool
of choice when reviewing this commit.

The amount of stack space that this recursive function uses is affected
by the version of rustc used to compile it, and the amount of stack
space available depends on the host platform. As a result, this was only
observed on Windows with a recent nightly version of rustc, but it could
eventually affect other platforms or compiler versions, especially as
ISLE rules grow in complexity.

Note that there are several other places in ISLE which recurse over the
user-provided rules. This commit does not change those, but they could
also become a problem in the future.

* Review comments: make stack manipulation local to emit_block
@alexcrichton alexcrichton requested a review from a team as a code owner July 12, 2024 20:35
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team July 12, 2024 20:35
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language labels Jul 12, 2024
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "cranelift", "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@fitzgen fitzgen merged commit 6b3719a into bytecodealliance:release-23.0.0 Jul 12, 2024
120 checks passed
@alexcrichton alexcrichton deleted the backport branch September 24, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants