Stream: git-wasmtime

Topic: wasmtime / PR #7535 winch: Multi-Value Part 1


view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 12:49):

saulecabrera opened PR #7535 from saulecabrera:winch-multi-value to bytecodealliance:main:

This change adds initial support for the Multi-Value proposal to Winch, focusing on function calls, support for Multi-Value for blocks will be added on top of this change in a different pull request.

This change is divided into two main parts:

Infrastructure changes needed to support Multi-Value

Some notable changes were needed in order to support this proposal, namely:

Handling Multi-Value returns for function calls

The approach for handling multiple results for function calls involves:

Adding an implicit extra parameter to the ABIParams definition, when a function returns multiple values; from the callee's perspective, this parameter is treated like any other "special" parameter (e.g VMContext), to which, we give it a well know LocalSlot for later referencing when storing the return values. From the caller's perspective, extra stack space is created before the call, and the address to that space is passed in to the callee, via the return pointer parameter and once the function returns, the values in the created space are captured as values in the value stack.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 12:49):

saulecabrera requested fitzgen for a review on PR #7535.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 12:49):

saulecabrera requested wasmtime-compiler-reviewers for a review on PR #7535.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 12:49):

saulecabrera requested wasmtime-core-reviewers for a review on PR #7535.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 14:17):

saulecabrera updated PR #7535.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 14:18):

saulecabrera updated PR #7535.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 14:26):

saulecabrera edited PR #7535:

This change adds initial support for the Multi-Value proposal to Winch, focusing on function calls, support for Multi-Value for blocks will be added on top of this change in a different pull request.

This change is divided into two main parts:

Infrastructure changes needed to support Multi-Value

Some notable changes were needed in order to support this proposal, namely:

Handling Multi-Value returns for function calls

The approach for handling multiple results for function calls involves:

Adding an implicit extra parameter to the ABIParams definition, when a function returns multiple values; from the callee's perspective, this parameter is treated like any other "special" parameter (e.g VMContext), to which, we give it a well know LocalSlot for later referencing when storing the return values. From the caller's perspective, extra stack space is created before the call, and the address to that space is passed in to the callee, via the return pointer parameter and once the function returns, the values in the created space are captured as values in the value stack.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen submitted PR review:

LGTM but I'm still a little sketched out by those disassembly changes where I feel like I'm only seeing one half of a change or something like that. Maybe you can explain what is going on?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen submitted PR review:

LGTM but I'm still a little sketched out by those disassembly changes where I feel like I'm only seeing one half of a change or something like that. Maybe you can explain what is going on?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen created PR review comment:

Could we document what the map closure is supposed to do here? Was not immediately obvious to me when reading the code.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen created PR review comment:

This seems like it is unnecessarily setting us up for porting issues in the future when we have a 32-bit target. Can we just put the size directly or use mem::size_of::<u32>() or something instead?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen created PR review comment:

Ah, great!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen created PR review comment:

Is this an expected/intended change in this first commit? I thought this was purely a refactoring to prep for multi-value, and I wouldn't expect any functional changes. Certainly not ones where we are changing from where we are pushing values to the stack when I don't see any corresponding changes in how we pop values from the stack.

But maybe this is addressed in follow up commits that I haven't gotten to yet...

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen created PR review comment:

Documentation is out of sync with the code: it returns a set not an iterator.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen created PR review comment:

Ditto regarding map

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen created PR review comment:

:eyes:

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 17:41):

fitzgen created PR review comment:

debug_assert_eq! will give better diagnostics on panic.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:49):

saulecabrera updated PR #7535.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:50):

saulecabrera submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:50):

saulecabrera created PR review comment:

I ended up moving the definition to the implementation of each ABI, that way once it'll be easier to integrate once we support 32-bit targets.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:50):

saulecabrera submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:50):

saulecabrera created PR review comment:

Fixed!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:51):

saulecabrera submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:51):

saulecabrera created PR review comment:

Fixed!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:51):

saulecabrera submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:51):

saulecabrera created PR review comment:

Fixed!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:52):

saulecabrera submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:52):

saulecabrera created PR review comment:

It's indeed intended, I just forgot to mention it in the commit message: I realized that the slot for the VMContext was not aligned, so I introduced alignment for it, similar to what I did for the return pointer.

In the first commit, that is here https://github.com/bytecodealliance/wasmtime/pull/7535/commits/5dcefe38b9dc4cac3f24bf9f4d0eb20f43f9b6a1#diff-b396908c6cc30abb2ad12e93c9443d5b8875dd320980cde6896068f5e5cbf4c1R101-R106; hopefully this clarifies things!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:53):

saulecabrera submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:53):

saulecabrera created PR review comment:

Fixed

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 19:59):

saulecabrera edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 22:20):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 22:20):

fitzgen created PR review comment:

That makes sense -- thanks for the explanation!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 14 2023 at 22:40):

saulecabrera merged PR #7535.


Last updated: Oct 23 2024 at 20:03 UTC