Skip to content

Commit b8e47ab

Browse files
authored
Update the wasm-tools family of crates to version 249 (#13389)
* Update the wasm-tools family of crates to version 249 * More test updates/fixes * Update component-model tests for `async` keyword changes * cargo fmt * cargo vet * Update component-model git submodule for test fixes Includes WebAssembly/component-model#653 * Fix wizer compilation * Fix component_fuzz for component-model async updates * Update component model git submodule to latest `main`
1 parent 1da8d86 commit b8e47ab

29 files changed

Lines changed: 234 additions & 192 deletions

Cargo.lock

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

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,18 +351,18 @@ wit-bindgen = { version = "0.57.0", default-features = false }
351351
wit-bindgen-rust-macro = { version = "0.57.0", default-features = false }
352352

353353
# wasm-tools family:
354-
wasmparser = { version = "0.248.0", default-features = false, features = ['simd'] }
355-
wat = "1.248.0"
356-
wast = "248.0.0"
357-
wasmprinter = "0.248.0"
358-
wasm-encoder = "0.248.0"
359-
wasm-smith = "0.248.0"
360-
wasm-mutate = "0.248.0"
361-
wit-parser = "0.248.0"
362-
wit-component = "0.248.0"
363-
wasm-wave = "0.248.0"
364-
wasm-compose = { version = "0.248.0", default-features = false }
365-
json-from-wast = "0.248.0"
354+
wasmparser = { version = "0.249.0", default-features = false, features = ['simd'] }
355+
wat = "1.249.0"
356+
wast = "249.0.0"
357+
wasmprinter = "0.249.0"
358+
wasm-encoder = "0.249.0"
359+
wasm-smith = "0.249.0"
360+
wasm-mutate = "0.249.0"
361+
wit-parser = "0.249.0"
362+
wit-component = "0.249.0"
363+
wasm-wave = "0.249.0"
364+
wasm-compose = { version = "0.249.0", default-features = false }
365+
json-from-wast = "0.249.0"
366366

367367
wstd = "0.6.5"
368368
wasip2 = "1.0"

crates/environ/src/component/translate.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use wasmparser::component_types::{
1818
ComponentFuncTypeId, ComponentInstanceTypeId, ComponentValType,
1919
};
2020
use wasmparser::types::Types;
21-
use wasmparser::{Chunk, ComponentImportName, Encoding, Parser, Payload, Validator};
21+
use wasmparser::{Chunk, ComponentExternName, Encoding, Parser, Payload, Validator};
2222

2323
mod adapt;
2424
pub use self::adapt::*;
@@ -176,7 +176,7 @@ struct Translation<'data> {
176176
// is straight from `wasmparser`'s passes.
177177
enum LocalInitializer<'data> {
178178
// imports
179-
Import(ComponentImportName<'data>, ComponentEntityType),
179+
Import(ComponentExternName<'data>, ComponentEntityType),
180180

181181
// An import of an intrinsic for compile-time builtins.
182182
IntrinsicsImport,
@@ -768,11 +768,12 @@ impl<'a, 'data> Translator<'a, 'data> {
768768
let import = import?;
769769
let types = self.validator.types(0).unwrap();
770770
let ty = types
771-
.component_entity_type_of_import(import.name.0)
772-
.unwrap();
771+
.component_item_for_import(import.name.name)
772+
.unwrap()
773+
.ty;
773774

774-
if self.is_unsafe_intrinsics_import(import.name.0) {
775-
self.check_unsafe_intrinsics_import(import.name.0, ty)?;
775+
if self.is_unsafe_intrinsics_import(import.name.name) {
776+
self.check_unsafe_intrinsics_import(import.name.name, ty)?;
776777
self.result
777778
.initializers
778779
.push(LocalInitializer::IntrinsicsImport);
@@ -1309,7 +1310,7 @@ impl<'a, 'data> Translator<'a, 'data> {
13091310
for export in s {
13101311
let export = export?;
13111312
let item = self.kind_to_item(export.kind, export.index)?;
1312-
let prev = self.result.exports.insert(export.name.0, item);
1313+
let prev = self.result.exports.insert(export.name.name, item);
13131314
assert!(prev.is_none());
13141315
self.result
13151316
.initializers
@@ -1451,7 +1452,7 @@ impl<'a, 'data> Translator<'a, 'data> {
14511452
let mut map = HashMap::with_capacity(exports.len());
14521453
for export in exports {
14531454
let idx = self.kind_to_item(export.kind, export.index)?;
1454-
map.insert(export.name.0, idx);
1455+
map.insert(export.name.name, idx);
14551456
}
14561457

14571458
Ok(LocalInitializer::ComponentSynthetic(map, ty))
@@ -1662,13 +1663,13 @@ impl<'a, 'data> Translator<'a, 'data> {
16621663
);
16631664

16641665
for (name, ty) in &instance_ty.exports {
1665-
let ComponentEntityType::Func(func_ty) = ty else {
1666+
let ComponentEntityType::Func(func_ty) = ty.ty else {
16661667
bail!(
16671668
"bad unsafe intrinsics import: imported instance `{import}` must \
16681669
only export functions"
16691670
)
16701671
};
1671-
let func_ty = &types[*func_ty];
1672+
let func_ty = &types[func_ty];
16721673

16731674
fn ty_eq(a: &InterfaceType, b: &wasmparser::component_types::ComponentValType) -> bool {
16741675
use wasmparser::{PrimitiveValType as P, component_types::ComponentValType as C};

crates/environ/src/component/translate/inline.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ pub(super) fn run(
114114
if let TypeDef::Interface(_) = ty {
115115
continue;
116116
}
117-
let index = inliner.result.import_types.push((name.0.to_string(), ty));
117+
let index = inliner
118+
.result
119+
.import_types
120+
.push((name.name.to_string(), ty));
118121
let path = ImportPath::root(index);
119-
args.insert(name.0, ComponentItemDef::from_import(path, ty)?);
122+
args.insert(name.name, ComponentItemDef::from_import(path, ty)?);
120123
}
121124

122125
// This will run the inliner to completion after being seeded with the
@@ -441,7 +444,7 @@ impl<'a> Inliner<'a> {
441444
// was provided as an import at the instantiation-site to what was
442445
// needed during the component's instantiation.
443446
Import(name, ty) => {
444-
let arg = match frame.args.get(name.0) {
447+
let arg = match frame.args.get(name.name) {
445448
Some(arg) => arg,
446449

447450
// Not all arguments need to be provided for instantiation,

crates/environ/src/component/types_builder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,17 +325,17 @@ impl ComponentTypesBuilder {
325325
let ty = &types[id];
326326
let mut result = TypeComponent::default();
327327
for (name, ty) in ty.imports.iter() {
328-
self.register_abstract_component_entity_type(types, *ty);
328+
self.register_abstract_component_entity_type(types, ty.ty);
329329
result.imports.insert(
330330
name.clone(),
331-
self.convert_component_entity_type(types, *ty)?,
331+
self.convert_component_entity_type(types, ty.ty)?,
332332
);
333333
}
334334
for (name, ty) in ty.exports.iter() {
335-
self.register_abstract_component_entity_type(types, *ty);
335+
self.register_abstract_component_entity_type(types, ty.ty);
336336
result.exports.insert(
337337
name.clone(),
338-
self.convert_component_entity_type(types, *ty)?,
338+
self.convert_component_entity_type(types, ty.ty)?,
339339
);
340340
}
341341
Ok(self.component_types.components.push(result))
@@ -350,10 +350,10 @@ impl ComponentTypesBuilder {
350350
let ty = &types[id];
351351
let mut result = TypeComponentInstance::default();
352352
for (name, ty) in ty.exports.iter() {
353-
self.register_abstract_component_entity_type(types, *ty);
353+
self.register_abstract_component_entity_type(types, ty.ty);
354354
result.exports.insert(
355355
name.clone(),
356-
self.convert_component_entity_type(types, *ty)?,
356+
self.convert_component_entity_type(types, ty.ty)?,
357357
);
358358
}
359359
Ok(self.component_types.component_instances.push(result))

crates/environ/src/component/types_builder/resources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl ResourcesBuilder {
247247
let ty = &types[id];
248248
for (name, ty) in ty.exports.iter() {
249249
path.push(name);
250-
self.register_component_entity_type_(types, *ty, path, register);
250+
self.register_component_entity_type_(types, ty.ty, path, register);
251251
path.pop();
252252
}
253253
}

crates/test-util/src/component_fuzz.rs

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,28 @@ pub enum LowerAbi {
17081708
Async,
17091709
}
17101710

1711+
impl LiftAbi {
1712+
fn is_async(self) -> bool {
1713+
!matches!(self, Self::Sync)
1714+
}
1715+
1716+
fn ensure_async(&mut self) {
1717+
if !self.is_async() {
1718+
*self = Self::AsyncStackful;
1719+
}
1720+
}
1721+
}
1722+
1723+
impl LowerAbi {
1724+
fn is_async(self) -> bool {
1725+
matches!(self, Self::Async)
1726+
}
1727+
1728+
fn ensure_async(&mut self) {
1729+
*self = Self::Async;
1730+
}
1731+
}
1732+
17111733
impl<'a> TestCase<'a> {
17121734
pub fn generate(types: &'a [Type], u: &mut Unstructured<'_>) -> arbitrary::Result<Self> {
17131735
let max_params = if types.len() > 0 { 5 } else { 0 };
@@ -1722,15 +1744,25 @@ impl<'a> TestCase<'a> {
17221744

17231745
let mut options = u.arbitrary::<TestCaseOptions>()?;
17241746

1725-
// Sync tasks cannot call async functions via a sync lower, nor can they
1726-
// block in other ways (e.g. by calling `waitable-set.wait`, returning
1727-
// `CALLBACK_CODE_WAIT`, etc.) prior to returning. Therefore,
1728-
// async-ness cascades to the callers:
1729-
if options.host_async {
1747+
// Keep each boundary self-consistent: async function types require async
1748+
// lowering/lifting, and async callees force their callers async too.
1749+
if options.host_async || options.callee_lower_abi.is_async() {
1750+
options.host_async = true;
1751+
options.callee_lower_abi.ensure_async();
17301752
options.guest_callee_async = true;
17311753
}
1732-
if options.guest_callee_async {
1754+
if options.guest_callee_async
1755+
|| options.callee_lift_abi.is_async()
1756+
|| options.caller_lower_abi.is_async()
1757+
{
1758+
options.guest_callee_async = true;
1759+
options.callee_lift_abi.ensure_async();
1760+
options.caller_lower_abi.ensure_async();
1761+
options.guest_caller_async = true;
1762+
}
1763+
if options.guest_caller_async || options.caller_lift_abi.is_async() {
17331764
options.guest_caller_async = true;
1765+
options.caller_lift_abi.ensure_async();
17341766
}
17351767

17361768
Ok(Self {

crates/test-util/src/wast.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,14 @@ impl WastTest {
469469
let unsupported = [
470470
// These tests in the `component-model` submodule have not yet been
471471
// updated to account for the recent threading-related intrinsic
472-
// changes
473-
"test/async/same-component-stream-future.wast",
472+
// changes.
474473
"test/async/trap-if-block-and-sync.wast",
474+
// Wasmtime doesn't expose the component-model `cm64` feature toggle
475+
// yet, so this parser-only test can't be enabled here.
476+
"test/wasm-tools/memory64.wast",
477+
// Cancellable `thread.yield` semantics still diverge from the
478+
// latest submodule expectation.
479+
"test/async/cancellable.wast",
475480
];
476481
if unsupported.iter().any(|part| self.path.ends_with(part)) {
477482
return true;

crates/wasmtime/src/compile/code_builder/compile_time_builtins.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ impl<'a> CodeBuilder<'a> {
8989
// unfortunately the `wasm-compose` API is not powerful
9090
// enough for us to do all that.
9191
ensure!(
92-
imp.name.0 != intrinsics_import,
92+
imp.name.name != intrinsics_import,
9393
"main Wasm cannot import the unsafe intrinsics (`{intrinsics_import}`) \
9494
when using compile-time builtins"
9595
);
9696

9797
if let wasmparser::ComponentTypeRef::Instance(_) = imp.ty {
98-
instance_imports.insert(imp.name.0);
98+
instance_imports.insert(imp.name.name);
9999
}
100100
}
101101
}

crates/wast/src/spectest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ pub fn link_component_spectest<T>(linker: &mut component::Linker<T>) -> Result<(
9696
let engine = linker.engine().clone();
9797
linker
9898
.root()
99-
.func_wrap("host-echo-u32", |_, v: (u32,)| Ok(v))?;
99+
.func_wrap_concurrent("host-echo-u32", |_, (v,): (u32,)| {
100+
Box::pin(async move { Ok((v,)) })
101+
})?;
100102
linker
101103
.root()
102104
.func_wrap("host-return-two", |_, _: ()| Ok((2u32,)))?;

0 commit comments

Comments
 (0)