Skip to content

Commit

Permalink
Update wasm-tools and wit-bindgen crates (bytecodealliance#8965)
Browse files Browse the repository at this point in the history
* Update wasm-tools and wit-bindgen crates

This keeps things updated and pulls in some new features from
wasm-tools:

* Multiple returns in the component model are now gated by default. This
  is reflected in a new `Config` option and CLI flag. The hope is to
  remove this feature is no one ends up needing it.

* Support for more `shared` things were added but the feature is always
  disabled so internal handlers just panic.

Tests were updated to not use multiple returns where appropriate, except
for one test which is specifically testing for multiple returns and how
it's reflected into the Rust type system.

* Fix fuzz build
  • Loading branch information
alexcrichton authored Jul 16, 2024
1 parent da4ea5c commit 88b45a4
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 102 deletions.
66 changes: 33 additions & 33 deletions Cargo.lock

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

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,19 @@ io-lifetimes = { version = "2.0.3", default-features = false }
io-extras = "0.18.1"
rustix = "0.38.31"
# wit-bindgen:
wit-bindgen = { version = "0.27.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.27.0", default-features = false }
wit-bindgen = { version = "0.28.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.28.0", default-features = false }

# wasm-tools family:
wasmparser = { version = "0.212.0", default-features = false }
wat = "1.212.0"
wast = "212.0.0"
wasmprinter = "0.212.0"
wasm-encoder = "0.212.0"
wasm-smith = "0.212.0"
wasm-mutate = "0.212.0"
wit-parser = "0.212.0"
wit-component = "0.212.0"
wasmparser = { version = "0.214.0", default-features = false }
wat = "1.214.0"
wast = "214.0.0"
wasmprinter = "0.214.0"
wasm-encoder = "0.214.0"
wasm-smith = "0.214.0"
wasm-mutate = "0.214.0"
wit-parser = "0.214.0"
wit-component = "0.214.0"

# Non-Bytecode Alliance maintained dependencies:
# --------------------------
Expand Down
29 changes: 28 additions & 1 deletion cranelift/wasm/src/code_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2551,7 +2551,34 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
| Operator::GlobalAtomicRmwXor { .. }
| Operator::GlobalAtomicRmwAnd { .. }
| Operator::GlobalAtomicRmwXchg { .. }
| Operator::GlobalAtomicRmwCmpxchg { .. } => {
| Operator::GlobalAtomicRmwCmpxchg { .. }
| Operator::TableAtomicGet { .. }
| Operator::TableAtomicSet { .. }
| Operator::TableAtomicRmwXchg { .. }
| Operator::TableAtomicRmwCmpxchg { .. }
| Operator::StructAtomicGet { .. }
| Operator::StructAtomicGetS { .. }
| Operator::StructAtomicGetU { .. }
| Operator::StructAtomicSet { .. }
| Operator::StructAtomicRmwAdd { .. }
| Operator::StructAtomicRmwSub { .. }
| Operator::StructAtomicRmwOr { .. }
| Operator::StructAtomicRmwXor { .. }
| Operator::StructAtomicRmwAnd { .. }
| Operator::StructAtomicRmwXchg { .. }
| Operator::StructAtomicRmwCmpxchg { .. }
| Operator::ArrayAtomicGet { .. }
| Operator::ArrayAtomicGetS { .. }
| Operator::ArrayAtomicGetU { .. }
| Operator::ArrayAtomicSet { .. }
| Operator::ArrayAtomicRmwAdd { .. }
| Operator::ArrayAtomicRmwSub { .. }
| Operator::ArrayAtomicRmwOr { .. }
| Operator::ArrayAtomicRmwXor { .. }
| Operator::ArrayAtomicRmwAnd { .. }
| Operator::ArrayAtomicRmwXchg { .. }
| Operator::ArrayAtomicRmwCmpxchg { .. }
| Operator::RefI31Shared { .. } => {
unimplemented!("shared-everything-threads not yet implemented")
}
};
Expand Down
3 changes: 3 additions & 0 deletions crates/cli-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ wasmtime_option_group! {
pub component_model: Option<bool>,
/// Configure support for 33+ flags in the component model.
pub component_model_more_flags: Option<bool>,
/// Component model support for more than one return value.
pub component_model_multiple_returns: Option<bool>,
/// Configure support for the function-references proposal.
pub function_references: Option<bool>,
/// Configure support for the GC proposal.
Expand Down Expand Up @@ -682,6 +684,7 @@ impl CommonOptions {
handle_conditionally_compiled! {
("component-model", component_model, wasm_component_model)
("component-model", component_model_more_flags, wasm_component_model_more_flags)
("component-model", component_model_multiple_returns, wasm_component_model_multiple_returns)
("threads", threads, wasm_threads)
("gc", gc, wasm_gc)
("gc", reference_types, wasm_reference_types)
Expand Down
32 changes: 24 additions & 8 deletions crates/environ/src/compile/module_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,18 @@ impl TypeConvert for WasmparserTypeConverter<'_> {
WasmCompositeType::Struct(_) => WasmHeapType::ConcreteStruct(index),
}
} else if let Some((wasmparser_types, _)) = self.rec_group_context.as_ref() {
match &wasmparser_types[id].composite_type {
wasmparser::CompositeType::Array(_) => WasmHeapType::ConcreteArray(index),
wasmparser::CompositeType::Func(_) => WasmHeapType::ConcreteFunc(index),
wasmparser::CompositeType::Struct(_) => WasmHeapType::ConcreteStruct(index),
let wasmparser_ty = &wasmparser_types[id].composite_type;
assert!(!wasmparser_ty.shared);
match &wasmparser_ty.inner {
wasmparser::CompositeInnerType::Array(_) => {
WasmHeapType::ConcreteArray(index)
}
wasmparser::CompositeInnerType::Func(_) => {
WasmHeapType::ConcreteFunc(index)
}
wasmparser::CompositeInnerType::Struct(_) => {
WasmHeapType::ConcreteStruct(index)
}
}
} else {
panic!("forward reference to type outside of rec group?")
Expand Down Expand Up @@ -424,10 +432,18 @@ impl TypeConvert for WasmparserTypeConverter<'_> {
.rec_group_elements(*rec_group)
.nth(rec_group_index)
.unwrap();
match &parser_types[id].composite_type {
wasmparser::CompositeType::Array(_) => WasmHeapType::ConcreteArray(index),
wasmparser::CompositeType::Func(_) => WasmHeapType::ConcreteFunc(index),
wasmparser::CompositeType::Struct(_) => WasmHeapType::ConcreteStruct(index),
let wasmparser_ty = &parser_types[id].composite_type;
assert!(!wasmparser_ty.shared);
match &wasmparser_ty.inner {
wasmparser::CompositeInnerType::Array(_) => {
WasmHeapType::ConcreteArray(index)
}
wasmparser::CompositeInnerType::Func(_) => {
WasmHeapType::ConcreteFunc(index)
}
wasmparser::CompositeInnerType::Struct(_) => {
WasmHeapType::ConcreteStruct(index)
}
}
} else {
panic!("forward reference to type outside of rec group?")
Expand Down
1 change: 1 addition & 0 deletions crates/fuzzing/src/generators/table_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl TableOps {
minimum: self.table_size as u64,
maximum: None,
table64: false,
shared: false,
});

// Define our globals.
Expand Down
9 changes: 5 additions & 4 deletions crates/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,14 +1723,15 @@ pub trait TypeConvert {
}

fn convert_composite_type(&self, ty: &wasmparser::CompositeType) -> WasmCompositeType {
match ty {
wasmparser::CompositeType::Func(f) => {
assert!(!ty.shared);
match &ty.inner {
wasmparser::CompositeInnerType::Func(f) => {
WasmCompositeType::Func(self.convert_func_type(f))
}
wasmparser::CompositeType::Array(a) => {
wasmparser::CompositeInnerType::Array(a) => {
WasmCompositeType::Array(self.convert_array_type(a))
}
wasmparser::CompositeType::Struct(s) => {
wasmparser::CompositeInnerType::Struct(s) => {
WasmCompositeType::Struct(self.convert_struct_type(s))
}
}
Expand Down
11 changes: 11 additions & 0 deletions crates/wasmtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,17 @@ impl Config {
self
}

/// Configures whether components support more than one return value for functions.
///
/// This is part of the transition plan in
/// https://github.com/WebAssembly/component-model/pull/368.
#[cfg(feature = "component-model")]
pub fn wasm_component_model_multiple_returns(&mut self, enable: bool) -> &mut Self {
self.features
.set(WasmFeatures::COMPONENT_MODEL_MULTIPLE_RETURNS, enable);
self
}

/// Configures which compilation strategy will be used for wasm modules.
///
/// This method can be used to configure which compiler is used for wasm
Expand Down
Loading

0 comments on commit 88b45a4

Please sign in to comment.