Skip to content

Commit

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

Pull in recent updates and denying memory64 support in components during
validation.

* Fix renamings in wave

* Fix some bindgen tests
  • Loading branch information
alexcrichton authored Jan 8, 2025
1 parent 0174225 commit 4c5f250
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 164 deletions.
159 changes: 80 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,16 @@ wit-bindgen = { version = "0.35.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.35.0", default-features = false }

# wasm-tools family:
wasmparser = { version = "0.221.2", default-features = false, features = ['simd'] }
wat = "1.221.2"
wast = "221.0.2"
wasmprinter = "0.221.2"
wasm-encoder = "0.221.2"
wasm-smith = "0.221.2"
wasm-mutate = "0.221.2"
wit-parser = "0.221.2"
wit-component = "0.221.2"
wasm-wave = "0.221.2"
wasmparser = { version = "0.223.0", default-features = false, features = ['simd'] }
wat = "1.223.0"
wast = "223.0.0"
wasmprinter = "0.223.0"
wasm-encoder = "0.223.0"
wasm-smith = "0.223.0"
wasm-mutate = "0.223.0"
wit-parser = "0.223.0"
wit-component = "0.223.0"
wasm-wave = "0.223.0"

# Non-Bytecode Alliance maintained dependencies:
# --------------------------
Expand Down
6 changes: 3 additions & 3 deletions crates/component-macro/tests/expanded/conventions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub mod foo {
fn apple_pear_grape(&mut self) -> ();
fn a0(&mut self) -> ();
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down Expand Up @@ -393,7 +393,7 @@ pub mod foo {
Host::a0(*self)
}
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down Expand Up @@ -756,7 +756,7 @@ pub mod exports {
Ok(())
}
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down
6 changes: 3 additions & 3 deletions crates/component-macro/tests/expanded/conventions_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub mod foo {
async fn apple_pear_grape(&mut self) -> ();
async fn a0(&mut self) -> ();
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down Expand Up @@ -429,7 +429,7 @@ pub mod foo {
Host::a0(*self).await
}
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down Expand Up @@ -818,7 +818,7 @@ pub mod exports {
Ok(())
}
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub mod foo {
async fn apple_pear_grape(&mut self) -> ();
async fn a0(&mut self) -> ();
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down Expand Up @@ -589,7 +589,7 @@ pub mod foo {
Host::a0(*self).await
}
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down Expand Up @@ -1065,7 +1065,7 @@ pub mod exports {
Ok(())
}
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
/// https://github.com/WebAssembly/component-model/issues/118
/// APPLE: func()
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
Expand Down
29 changes: 29 additions & 0 deletions crates/environ/src/component/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,32 @@ impl<'a, 'data> Translator<'a, 'data> {
| wasmparser::CanonicalFunction::ThreadHwConcurrency => {
bail!("unsupported intrinsic")
}

wasmparser::CanonicalFunction::TaskBackpressure
| wasmparser::CanonicalFunction::TaskPoll { .. }
| wasmparser::CanonicalFunction::TaskYield { .. }
| wasmparser::CanonicalFunction::SubtaskDrop
| wasmparser::CanonicalFunction::StreamNew { .. }
| wasmparser::CanonicalFunction::StreamRead { .. }
| wasmparser::CanonicalFunction::StreamWrite { .. }
| wasmparser::CanonicalFunction::StreamCancelRead { .. }
| wasmparser::CanonicalFunction::StreamCancelWrite { .. }
| wasmparser::CanonicalFunction::StreamCloseReadable { .. }
| wasmparser::CanonicalFunction::StreamCloseWritable { .. }
| wasmparser::CanonicalFunction::FutureNew { .. }
| wasmparser::CanonicalFunction::FutureRead { .. }
| wasmparser::CanonicalFunction::FutureWrite { .. }
| wasmparser::CanonicalFunction::FutureCancelRead { .. }
| wasmparser::CanonicalFunction::FutureCancelWrite { .. }
| wasmparser::CanonicalFunction::FutureCloseReadable { .. }
| wasmparser::CanonicalFunction::FutureCloseWritable { .. }
| wasmparser::CanonicalFunction::ErrorContextNew { .. }
| wasmparser::CanonicalFunction::ErrorContextDebugMessage { .. }
| wasmparser::CanonicalFunction::ErrorContextDrop
| wasmparser::CanonicalFunction::TaskReturn { .. }
| wasmparser::CanonicalFunction::TaskWait { .. } => {
bail!("unsupported intrinsic")
}
};
self.result.initializers.push(init);
}
Expand Down Expand Up @@ -920,6 +946,9 @@ impl<'a, 'data> Translator<'a, 'data> {
let idx = FuncIndex::from_u32(*idx);
ret.post_return = Some(idx);
}
wasmparser::CanonicalOption::Async | wasmparser::CanonicalOption::Callback(_) => {
todo!()
}
}
}
return ret;
Expand Down
3 changes: 3 additions & 0 deletions crates/environ/src/component/types_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ impl ComponentTypesBuilder {
ComponentDefinedType::Borrow(r) => {
InterfaceType::Borrow(self.resource_id(r.resource()))
}
ComponentDefinedType::Future(_)
| ComponentDefinedType::Stream(_)
| ComponentDefinedType::ErrorContext => bail!("unsupported async type"),
};
let info = self.type_information(&ret);
if info.depth > MAX_TYPE_DEPTH {
Expand Down
2 changes: 2 additions & 0 deletions crates/wasmtime/src/engine/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ impl Metadata<'_> {
component_model_nested_names,
component_model_more_flags,
component_model_multiple_returns,
component_model_async,
legacy_exceptions,
gc_types,
stack_switching,
Expand All @@ -252,6 +253,7 @@ impl Metadata<'_> {
assert!(!shared_everything_threads);
assert!(!legacy_exceptions);
assert!(!stack_switching);
assert!(!component_model_async);

Metadata {
target: engine.compiler().triple().to_string(),
Expand Down
20 changes: 10 additions & 10 deletions crates/wasmtime/src/runtime/wave/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ impl WasmType for component::Type {
Self::U32 => WasmTypeKind::U32,
Self::S64 => WasmTypeKind::S64,
Self::U64 => WasmTypeKind::U64,
Self::Float32 => WasmTypeKind::Float32,
Self::Float64 => WasmTypeKind::Float64,
Self::Float32 => WasmTypeKind::F32,
Self::Float64 => WasmTypeKind::F64,
Self::Char => WasmTypeKind::Char,
Self::String => WasmTypeKind::String,
Self::List(_) => WasmTypeKind::List,
Expand Down Expand Up @@ -122,8 +122,8 @@ impl WasmValue for component::Val {
Self::U32(_) => WasmTypeKind::U32,
Self::S64(_) => WasmTypeKind::S64,
Self::U64(_) => WasmTypeKind::U64,
Self::Float32(_) => WasmTypeKind::Float32,
Self::Float64(_) => WasmTypeKind::Float64,
Self::Float32(_) => WasmTypeKind::F32,
Self::Float64(_) => WasmTypeKind::F64,
Self::Char(_) => WasmTypeKind::Char,
Self::String(_) => WasmTypeKind::String,
Self::List(_) => WasmTypeKind::List,
Expand Down Expand Up @@ -152,11 +152,11 @@ impl WasmValue for component::Val {
(Char, char, make_char, unwrap_char)
);

fn make_float32(val: f32) -> Self {
fn make_f32(val: f32) -> Self {
let val = canonicalize_nan32(val);
Self::Float32(val)
}
fn make_float64(val: f64) -> Self {
fn make_f64(val: f64) -> Self {
let val = canonicalize_nan64(val);
Self::Float64(val)
}
Expand Down Expand Up @@ -238,12 +238,12 @@ impl WasmValue for component::Val {
Ok(val)
}

fn unwrap_float32(&self) -> f32 {
let val = *unwrap_val!(self, Self::Float32, "float32");
fn unwrap_f32(&self) -> f32 {
let val = *unwrap_val!(self, Self::Float32, "f32");
canonicalize_nan32(val)
}
fn unwrap_float64(&self) -> f64 {
let val = *unwrap_val!(self, Self::Float64, "float64");
fn unwrap_f64(&self) -> f64 {
let val = *unwrap_val!(self, Self::Float64, "f64");
canonicalize_nan64(val)
}
fn unwrap_string(&self) -> Cow<str> {
Expand Down
20 changes: 10 additions & 10 deletions crates/wasmtime/src/runtime/wave/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ impl WasmType for crate::ValType {
match self {
Self::I32 => WasmTypeKind::S32,
Self::I64 => WasmTypeKind::S64,
Self::F32 => WasmTypeKind::Float32,
Self::F64 => WasmTypeKind::Float64,
Self::F32 => WasmTypeKind::F32,
Self::F64 => WasmTypeKind::F64,
Self::V128 => WasmTypeKind::Tuple,

Self::Ref(_) => WasmTypeKind::Unsupported,
Expand All @@ -33,8 +33,8 @@ impl WasmValue for crate::Val {
match self {
Self::I32(_) => WasmTypeKind::S32,
Self::I64(_) => WasmTypeKind::S64,
Self::F32(_) => WasmTypeKind::Float32,
Self::F64(_) => WasmTypeKind::Float64,
Self::F32(_) => WasmTypeKind::F32,
Self::F64(_) => WasmTypeKind::F64,
Self::V128(_) => WasmTypeKind::Tuple,
Self::FuncRef(_) => WasmTypeKind::Unsupported,
Self::ExternRef(_) => WasmTypeKind::Unsupported,
Expand All @@ -48,11 +48,11 @@ impl WasmValue for crate::Val {
fn make_s64(val: i64) -> Self {
Self::I64(val)
}
fn make_float32(val: f32) -> Self {
fn make_f32(val: f32) -> Self {
let val = canonicalize_nan32(val);
Self::F32(val.to_bits())
}
fn make_float64(val: f64) -> Self {
fn make_f64(val: f64) -> Self {
let val = canonicalize_nan64(val);
Self::F64(val.to_bits())
}
Expand Down Expand Up @@ -88,13 +88,13 @@ impl WasmValue for crate::Val {
*unwrap_val!(self, Self::I64, "s64")
}

fn unwrap_float32(&self) -> f32 {
let val = f32::from_bits(*unwrap_val!(self, Self::F32, "float32"));
fn unwrap_f32(&self) -> f32 {
let val = f32::from_bits(*unwrap_val!(self, Self::F32, "f32"));
canonicalize_nan32(val)
}

fn unwrap_float64(&self) -> f64 {
let val = f64::from_bits(*unwrap_val!(self, Self::F64, "float64"));
fn unwrap_f64(&self) -> f64 {
let val = f64::from_bits(*unwrap_val!(self, Self::F64, "f64"));
canonicalize_nan64(val)
}

Expand Down
9 changes: 4 additions & 5 deletions crates/wit-bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ impl<'a> InterfaceGenerator<'a> {
TypeDefKind::Type(t) => self.type_alias(id, name, t, &ty.docs),
TypeDefKind::Future(_) => todo!("generate for future"),
TypeDefKind::Stream(_) => todo!("generate for stream"),
TypeDefKind::ErrorContext => todo!("generate for error-context"),
TypeDefKind::Handle(handle) => self.type_handle(id, name, handle, &ty.docs),
TypeDefKind::Resource => self.type_resource(id, name, ty, &ty.docs),
TypeDefKind::Unknown => unreachable!(),
Expand Down Expand Up @@ -3237,6 +3238,7 @@ fn type_contains_lists(ty: Type, resolve: &Resolve) -> bool {
Type::Id(id) => match &resolve.types[id].kind {
TypeDefKind::Resource
| TypeDefKind::Unknown
| TypeDefKind::ErrorContext
| TypeDefKind::Flags(_)
| TypeDefKind::Handle(_)
| TypeDefKind::Enum(_) => false,
Expand All @@ -3258,11 +3260,8 @@ fn type_contains_lists(ty: Type, resolve: &Resolve) -> bool {
.iter()
.any(|case| option_type_contains_lists(case.ty, resolve)),
TypeDefKind::Type(ty) => type_contains_lists(*ty, resolve),
TypeDefKind::Future(ty) => option_type_contains_lists(*ty, resolve),
TypeDefKind::Stream(Stream { element, end }) => {
option_type_contains_lists(*element, resolve)
|| option_type_contains_lists(*end, resolve)
}
TypeDefKind::Future(_) => todo!(),
TypeDefKind::Stream(_) => todo!(),
TypeDefKind::List(_) => true,
},

Expand Down
18 changes: 5 additions & 13 deletions crates/wit-bindgen/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ pub trait RustGenerator<'a> {
| TypeDefKind::Enum(_)
| TypeDefKind::Tuple(_)
| TypeDefKind::Handle(_)
| TypeDefKind::Resource => true,
| TypeDefKind::Resource
| TypeDefKind::ErrorContext => true,
TypeDefKind::Type(Type::Id(t)) => {
needs_generics(resolve, &resolve.types[*t].kind)
}
Expand Down Expand Up @@ -165,18 +166,9 @@ pub trait RustGenerator<'a> {
TypeDefKind::Enum(_) => {
panic!("unsupported anonymous type reference: enum")
}
TypeDefKind::Future(ty) => {
self.push_str("Future<");
self.print_optional_ty(ty.as_ref(), mode);
self.push_str(">");
}
TypeDefKind::Stream(stream) => {
self.push_str("Stream<");
self.print_optional_ty(stream.element.as_ref(), mode);
self.push_str(",");
self.print_optional_ty(stream.end.as_ref(), mode);
self.push_str(">");
}
TypeDefKind::Future(_) => todo!(),
TypeDefKind::Stream(_) => todo!(),
TypeDefKind::ErrorContext => todo!(),

TypeDefKind::Handle(handle) => {
self.print_handle(handle);
Expand Down
10 changes: 3 additions & 7 deletions crates/wit-bindgen/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,9 @@ impl Types {
info = self.optional_type_info(resolve, r.ok.as_ref());
info |= self.optional_type_info(resolve, r.err.as_ref());
}
TypeDefKind::Future(ty) => {
info = self.optional_type_info(resolve, ty.as_ref());
}
TypeDefKind::Stream(stream) => {
info = self.optional_type_info(resolve, stream.element.as_ref());
info |= self.optional_type_info(resolve, stream.end.as_ref());
}
TypeDefKind::Future(_) => todo!(),
TypeDefKind::Stream(_) => todo!(),
TypeDefKind::ErrorContext => todo!(),
TypeDefKind::Handle(_) => info.has_handle = true,
TypeDefKind::Resource => {}
TypeDefKind::Unknown => unreachable!(),
Expand Down
2 changes: 1 addition & 1 deletion supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4217,7 +4217,7 @@ end = "2025-12-02"
criteria = "safe-to-deploy"
user-id = 539 # Josh Stone (cuviper)
start = "2020-01-15"
end = "2024-07-06"
end = "2026-01-08"

[[trusted.io-extras]]
criteria = "safe-to-deploy"
Expand Down
Loading

0 comments on commit 4c5f250

Please sign in to comment.