Skip to content

Commit

Permalink
Update the wasm-tools family of crates
Browse files Browse the repository at this point in the history
This commit updates to the latest wasm-tools and `wit-bindgen` to bring
the family of crates forward. This update notably includes Nick's work
on packed indices in the `wasmparser` crate for validation for the
upcoming implementation of GC types. This meant that translation from
`wasmparser` types to Wasmtime types now may work with a "type id"
instead of just a type index which required plumbing not only Wasmtime's
own type information but additionally `wasmparser`'s type information
throughout translation.

This required a fair bit of refactoring to get this working but no
change in functionality is intended, only a different way of doing
everything prior.
  • Loading branch information
alexcrichton committed Nov 27, 2023
1 parent 6506567 commit 119f655
Show file tree
Hide file tree
Showing 29 changed files with 363 additions and 231 deletions.
112 changes: 38 additions & 74 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,18 @@ io-extras = "0.18.0"
rustix = "0.38.21"
is-terminal = "0.4.0"
# wit-bindgen:
wit-bindgen = { version = "0.13.1", default-features = false }
wit-bindgen = { version = "0.15.0", default-features = false }

# wasm-tools family:
wasmparser = "0.116.0"
wat = "1.0.79"
wast = "67.0.1"
wasmprinter = "0.2.72"
wasm-encoder = "0.36.2"
wasm-smith = "0.12.23"
wasm-mutate = "0.2.40"
wasmparser = "0.118.0"
wat = "1.0.81"
wast = "69.0.0"
wasmprinter = "0.2.74"
wasm-encoder = "0.38.0"
wasm-smith = "0.13.0"
wasm-mutate = "0.2.42"
wit-parser = "0.13.0"
wit-component = "0.18.0"
wit-component = "0.18.2"

# Non-Bytecode Alliance maintained dependencies:
# --------------------------
Expand Down
4 changes: 2 additions & 2 deletions cranelift/filetests/src/test_wasm/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<'data> ModuleEnvironment<'data> for ModuleEnv {
}

impl TypeConvert for ModuleEnv {
fn lookup_heap_type(&self, _index: TypeIndex) -> WasmHeapType {
fn lookup_heap_type(&self, _index: wasmparser::UnpackedIndex) -> WasmHeapType {
todo!()
}
}
Expand Down Expand Up @@ -271,7 +271,7 @@ impl<'a> FuncEnv<'a> {
}

impl TypeConvert for FuncEnv<'_> {
fn lookup_heap_type(&self, _index: TypeIndex) -> WasmHeapType {
fn lookup_heap_type(&self, _index: wasmparser::UnpackedIndex) -> WasmHeapType {
todo!()
}
}
Expand Down
4 changes: 2 additions & 2 deletions cranelift/wasm/src/environ/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl<'dummy_environment> DummyFuncEnvironment<'dummy_environment> {
}

impl<'dummy_environment> TypeConvert for DummyFuncEnvironment<'dummy_environment> {
fn lookup_heap_type(&self, _index: TypeIndex) -> WasmHeapType {
fn lookup_heap_type(&self, _index: wasmparser::UnpackedIndex) -> WasmHeapType {
unimplemented!()
}
}
Expand Down Expand Up @@ -704,7 +704,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
}

impl TypeConvert for DummyEnvironment {
fn lookup_heap_type(&self, _index: TypeIndex) -> WasmHeapType {
fn lookup_heap_type(&self, _index: wasmparser::UnpackedIndex) -> WasmHeapType {
unimplemented!()
}
}
Expand Down
24 changes: 8 additions & 16 deletions cranelift/wasm/src/translation_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,14 @@ where
T: WasmModuleResources,
{
return Ok(match ty {
wasmparser::BlockType::Empty => {
let params: &'static [wasmparser::ValType] = &[];
let results: std::vec::Vec<wasmparser::ValType> = vec![];
(
itertools::Either::Left(params.iter().copied()),
itertools::Either::Left(results.into_iter()),
)
}
wasmparser::BlockType::Type(ty) => {
let params: &'static [wasmparser::ValType] = &[];
let results: std::vec::Vec<wasmparser::ValType> = vec![ty.clone()];
(
itertools::Either::Left(params.iter().copied()),
itertools::Either::Left(results.into_iter()),
)
}
wasmparser::BlockType::Empty => (
itertools::Either::Left(std::iter::empty()),
itertools::Either::Left(None.into_iter()),
),
wasmparser::BlockType::Type(ty) => (
itertools::Either::Left(std::iter::empty()),
itertools::Either::Left(Some(ty).into_iter()),
),
wasmparser::BlockType::FuncType(ty_index) => {
let ty = validator
.resources()
Expand Down
Loading

0 comments on commit 119f655

Please sign in to comment.