Skip to content

Commit 8b1600c

Browse files
authored
Merge pull request #101 from Gentle/wasmtime19
Update dependencies, wasmtime-19, remove wasmtime-wasi
2 parents e633f95 + 341b9c3 commit 8b1600c

File tree

13 files changed

+367
-653
lines changed

13 files changed

+367
-653
lines changed

Cargo.lock

Lines changed: 316 additions & 613 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@ name = "uap"
2727
harness = false
2828

2929
[dependencies]
30-
anyhow = "1.0.80"
30+
anyhow = "1.0.81"
3131
cap-std = "3.0.0"
3232
env_logger = { version = "0.11", optional = true }
3333
log = "0.4.21"
34-
rayon = "1.9.0"
34+
rayon = "1.10.0"
3535
structopt = { version = "0.3.26", optional = true }
36-
wasm-encoder = "0.201.0"
37-
wasmparser = "0.201.0"
36+
wasm-encoder = "0.202.0"
37+
wasmparser = "0.202.0"
3838
wasmtime = { workspace = true }
39-
wasmtime-wasi = { workspace = true }
4039
wasi-common = { workspace = true }
4140

4241
# Enable this dependency to get messages with WAT disassemblies when certain
@@ -46,17 +45,16 @@ workspace = true
4645
optional = true
4746

4847
[workspace.dependencies]
49-
wasmprinter = "0.201.0"
50-
wasmtime = "18"
51-
wasmtime-wasi = "18"
52-
wasi-common = "18"
48+
wasmprinter = "0.202.0"
49+
wasmtime = "19"
50+
wasi-common = "19"
5351

5452

5553
[dev-dependencies]
5654
criterion = "0.5.1"
5755
env_logger = "0.11.3"
5856
wasmprinter = { workspace = true }
59-
wat = "1.201.0"
57+
wat = "1.202.0"
6058

6159
[workspace]
6260
members = [

benches/regex-bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

1212
[dependencies]
13-
regex = "1.10.3"
13+
regex = "1.10.4"
1414

1515
[features]
1616
wizer = []

benches/regex.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ fn bench_regex(c: &mut Criterion) {
2626
let mut group = c.benchmark_group("regex");
2727
group.bench_function("control", |b| {
2828
let engine = wasmtime::Engine::default();
29-
let wasi = wasmtime_wasi::WasiCtxBuilder::new().build();
29+
let wasi = wasi_common::sync::WasiCtxBuilder::new().build();
3030
let mut store = wasmtime::Store::new(&engine, wasi);
3131
let module =
3232
wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm"))
3333
.unwrap();
3434
let mut linker = wasmtime::Linker::new(&engine);
35-
wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap();
35+
wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap();
3636

3737
b.iter(|| run_iter(&linker, &module, &mut store));
3838
});
3939
group.bench_function("wizer", |b| {
4040
let engine = wasmtime::Engine::default();
41-
let wasi = wasmtime_wasi::WasiCtxBuilder::new().build();
41+
let wasi = wasi_common::sync::WasiCtxBuilder::new().build();
4242
let mut store = wasmtime::Store::new(&engine, wasi);
4343
let module =
4444
wasmtime::Module::new(store.engine(), &include_bytes!("regex_bench.control.wasm"))
4545
.unwrap();
4646
let mut linker = wasmtime::Linker::new(&engine);
47-
wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap();
47+
wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap();
4848

4949
b.iter(|| run_iter(&linker, &module, &mut store));
5050
});

benches/uap-bench/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ crate-type = ["cdylib"]
1111

1212
[dependencies]
1313
serde = { version = "1.0.197", features = ["derive"] }
14-
regex = "1.10.3"
15-
serde_yaml = "0.9.32"
14+
regex = "1.10.4"
15+
serde_yaml = "0.9.34"
1616

1717
[features]
1818
wizer = []

benches/uap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@ fn bench_uap(c: &mut Criterion) {
3939
let mut group = c.benchmark_group("uap");
4040
group.bench_function("control", |b| {
4141
let engine = wasmtime::Engine::default();
42-
let wasi = wasmtime_wasi::WasiCtxBuilder::new().build();
42+
let wasi = wasi_common::sync::WasiCtxBuilder::new().build();
4343
let mut store = wasmtime::Store::new(&engine, wasi);
4444
let module =
4545
wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.control.wasm"))
4646
.unwrap();
4747
let mut linker = wasmtime::Linker::new(&engine);
48-
wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap();
48+
wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap();
4949

5050
b.iter(|| run_iter(&linker, &module, &mut store));
5151
});
5252
group.bench_function("wizer", |b| {
5353
let engine = wasmtime::Engine::default();
54-
let wasi = wasmtime_wasi::WasiCtxBuilder::new().build();
54+
let wasi = wasi_common::sync::WasiCtxBuilder::new().build();
5555
let mut store = wasmtime::Store::new(&engine, wasi);
5656
let module =
5757
wasmtime::Module::new(store.engine(), &include_bytes!("uap_bench.wizer.wasm")).unwrap();
5858
let mut linker = wasmtime::Linker::new(&engine);
59-
wasmtime_wasi::sync::add_to_linker(&mut linker, |s| s).unwrap();
59+
wasi_common::sync::add_to_linker(&mut linker, |s| s).unwrap();
6060

6161
b.iter(|| run_iter(&linker, &module, &mut store));
6262
});

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cargo-fuzz = true
1313
env_logger = "0.11.3"
1414
libfuzzer-sys = "0.4"
1515
log = "0.4.21"
16-
wasm-smith = "0.201.0"
16+
wasm-smith = "0.202.0"
1717
wasmprinter = { workspace = true }
1818
wasmtime = { workspace = true }
1919

fuzz/fuzz_targets/same_result.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ fuzz_target!(|data: &[u8]| {
132132
// Instantiate the snapshot and call the main function.
133133
let snapshot_instance = Instance::new(&mut store, &snapshot_module, &[]).unwrap();
134134
let snapshot_main_func = snapshot_instance.get_func(&mut store, main_func).unwrap();
135-
let main_args = wizer::dummy::dummy_values(snapshot_main_func.ty(&store).params());
135+
let main_args =
136+
wizer::dummy::dummy_values(snapshot_main_func.ty(&store).params()).unwrap();
136137
let mut snapshot_result =
137138
vec![wasmtime::Val::I32(0); snapshot_main_func.ty(&store).results().len()];
138139
let snapshot_call_result =

src/dummy.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,32 @@ pub fn dummy_func(store: &mut crate::Store, ty: FuncType, name: &str) -> Func {
5959

6060
/// Construct a dummy value for the given value type.
6161
#[cfg(fuzzing)]
62-
pub fn dummy_value(val_ty: ValType) -> Val {
63-
match val_ty {
62+
pub fn dummy_value(val_ty: ValType) -> Result<Val> {
63+
Ok(match val_ty {
6464
ValType::I32 => Val::I32(0),
6565
ValType::I64 => Val::I64(0),
6666
ValType::F32 => Val::F32(0),
6767
ValType::F64 => Val::F64(0),
6868
ValType::V128 => Val::V128(0.into()),
69-
ValType::ExternRef => Val::ExternRef(None),
70-
ValType::FuncRef => Val::FuncRef(None),
71-
}
69+
ValType::Ref(ref_type) => {
70+
if !ref_type.is_nullable() {
71+
anyhow::bail!("cannot create a dummy value for a non-nullable reference type");
72+
}
73+
if ref_type.matches(&RefType::EXTERNREF) {
74+
Val::ExternRef(None)
75+
} else if ref_type.matches(&RefType::FUNCREF) {
76+
Val::FuncRef(None)
77+
} else if ref_type.matches(&RefType::NULLFUNCREF) {
78+
Val::FuncRef(None)
79+
} else {
80+
panic!("Unknown RefType {:?}", ref_type);
81+
}
82+
}
83+
})
7284
}
7385

7486
/// Construct a sequence of dummy values for the given types.
7587
#[cfg(fuzzing)]
76-
pub fn dummy_values(val_tys: impl IntoIterator<Item = ValType>) -> Vec<Val> {
77-
val_tys.into_iter().map(dummy_value).collect()
88+
pub fn dummy_values(val_tys: impl IntoIterator<Item = ValType>) -> Result<Vec<Val>> {
89+
val_tys.into_iter().map(|ty| dummy_value(ty)).collect()
7890
}

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mod snapshot;
1717
mod stack_ext;
1818
mod translate;
1919

20+
use wasi_common::sync::WasiCtxBuilder;
2021
/// Re-export wasmtime so users can align with our version. This is
2122
/// especially useful when providing a custom Linker.
2223
pub use wasmtime;
@@ -31,7 +32,6 @@ use std::rc::Rc;
3132
use structopt::StructOpt;
3233
use wasi_common::WasiCtx;
3334
use wasmtime::{Engine, Extern};
34-
use wasmtime_wasi::WasiCtxBuilder;
3535

3636
const DEFAULT_INHERIT_STDIO: bool = true;
3737
const DEFAULT_INHERIT_ENV: bool = false;
@@ -776,9 +776,9 @@ impl Wizer {
776776
}
777777
for dir in &self.dirs {
778778
log::debug!("Preopening directory: {}", dir.display());
779-
let preopened = wasmtime_wasi::sync::Dir::open_ambient_dir(
779+
let preopened = wasi_common::sync::Dir::open_ambient_dir(
780780
dir,
781-
wasmtime_wasi::sync::ambient_authority(),
781+
wasi_common::sync::ambient_authority(),
782782
)
783783
.with_context(|| format!("failed to open directory: {}", dir.display()))?;
784784
ctx.preopened_dir(preopened, dir)?;
@@ -789,9 +789,9 @@ impl Wizer {
789789
guest_dir.display(),
790790
host_dir.display()
791791
);
792-
let preopened = wasmtime_wasi::sync::Dir::open_ambient_dir(
792+
let preopened = wasi_common::sync::Dir::open_ambient_dir(
793793
host_dir,
794-
wasmtime_wasi::sync::ambient_authority(),
794+
wasi_common::sync::ambient_authority(),
795795
)
796796
.with_context(|| format!("failed to open directory: {}", host_dir.display()))?;
797797
ctx.preopened_dir(preopened, guest_dir)?;
@@ -834,7 +834,7 @@ impl Wizer {
834834
};
835835

836836
if self.allow_wasi {
837-
wasmtime_wasi::add_to_linker(&mut linker, |ctx: &mut Option<WasiCtx>| {
837+
wasi_common::sync::add_to_linker(&mut linker, |ctx: &mut Option<WasiCtx>| {
838838
ctx.as_mut().unwrap()
839839
})?;
840840
}

0 commit comments

Comments
 (0)