Skip to content

Update to the next version of the witx crate#2659

Merged
abrown merged 8 commits into
bytecodealliance:mainfrom
alexcrichton:witx-next
Feb 18, 2021
Merged

Update to the next version of the witx crate#2659
abrown merged 8 commits into
bytecodealliance:mainfrom
alexcrichton:witx-next

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This commit updates to the 0.9 version of the witx crate implemented in
WebAssembly/WASI#395. This new version drastically changes code
generation and how we interface with the crate. The intention is to
abstract the code generation aspects and allow code generators to
implement much more low-level instructions to enable more flexible APIs
in the future. Additionally a bunch of *.witx files were updated in
the WASI repository.

It's worth pointing out, however, that wasi-common does not change as
a result of this change. The shape of the APIs that we need to implement
are effectively the same and the only difference is that the shim
functions generated by wiggle are a bit different.

@alexcrichton

Copy link
Copy Markdown
Member Author

Oh and one other change with this PR, some errors which were previously classified as EINVAL or similar are now classified as traps. For example if you return a bad return pointer and we fail trying to write to it we'll generate a trap instead of returning EINVAL.

@github-actions github-actions Bot added the wasi Issues pertaining to WASI label Feb 17, 2021
@github-actions

Copy link
Copy Markdown

Subscribe to Label Action

cc @kubkon

Details This issue or pull request has been labeled: "wasi"

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

  • kubkon: wasi

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

Learn more.

@abrown

abrown commented Feb 17, 2021

Copy link
Copy Markdown
Member

Looks like https://github.com/bytecodealliance/wasmtime/pull/2659/checks?check_run_id=1921259948 is the same type of error that I saw in @sunfishcode's PR... I told him that I am willing to take a look at upgrading the witx for wasi-nn but that may not be the only thing going wrong here. Let me know if you need me to take a look.

fn try_from(value: #abi_repr) -> Result<#ident, #rt::GuestError> {
#ident::try_from(value as #repr)
fn try_from(value: #abi_repr) -> Result<Self, #rt::GuestError> {
#ident::try_from(#repr::try_from(value)?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good catch!!

@pchickey pchickey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking very good. Wiggle test suite needs tending to

);

assert_eq!(res, Ok(types::Errno::Ok.into()), "sum of int and ptr errno");
assert_eq!(res, Ok(types::Errno::Ok as i32), "sum of int and ptr errno");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@pchickey do you have thoughts on adding back the to/from abi repr traits? I originally removed them because I figured it was good to trim things down to just the in-memory type to avoid too many conversions being available, but it ended up showing up a good amount in tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm fine with either - using as in tests is OK with me, or maybe we should do types::Errno::try_from(res).unwrap() on the lhs? If you don't want to provide too many From impls maybe define a FromAbi trait in wiggle that has the same shape, but has docs saying its just for wiggle use?

@alexcrichton

Copy link
Copy Markdown
Member Author

@abrown no worries, I'll probably need to send a merge change to the wasi-nn repo once the wasi changes land which updates the witx as well. I don't mind doing that inline here as well.

This commit updates to the 0.9 version of the witx crate implemented in
WebAssembly/WASI#395. This new version drastically changes code
generation and how we interface with the crate. The intention is to
abstract the code generation aspects and allow code generators to
implement much more low-level instructions to enable more flexible APIs
in the future. Additionally a bunch of `*.witx` files were updated in
the WASI repository.

It's worth pointing out, however, that `wasi-common` does not change as
a result of this change. The shape of the APIs that we need to implement
are effectively the same and the only difference is that the shim
functions generated by wiggle are a bit different.
@alexcrichton

Copy link
Copy Markdown
Member Author

Ok all submodules have been merged and this is now updated, so this is ready for merge when approved

@pchickey pchickey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great to me. This touches wasi-nn and wasi-crypto in what I see as a purely mechanical manner - should we give @abrown @jedisct1 a chance to review as well in case they spot something I missed?

@jedisct1

Copy link
Copy Markdown
Contributor

Looking good!

@abrown abrown left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me!

@abrown

abrown commented Feb 18, 2021

Copy link
Copy Markdown
Member

And thanks @alexcrichton for the changes to wasi-nn as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasi Issues pertaining to WASI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants