Skip to content

Start to port Wasmtime to the new wasi-io API with resources. #7029

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

Merged
merged 32 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
826c3e7
Rename `Host*` things to avoid name conflicts with bindings.
sunfishcode Sep 14, 2023
5a5d932
Update to the latest resource-enabled wit files.
sunfishcode Sep 15, 2023
047ea24
Adapting the code to the new bindings.
sunfishcode Sep 15, 2023
717c5a3
Update wasi-http to the resource-enabled wit deps.
sunfishcode Sep 15, 2023
c0194ec
Start adapting the wasi-http code to the new bindings.
sunfishcode Sep 15, 2023
e014999
Make `get_directories` always return new owned handles.
sunfishcode Sep 15, 2023
497a535
Simplify the `poll_one` implementation.
sunfishcode Sep 15, 2023
264b679
Update the wasi-preview1-component-adapter.
sunfishcode Sep 16, 2023
1c998dc
Work around a bug hit by poll-list, fix a bug in poll-one.
sunfishcode Sep 18, 2023
0ab3e4e
Comment out `test_fd_readwrite_invalid_fd`, which panics now.
sunfishcode Sep 18, 2023
e07ad5b
Fix a few FIXMEs.
sunfishcode Sep 18, 2023
ed8229f
Use `.as_ref().trapping_unwrap()` instead of `TrappingUnwrapRef`.
sunfishcode Sep 18, 2023
94be468
Use `drop_in_place`.
sunfishcode Sep 18, 2023
30d853c
Remove `State::with_mut`.
sunfishcode Sep 18, 2023
913dd7c
Remove the `RefCell` around the `State`.
sunfishcode Sep 18, 2023
826c58d
Update to wit-bindgen 0.12.
sunfishcode Sep 26, 2023
a1efe74
Update wasi-http to use resources for poll and I/O.
sunfishcode Sep 26, 2023
77da599
Re-enable disabled tests, remove logging from the worlds.
sunfishcode Sep 26, 2023
32376d4
Remove the `poll_list` workarounds that are no longer needed.
sunfishcode Sep 26, 2023
3585aee
Remove logging from the adapter.
sunfishcode Sep 27, 2023
0bfca79
Reenable a test that now passes.
sunfishcode Sep 27, 2023
b0a98b6
Remove `.descriptors_mut` and use `with_descriptors_mut` instead.
sunfishcode Sep 27, 2023
e4db840
Implement dynamic borrow checking for descriptors.
sunfishcode Sep 27, 2023
edbeaab
Add a cargo-vet audit for wasmtime-wmemcheck.
sunfishcode Sep 27, 2023
8de6cc6
Update cargo vet for wit-bindgen 0.12.
sunfishcode Sep 27, 2023
ad62c20
Cut down on duplicate sync/async resource types (#1)
alexcrichton Sep 27, 2023
3f06964
Allow calling `get-directories` more than once (#2)
alexcrichton Sep 28, 2023
1c86467
Start to lift restriction of stdio only once (#3)
alexcrichton Sep 28, 2023
b8fed8c
Remove some workarounds
sunfishcode Sep 28, 2023
b76a61f
If `poll_oneoff` fails part-way through, clean up properly.
sunfishcode Sep 28, 2023
f175845
Merge remote-tracking branch 'origin/main' into resources
alexcrichton Sep 29, 2023
08afa7b
Merge pull request #4 from alexcrichton/merge-main
sunfishcode Sep 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ io-extras = "0.18.0"
rustix = "0.38.8"
is-terminal = "0.4.0"
# wit-bindgen:
wit-bindgen = { version = "0.11.0", default-features = false }
wit-bindgen = { version = "0.12.0", default-features = false }

# wasm-tools family:
wasmparser = "0.113.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
use command_tests::wasi::cli::environment;
use command_tests::wasi::cli::stdin;
use command_tests::wasi::io::poll;
use command_tests::wasi::io::streams;
use command_tests::wasi::poll::poll;

fn main() {
let args = environment::get_arguments();

if args == &["correct"] {
let stdin: streams::InputStream = stdin::get_stdin();
let stdin_pollable = streams::subscribe_to_input_stream(stdin);
let ready = poll::poll_oneoff(&[stdin_pollable]);
assert_eq!(ready, &[true]);
poll::drop_pollable(stdin_pollable);
streams::drop_input_stream(stdin);
let stdin_pollable = stdin.subscribe();
let ready = poll::poll_list(&[&stdin_pollable]);
assert_eq!(ready, &[0]);
drop(stdin_pollable);
drop(stdin);
} else if args == &["trap"] {
let stdin: streams::InputStream = stdin::get_stdin();
let stdin_pollable = streams::subscribe_to_input_stream(stdin);
let ready = poll::poll_oneoff(&[stdin_pollable]);
assert_eq!(ready, &[true]);
streams::drop_input_stream(stdin);
let stdin_pollable = stdin.subscribe();
let ready = poll::poll_list(&[&stdin_pollable]);
assert_eq!(ready, &[0]);
drop(stdin);
unreachable!(
"execution should have trapped in line above when stream dropped before pollable"
);
Expand Down
29 changes: 8 additions & 21 deletions crates/test-programs/reactor-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,10 @@ wit_bindgen::generate!({
});

struct T;
use wasi::io::streams;
use wasi::poll::poll;
use wasi::io::poll;

static mut STATE: Vec<String> = Vec::new();

struct DropPollable {
pollable: poll::Pollable,
}

impl Drop for DropPollable {
fn drop(&mut self) {
poll::drop_pollable(self.pollable);
}
}

impl Guest for T {
fn add_strings(ss: Vec<String>) -> u32 {
for s in ss {
Expand All @@ -40,34 +29,32 @@ impl Guest for T {
}

fn write_strings_to(o: OutputStream) -> Result<(), ()> {
let sub = DropPollable {
pollable: streams::subscribe_to_output_stream(o),
};
let pollable = o.subscribe();
unsafe {
for s in STATE.iter() {
let mut out = s.as_bytes();
while !out.is_empty() {
poll::poll_oneoff(&[sub.pollable]);
let n = match streams::check_write(o) {
poll::poll_list(&[&pollable]);
let n = match o.check_write() {
Ok(n) => n,
Err(_) => return Err(()),
};

let len = (n as usize).min(out.len());
match streams::write(o, &out[..len]) {
match o.write(&out[..len]) {
Ok(_) => out = &out[len..],
Err(_) => return Err(()),
}
}
}

match streams::flush(o) {
match o.flush() {
Ok(_) => {}
Err(_) => return Err(()),
}

poll::poll_oneoff(&[sub.pollable]);
match streams::check_write(o) {
poll::poll_list(&[&pollable]);
match o.check_write() {
Ok(_) => {}
Err(_) => return Err(()),
}
Expand Down
Loading