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

Fix witty export of functions with 16 parameters second attempt #2530

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Sep 24, 2024

Motivation

This is a second attempt to fix the issue, the first one (#2429) blocked publishing new crate versions because it depended on a fix that was upstreamed to wasmtime, but hadn't been included in a release yet. To remove the blocker it was reverted (by #2435) but now the newly released version 25.0.0 of wasmtime includes the fix that's needed.

When exporting functions with a specific signature type (with parameters that are flattened to exactly 16 flat types and with a return type that flattens to more than one flat type) to a Wasm instance, Witty's #[wit_export] macro would incorrectly lower all parameters and return types to the type.

This is different from what was specified in the specification.

Proposal

Don't lower the parameters of functions if they can be flattened into 16 flat types, even if the return type is lowered into the heap.

Test Plan

Ran tests manually to ensure that the test_memory_run_application_with_dependency passes without the dummy parameter that was introduced previously as a workaround before this fix.

Release Plan

  • Need to bump the major/minor version number in the next release of the crates.
  • Need to update the developer manual.
  • This PR is adding or removing Cargo features.
  • Release is blocked and/or tracked by other issues (see links below)

Links

Instead of manually creating the very deeply nested type.
Use the new fork release which updates the version of `wat` so that
there's no conflict with the new version of `wasmtime`.
Include the fix that allows usage of 17 parameters with typed exported
functions.
Keep them as flat parameters instead, even if the return type needs to
be lowered as well.
They were added to work-around the issue with function parameters that
flattened to 16 flat types, and with the fix they are no longer needed.
@jvff jvff added the bug Something isn't working label Sep 24, 2024
@jvff jvff added this to the Testnet #1 milestone Sep 24, 2024
@jvff jvff self-assigned this Sep 24, 2024
Copy link
Contributor

@ma2bd ma2bd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jvff jvff merged commit 2cf44d8 into linera-io:main Sep 24, 2024
5 checks passed
@jvff jvff deleted the fix-witty-export-of-functions-with-16-parameters-second-attempt branch September 24, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't move parameters to heap if there are exactly 16 of them
3 participants