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

Add Rust impl of wasmtime_ssp_sched_yield #127

Merged
merged 2 commits into from
Apr 30, 2019
Merged

Add Rust impl of wasmtime_ssp_sched_yield #127

merged 2 commits into from
Apr 30, 2019

Conversation

kubkon
Copy link
Member

@kubkon kubkon commented Apr 28, 2019

Also, add Rust implementation of errno and convert_errno.

This PR addresses #120.

Caveats:

  • errno and convert_errno are currently implemented only for *nix OSes (the implementation borrowed from Rust's libstd; please have a look in the comments below)
  • missing handling of EOPNOTSUPP and EWOULDBLOCK

All comments and suggestions are more than welcome!

EDIT: to address bindgen issues reported by @heyitsanthony in #126, this PR also manually defines host::__wasi_errno_t errors, and blacklists them in bindgen.

)]
#[cfg_attr(target_os = "haiku", link_name = "_errnop")]
fn errno_location() -> *mut libc::c_int;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't decide between using nix crate or linking to errno ourselves, but in the end, decided to borrow the functionality for *nix directly from Rust's libstd.

Copy link
Member

Choose a reason for hiding this comment

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

We can use the errno crate for cross-platform access to errno (wasmtime uses this in a few other places already).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, nice! I'll investigate today and make amends.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, we're now using the errno crate.

// #endif
// #if EWOULDBLOCK != EAGAIN
// [EWOULDBLOCK] = __WASI_EAGAIN
// #endif
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how to handle these two cases here. Suggestions more than welcome!

Choose a reason for hiding this comment

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

maybe this:

#[allow(unreachable_patterns)]    
match errno {
    ...
    libc::EAGAIN | libc::EWOULDBLOCK => __WASI_EAGAIN,
    ...
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Perfect, thanks!

Copy link
Member Author

@kubkon kubkon Apr 29, 2019

Choose a reason for hiding this comment

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

I've changed it the way you suggested. I think it looks great now. Have a look and lemme know what you reckon!

Also, add Rust implementation of errno and convert_errno.
)]
#[cfg_attr(target_os = "haiku", link_name = "_errnop")]
fn errno_location() -> *mut libc::c_int;
}
Copy link
Member

Choose a reason for hiding this comment

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

We can use the errno crate for cross-platform access to errno (wasmtime uses this in a few other places already).

pub const __WASI_ETIMEDOUT: __wasi_errno_t = 73;
pub const __WASI_ETXTBSY: __wasi_errno_t = 74;
pub const __WASI_EXDEV: __wasi_errno_t = 75;
pub const __WASI_ENOTCAPABLE: __wasi_errno_t = 76;
Copy link
Member

Choose a reason for hiding this comment

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

I convinced myself that it's ok to put these here, because eventually, wasmtime_ssp.h and the bindgen-generated wasmtime_ssp.rs will go away and we'll need these :-).

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed! :-)

pub const __WASI_EXDEV: __wasi_errno_t = 75;
pub const __WASI_ENOTCAPABLE: __wasi_errno_t = 76;

/// Convert POSIX error to CloudABI error
Copy link
Member

Choose a reason for hiding this comment

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

This comment should now say "... to WASI error".

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed!

libc::ENOSYS => host::__WASI_ENOSYS,
// TODO: verify if this is correct
#[cfg(target_os = "freebsd")]
libc::ENOTCAPABLE => host::__WASI_ENOTCAPABLE,
Copy link
Member

Choose a reason for hiding this comment

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

Yes, this is correct, at least at present.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

They are now blacklisted in the bindgen.
@sunfishcode
Copy link
Member

Great!

@sunfishcode sunfishcode merged commit 86b7a52 into bytecodealliance:master Apr 30, 2019
kubkon pushed a commit that referenced this pull request Nov 7, 2019
This commit syncs tests with latest wasmtime revision.
As such, it now utilises the `wasmtime-api` crate for
runtime setup.

Closes #126, #127, #128, #129.
mooori pushed a commit to mooori/wasmtime that referenced this pull request Dec 20, 2023
dhil pushed a commit to dhil/wasmtime that referenced this pull request Mar 13, 2024
This turns the `wasmtime_fibre` into a module called `fibre` in the
`runtime` crate. As a result, the `wasmtime_fibre` crate is removed from
the workspace. This is helpful for specializing the fibre implementation
further for our purposes in the future.

Arguably, we could actually make `fibre` a submodule of the existing
`continuation` module in `runtime` (i.e., instead of putting it at
`wasmtime_runtime::fibre`, put it at
`wasmtime_runtime::continuation::fibre`), but I decided against changing
the directory structure further for now.

The only noteworthy changes outside of moving the files are:
1. The types `SwitchDirection` and `SwitchDirectionEnum`, previously in
the `wasmtime_fibre` crate, are now in the `continuations` crate. We
need access to these in cranelift.
2. Instead of adding a lot of /// TODO comments I bailed out of
mandatory doc comments (as imposed by the `runtime` crate) on pub
definitions in the new `fibre` module.
avanhatt pushed a commit to wellesley-prog-sys/wasmtime that referenced this pull request Oct 9, 2024
avanhatt pushed a commit to wellesley-prog-sys/wasmtime that referenced this pull request Oct 18, 2024
Verify `load_i64` expansions involving `MovWide` instructions.

We added `MovWide` ASLp specs in bytecodealliance#127. This PR provides additional specs
to utilize them.

Updates avanhatt#49 avanhatt#34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants