Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 70 additions & 70 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,18 @@ wit-bindgen = { version = "0.57.0", default-features = false }
wit-bindgen-rust-macro = { version = "0.57.0", default-features = false }

# wasm-tools family:
wasmparser = { version = "0.248.0", default-features = false, features = ['simd'] }
wat = "1.248.0"
wast = "248.0.0"
wasmprinter = "0.248.0"
wasm-encoder = "0.248.0"
wasm-smith = "0.248.0"
wasm-mutate = "0.248.0"
wit-parser = "0.248.0"
wit-component = "0.248.0"
wasm-wave = "0.248.0"
wasm-compose = { version = "0.248.0", default-features = false }
json-from-wast = "0.248.0"
wasmparser = { version = "0.249.0", default-features = false, features = ['simd'] }
wat = "1.249.0"
wast = "249.0.0"
wasmprinter = "0.249.0"
wasm-encoder = "0.249.0"
wasm-smith = "0.249.0"
wasm-mutate = "0.249.0"
wit-parser = "0.249.0"
wit-component = "0.249.0"
wasm-wave = "0.249.0"
wasm-compose = { version = "0.249.0", default-features = false }
json-from-wast = "0.249.0"

wstd = "0.6.5"
wasip2 = "1.0"
Expand Down
21 changes: 10 additions & 11 deletions crates/environ/src/component/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use wasmparser::component_types::{
ComponentFuncTypeId, ComponentInstanceTypeId, ComponentValType,
};
use wasmparser::types::Types;
use wasmparser::{Chunk, ComponentImportName, Encoding, Parser, Payload, Validator};
use wasmparser::{Chunk, ComponentExternName, Encoding, Parser, Payload, Validator};

mod adapt;
pub use self::adapt::*;
Expand Down Expand Up @@ -176,7 +176,7 @@ struct Translation<'data> {
// is straight from `wasmparser`'s passes.
enum LocalInitializer<'data> {
// imports
Import(ComponentImportName<'data>, ComponentEntityType),
Import(ComponentExternName<'data>, ComponentEntityType),

// An import of an intrinsic for compile-time builtins.
IntrinsicsImport,
Expand Down Expand Up @@ -767,12 +767,10 @@ impl<'a, 'data> Translator<'a, 'data> {
for import in s {
let import = import?;
let types = self.validator.types(0).unwrap();
let ty = types
.component_entity_type_of_import(import.name.0)
.unwrap();
let ty = types.component_item_for_import(import.name.name).unwrap().ty;

if self.is_unsafe_intrinsics_import(import.name.0) {
self.check_unsafe_intrinsics_import(import.name.0, ty)?;
if self.is_unsafe_intrinsics_import(import.name.name) {
self.check_unsafe_intrinsics_import(import.name.name, ty)?;
self.result
.initializers
.push(LocalInitializer::IntrinsicsImport);
Expand Down Expand Up @@ -1309,7 +1307,7 @@ impl<'a, 'data> Translator<'a, 'data> {
for export in s {
let export = export?;
let item = self.kind_to_item(export.kind, export.index)?;
let prev = self.result.exports.insert(export.name.0, item);
let prev = self.result.exports.insert(export.name.name, item);
assert!(prev.is_none());
self.result
.initializers
Expand Down Expand Up @@ -1451,7 +1449,7 @@ impl<'a, 'data> Translator<'a, 'data> {
let mut map = HashMap::with_capacity(exports.len());
for export in exports {
let idx = self.kind_to_item(export.kind, export.index)?;
map.insert(export.name.0, idx);
map.insert(export.name.name, idx);
}

Ok(LocalInitializer::ComponentSynthetic(map, ty))
Expand Down Expand Up @@ -1487,6 +1485,7 @@ impl<'a, 'data> Translator<'a, 'data> {
let ty = types.component_any_type_at(index);
ComponentItem::Type(ty)
}

})
}

Expand Down Expand Up @@ -1662,13 +1661,13 @@ impl<'a, 'data> Translator<'a, 'data> {
);

for (name, ty) in &instance_ty.exports {
let ComponentEntityType::Func(func_ty) = ty else {
let ComponentEntityType::Func(func_ty) = ty.ty else {
bail!(
"bad unsafe intrinsics import: imported instance `{import}` must \
only export functions"
)
};
let func_ty = &types[*func_ty];
let func_ty = &types[func_ty];

fn ty_eq(a: &InterfaceType, b: &wasmparser::component_types::ComponentValType) -> bool {
use wasmparser::{PrimitiveValType as P, component_types::ComponentValType as C};
Expand Down
6 changes: 3 additions & 3 deletions crates/environ/src/component/translate/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ pub(super) fn run(
if let TypeDef::Interface(_) = ty {
continue;
}
let index = inliner.result.import_types.push((name.0.to_string(), ty));
let index = inliner.result.import_types.push((name.name.to_string(), ty));
let path = ImportPath::root(index);
args.insert(name.0, ComponentItemDef::from_import(path, ty)?);
args.insert(name.name, ComponentItemDef::from_import(path, ty)?);
}

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

// Not all arguments need to be provided for instantiation,
Expand Down
27 changes: 12 additions & 15 deletions crates/environ/src/component/types_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,18 +325,16 @@ impl ComponentTypesBuilder {
let ty = &types[id];
let mut result = TypeComponent::default();
for (name, ty) in ty.imports.iter() {
self.register_abstract_component_entity_type(types, *ty);
result.imports.insert(
name.clone(),
self.convert_component_entity_type(types, *ty)?,
);
self.register_abstract_component_entity_type(types, ty.ty);
result
.imports
.insert(name.clone(), self.convert_component_entity_type(types, ty.ty)?);
}
for (name, ty) in ty.exports.iter() {
self.register_abstract_component_entity_type(types, *ty);
result.exports.insert(
name.clone(),
self.convert_component_entity_type(types, *ty)?,
);
self.register_abstract_component_entity_type(types, ty.ty);
result
.exports
.insert(name.clone(), self.convert_component_entity_type(types, ty.ty)?);
}
Ok(self.component_types.components.push(result))
}
Expand All @@ -350,11 +348,10 @@ impl ComponentTypesBuilder {
let ty = &types[id];
let mut result = TypeComponentInstance::default();
for (name, ty) in ty.exports.iter() {
self.register_abstract_component_entity_type(types, *ty);
result.exports.insert(
name.clone(),
self.convert_component_entity_type(types, *ty)?,
);
self.register_abstract_component_entity_type(types, ty.ty);
result
.exports
.insert(name.clone(), self.convert_component_entity_type(types, ty.ty)?);
}
Ok(self.component_types.component_instances.push(result))
}
Expand Down
2 changes: 1 addition & 1 deletion crates/environ/src/component/types_builder/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl ResourcesBuilder {
let ty = &types[id];
for (name, ty) in ty.exports.iter() {
path.push(name);
self.register_component_entity_type_(types, *ty, path, register);
self.register_component_entity_type_(types, ty.ty, path, register);
path.pop();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ impl<'a> CodeBuilder<'a> {
// unfortunately the `wasm-compose` API is not powerful
// enough for us to do all that.
ensure!(
imp.name.0 != intrinsics_import,
imp.name.name != intrinsics_import,
"main Wasm cannot import the unsafe intrinsics (`{intrinsics_import}`) \
when using compile-time builtins"
);

if let wasmparser::ComponentTypeRef::Instance(_) = imp.ty {
instance_imports.insert(imp.name.0);
instance_imports.insert(imp.name.name);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/wast/src/spectest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ pub fn link_component_spectest<T>(linker: &mut component::Linker<T>) -> Result<(
let engine = linker.engine().clone();
linker
.root()
.func_wrap("host-echo-u32", |_, v: (u32,)| Ok(v))?;
.func_wrap_concurrent("host-echo-u32", |_, (v,): (u32,)| {
Box::pin(async move { Ok((v,)) })
})?;
linker
.root()
.func_wrap("host-return-two", |_, _: ()| Ok((2u32,)))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/wizer/src/component/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl ReencodeComponent for Reencoder<'_> {
) -> Result<(), Error> {
for export in section {
let export = export?;
if !self.wizer.get_keep_init_func() && export.name.0 == self.wizer.get_init_func() {
if !self.wizer.get_keep_init_func() && export.name.name == self.wizer.get_init_func() {
self.removed_func = Some(self.funcs);
} else {
if export.kind == wasmparser::ComponentExternalKind::Func {
Expand Down
2 changes: 1 addition & 1 deletion tests/all/component_model/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ mod no_imports_concurrent {
(with "" (instance (export "task.return" (func $task-return))))
))

(func $f (export "bar")
(func $f (export "bar") async
(canon lift (core func $i "bar") async (callback (func $i "callback")))
)

Expand Down
4 changes: 2 additions & 2 deletions tests/all/component_model/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ async fn test_many_parameters(dynamic: bool, concurrent: bool) -> Result<()> {
(with "libc" (instance $libc))
))

(type $t (func
(type $t (func async
(param "p1" s8) ;; offset 0, size 1
(param "p2" u64) ;; offset 8, size 8
(param "p3" float32) ;; offset 16, size 4
Expand Down Expand Up @@ -1379,7 +1379,7 @@ async fn test_many_results(dynamic: bool, concurrent: bool) -> Result<()> {
(with "libc" (instance $libc))
))

(type $t (func (result $tuple)))
(type $t (func async (result $tuple)))
(func (export "many-results") (type $t)
(canon lift
(core func $i "foo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
))

(func (export "turn-on-backpressure") (canon lift (core func $i "turn-on-backpressure")))
(func (export "f")
(func (export "f") async
(canon lift (core func $i "f") async (callback (func $i "callback"))))
)
(instance $A (instantiate $A))

(component $B
(import "A" (instance $A
(export "f" (func))
(export "f" (func async))
(export "turn-on-backpressure" (func))
))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
(with "" (instance (export "task.return" (func $task.return))))
))

(func (export "foo") (param "p1" u32) (result u32)
(func (export "foo") async (param "p1" u32) (result u32)
(canon lift (core func $i "foo") async (callback (func $i "callback")))
)
)

(component $B
(import "a" (func $foo (param "p1" u32) (result u32)))
(import "a" (func $foo async (param "p1" u32) (result u32)))
(core func $foo (canon lower (func $foo)))
(core module $m
(import "" "foo" (func $foo (param i32) (result i32)))
Expand All @@ -47,5 +47,5 @@
(func (export "run") (alias export $B "run"))
)

(assert_return (invoke "run"))
(assert_return (invoke "run"))
(assert_trap (invoke "run") "wasm trap: cannot block a synchronous task before returning")
(assert_trap (invoke "run") "wasm trap: cannot enter component instance")
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
(func (export "set-backpressure")
(canon lift (core func $i "set-backpressure")))

(func (export "target")
(func (export "target") async
(canon lift (core func $i "target") async (callback (func $i "callback"))))
)

Expand Down
14 changes: 7 additions & 7 deletions tests/misc_testsuite/component-model/async/fused.wast
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
(with "" (instance (export "task.return" (func $task-return))))
))

(func (export "foo") (param "p1" u32) (result u32)
(func (export "foo") async (param "p1" u32) (result u32)
(canon lift (core func $i "foo") async (callback (func $i "callback")))
)
)

(component $lowerer
(import "a" (func $foo (param "p1" u32) (result u32)))
(import "a" (func $foo async (param "p1" u32) (result u32)))
(core module $libc (memory (export "memory") 1))
(core instance $libc (instantiate $libc))
(core func $foo (canon lower (func $foo) async (memory $libc "memory")))
Expand Down Expand Up @@ -65,13 +65,13 @@
)
)
(core instance $i (instantiate $m))
(func (export "foo") (param "p1" u32) (result u32)
(func (export "foo") async (param "p1" u32) (result u32)
(canon lift (core func $i "foo"))
)
)

(component $lowerer
(import "a" (func $foo (param "p1" u32) (result u32)))
(import "a" (func $foo async (param "p1" u32) (result u32)))
(core module $libc (memory (export "memory") 1))
(core instance $libc (instantiate $libc))
(core func $foo (canon lower (func $foo) async (memory $libc "memory")))
Expand Down Expand Up @@ -117,13 +117,13 @@
(with "" (instance (export "task.return" (func $task-return))))
))

(func (export "foo") (param "p1" u32) (result u32)
(func (export "foo") async (param "p1" u32) (result u32)
(canon lift (core func $i "foo") async (callback (func $i "callback")))
)
)

(component $lowerer
(import "a" (func $foo (param "p1" u32) (result u32)))
(import "a" (func $foo async (param "p1" u32) (result u32)))
(core func $foo (canon lower (func $foo)))
(core module $m
(import "" "foo" (func $foo (param i32) (result i32)))
Expand All @@ -146,4 +146,4 @@
(func (export "run") (alias export $lowerer "run"))
)

(assert_return (invoke "run"))
(assert_trap (invoke "run") "wasm trap: cannot block a synchronous task before returning")
Loading
Loading