Update the wasm-tools family of crates (#5310)

Most of the changes here are the updates to the component model which
includes optional URL fields in imports/exports.
This commit is contained in:
Alex Crichton
2022-11-21 15:37:16 -06:00
committed by GitHub
parent c74706aa59
commit b305f251fb
21 changed files with 331 additions and 127 deletions

101
Cargo.lock generated
View File

@@ -1259,6 +1259,15 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "form_urlencoded"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8"
dependencies = [
"percent-encoding",
]
[[package]]
name = "fs-set-times"
version = "0.17.0"
@@ -1439,6 +1448,16 @@ version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
[[package]]
name = "idna"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6"
dependencies = [
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "indexmap"
version = "1.9.1"
@@ -2046,6 +2065,12 @@ dependencies = [
"base64ct",
]
[[package]]
name = "percent-encoding"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "pin-project-lite"
version = "0.2.9"
@@ -2916,6 +2941,21 @@ dependencies = [
"serde_json",
]
[[package]]
name = "tinyvec"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.18.1"
@@ -3005,6 +3045,12 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-bidi"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]]
name = "unicode-linebreak"
version = "0.1.2"
@@ -3014,6 +3060,15 @@ dependencies = [
"regex",
]
[[package]]
name = "unicode-normalization"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-width"
version = "0.1.9"
@@ -3036,6 +3091,17 @@ dependencies = [
"subtle",
]
[[package]]
name = "url"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643"
dependencies = [
"form_urlencoded",
"idna",
"percent-encoding",
]
[[package]]
name = "uuid"
version = "1.0.0"
@@ -3250,18 +3316,18 @@ checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
[[package]]
name = "wasm-encoder"
version = "0.19.1"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9424cdab516a16d4ea03c8f4a01b14e7b2d04a129dcc2bcdde5bcc5f68f06c41"
checksum = "05632e0a66a6ed8cca593c24223aabd6262f256c3693ad9822c315285f010614"
dependencies = [
"leb128",
]
[[package]]
name = "wasm-mutate"
version = "0.2.11"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b48cf16265251b7e11c57686ea068a77c87a67aada5cff4ee8dd50382820f01b"
checksum = "3a3f74c801ac9b17a797d7d2ea441277bc1ded7ba521ca5146258d6510cc2f11"
dependencies = [
"egg",
"log",
@@ -3273,9 +3339,9 @@ dependencies = [
[[package]]
name = "wasm-smith"
version = "0.11.8"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f351bb8188460a311bceb4e2fd7423e09ba5c4a16fc03f3b258f454c4d706881"
checksum = "ca488f460a34d3af30f1d65f26f108612f2755872f2aba9906c36f1c046ef1cf"
dependencies = [
"arbitrary",
"flagset",
@@ -3325,11 +3391,12 @@ dependencies = [
[[package]]
name = "wasmparser"
version = "0.94.0"
version = "0.95.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdac7e1d98d70913ae3b4923dd7419c8ea7bdfd4c44a240a0ba305d929b7f191"
checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a"
dependencies = [
"indexmap",
"url",
]
[[package]]
@@ -3343,9 +3410,9 @@ dependencies = [
[[package]]
name = "wasmprinter"
version = "0.2.43"
version = "0.2.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c093ddb9e6526cc59d93032b9be7a8d014cc997e8a9372f394c9624f820d209"
checksum = "ae24500f9cc27a4b2b338e66693ff53c08b17cf920bdc81e402a09fe7a204eea"
dependencies = [
"anyhow",
"wasmparser",
@@ -3493,7 +3560,7 @@ dependencies = [
"wasmtime-wasi-crypto",
"wasmtime-wasi-nn",
"wasmtime-wast",
"wast 49.0.0",
"wast 50.0.0",
"wat",
"windows-sys",
]
@@ -3763,7 +3830,7 @@ dependencies = [
"anyhow",
"log",
"wasmtime",
"wast 49.0.0",
"wast 50.0.0",
]
[[package]]
@@ -3788,9 +3855,9 @@ dependencies = [
[[package]]
name = "wast"
version = "49.0.0"
version = "50.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05ef81fcd60d244cafffeafac3d17615fdb2fddda6aca18f34a8ae233353587c"
checksum = "a2cbb59d4ac799842791fe7e806fa5dbbf6b5554d538e51cc8e176db6ff0ae34"
dependencies = [
"leb128",
"memchr",
@@ -3800,11 +3867,11 @@ dependencies = [
[[package]]
name = "wat"
version = "1.0.51"
version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c347c4460ffb311e95aafccd8c29e4888f241b9e4b3bb0e0ccbd998de2c8c0d"
checksum = "584aaf7a1ecf4d383bbe1a25eeab0cbb8ff96acc6796707ff65cde48f4632f15"
dependencies = [
"wast 49.0.0",
"wast 50.0.0",
]
[[package]]

View File

@@ -155,13 +155,13 @@ winch-codegen = { path = "winch/codegen", version = "=0.2.0" }
target-lexicon = { version = "0.12.3", default-features = false }
anyhow = "1.0.22"
wasmparser = "0.94.0"
wat = "1.0.51"
wast = "49.0.0"
wasmprinter = "0.2.43"
wasm-encoder = "0.19.1"
wasm-smith = "0.11.8"
wasm-mutate = "0.2.11"
wasmparser = "0.95.0"
wat = "1.0.52"
wast = "50.0.0"
wasmprinter = "0.2.44"
wasm-encoder = "0.20.0"
wasm-smith = "0.11.9"
wasm-mutate = "0.2.12"
windows-sys = "0.36.0"
env_logger = "0.9"
rustix = "0.35.10"

View File

@@ -840,14 +840,16 @@ impl<'a, 'data> Translator<'a, 'data> {
// An imported component instance is being aliased, so the type of
// the aliased item is directly available from the instance type.
ComponentInstanceType::Index(ty) => {
self.result.push_typedef(self.types[ty].exports[name])
let (_url, ty) = &self.types[ty].exports[name];
self.result.push_typedef(*ty);
}
// An imported component was instantiated so the type of the aliased
// export is available through the type of the export on the
// original component.
ComponentInstanceType::InstantiatedIndex(ty) => {
self.result.push_typedef(self.types[ty].exports[name])
let (_, ty) = self.types[ty].exports[name];
self.result.push_typedef(ty);
}
// A static nested component was instantiated which means that the

View File

@@ -668,7 +668,7 @@ impl<'a> Inliner<'a> {
ComponentInstanceDef::Import(path, ty) => {
let mut path = path.clone();
path.path.push(name);
match self.types[*ty].exports[*name] {
match self.types[*ty].exports[*name].1 {
TypeDef::ComponentFunc(_) => {
frame.component_funcs.push(ComponentFuncDef::Import(path));
}
@@ -909,7 +909,7 @@ impl<'a> Inliner<'a> {
// Note that for now this would only work with
// module-exporting instances.
ComponentInstanceDef::Import(path, ty) => {
for (name, ty) in self.types[ty].exports.iter() {
for (name, (_url, ty)) in self.types[ty].exports.iter() {
let mut path = path.clone();
path.path.push(name);
let def = ComponentItemDef::from_import(path, *ty)?;

View File

@@ -553,13 +553,17 @@ impl ComponentTypesBuilder {
ComponentTypeDeclaration::Type(ty) => self.type_declaration_type(ty)?,
ComponentTypeDeclaration::CoreType(ty) => self.type_declaration_core_type(ty)?,
ComponentTypeDeclaration::Alias(alias) => self.type_declaration_alias(alias)?,
ComponentTypeDeclaration::Export { name, ty } => {
ComponentTypeDeclaration::Export { name, url, ty } => {
let ty = self.component_type_ref(ty);
result.exports.insert(name.to_string(), ty);
result
.exports
.insert(name.to_string(), (url.to_string(), ty));
}
ComponentTypeDeclaration::Import(import) => {
let ty = self.component_type_ref(&import.ty);
result.imports.insert(import.name.to_string(), ty);
result
.imports
.insert(import.name.to_string(), (import.url.to_string(), ty));
}
}
}
@@ -581,9 +585,11 @@ impl ComponentTypesBuilder {
InstanceTypeDeclaration::Type(ty) => self.type_declaration_type(ty)?,
InstanceTypeDeclaration::CoreType(ty) => self.type_declaration_core_type(ty)?,
InstanceTypeDeclaration::Alias(alias) => self.type_declaration_alias(alias)?,
InstanceTypeDeclaration::Export { name, ty } => {
InstanceTypeDeclaration::Export { name, url, ty } => {
let ty = self.component_type_ref(ty);
result.exports.insert(name.to_string(), ty);
result
.exports
.insert(name.to_string(), (url.to_string(), ty));
}
}
}
@@ -971,9 +977,9 @@ pub struct TypeModule {
#[derive(Serialize, Deserialize, Default)]
pub struct TypeComponent {
/// The named values that this component imports.
pub imports: IndexMap<String, TypeDef>,
pub imports: IndexMap<String, (String, TypeDef)>,
/// The named values that this component exports.
pub exports: IndexMap<String, TypeDef>,
pub exports: IndexMap<String, (String, TypeDef)>,
}
/// The type of a component instance in the component model, or an instantiated
@@ -983,7 +989,7 @@ pub struct TypeComponent {
#[derive(Serialize, Deserialize, Default)]
pub struct TypeComponentInstance {
/// The list of exports that this component has along with their types.
pub exports: IndexMap<String, TypeDef>,
pub exports: IndexMap<String, (String, TypeDef)>,
}
/// A component function type in the component model.

View File

@@ -71,7 +71,7 @@ impl TypeChecker<'_> {
// Like modules, every export in the expected type must be present in
// the actual type. It's ok, though, to have extra exports in the actual
// type.
for (name, expected) in expected.exports.iter() {
for (name, (_url, expected)) in expected.exports.iter() {
// Interface types may be exported from a component in order to give them a name, but
// they don't have a definition in the sense that this search is interested in, so
// ignore them.

View File

@@ -175,6 +175,16 @@ are only created when requested by the application, however, and otherwise
only does its stated purpose.
"""
[[audits.form_urlencoded]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "1.1.0"
notes = """
This is a small crate for working with url-encoded forms which doesn't have any
more than what it says on the tin. Contains one `unsafe` block related to
performance around utf-8 validation which is fairly easy to verify as correct.
"""
[[audits.heck]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -187,6 +197,17 @@ criteria = "safe-to-deploy"
version = "2.2.1"
notes = "I am the author of this crate."
[[audits.idna]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.3.0"
notes = """
This is a crate without unsafe code or usage of the standard library. The large
size of this crate comes from the large generated unicode tables file. This
crate is broadly used throughout the ecosystem and does not contain anything
suspicious.
"""
[[audits.indexmap-nostd]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
@@ -280,6 +301,16 @@ criteria = "safe-to-deploy"
version = "1.0.0"
notes = "I am the author of this crate."
[[audits.percent-encoding]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "2.2.0"
notes = """
This crate is a single-file crate that does what it says on the tin. There are
a few `unsafe` blocks related to utf-8 validation which are locally verifiable
as correct and otherwise this crate is good to go.
"""
[[audits.regalloc2]]
who = "Jamey Sharp <jsharp@fastly.com>"
criteria = "safe-to-deploy"
@@ -334,6 +365,60 @@ criteria = "safe-to-deploy"
version = "0.23.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.tinyvec]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "1.6.0"
notes = """
This crate, while it implements collections, does so without `std::*` APIs and
without `unsafe`. Skimming the crate everything looks reasonable and what one
would expect from idiomatic safe collections in Rust.
"""
[[audits.tinyvec_macros]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.1.0"
notes = """
This is a trivial crate which only contains a singular macro definition which is
intended to multiplex across the internal representation of a tinyvec,
presumably. This trivially doesn't contain anything bad.
"""
[[audits.unicode-bidi]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.3.8"
notes = """
This crate has no unsafe code and does not use `std::*`. Skimming the crate it
does not attempt to out of the bounds of what it's already supposed to be doing.
"""
[[audits.unicode-normalization]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.1.19"
notes = """
This crate contains one usage of `unsafe` which I have manually checked to see
it as correct. This crate's size comes in large part due to the generated
unicode tables that it contains. This crate is additionally widely used
throughout the ecosystem and skimming the crate shows no usage of `std::*` APIs
and nothing suspicious.
"""
[[audits.url]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "2.3.1"
notes = """
This crate contains no `unsafe` code and otherwise doesn't use any functionality
it's not supposed to from `std` or such. This crate is the defacto standard for
URL parsing in the Rust community with widespread usage to battle-test, harden,
and suss out bugs. I've historically reviewed this crate in the past and it
is similar to what it once was back then. Skimming over the crate there is
nothing suspicious and it's everything you'd expect a Rust URL parser to be.
"""
[[audits.wasm-encoder]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -370,6 +455,12 @@ criteria = "safe-to-deploy"
version = "0.19.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-encoder]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.20.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-encoder]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -418,6 +509,12 @@ criteria = "safe-to-run"
version = "0.2.11"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-mutate]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
version = "0.2.12"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-smith]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -460,6 +557,27 @@ criteria = "safe-to-run"
version = "0.11.8"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasm-smith]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
version = "0.11.9"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmi]]
who = "Robin Freyler <robin.freyler@gmail.com>"
criteria = "safe-to-run"
version = "0.20.0"
notes = """
I am the author of this crate. It contains unsafe Rust code.
However, the crate does not read or write data from any parts of the filesystem,
it does not install software upon compilation e.g. via build scripts,
it does not connect to network endpoints and does not misuse system resources.
If any of the above happens it is either by the user explicitly telling the
crate to do so (it is an interpreter) or due to a bug or other unintended
behavior.
"""
[[audits.wasmi_arena]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
@@ -487,21 +605,6 @@ criteria = "safe-to-run"
version = "0.5.0"
notes = "See notes for version 0.4.0"
[[audits.wasmi]]
who = "Robin Freyler <robin.freyler@gmail.com>"
criteria = "safe-to-run"
version = "0.20.0"
notes = """
I am the author of this crate. It contains unsafe Rust code.
However, the crate does not read or write data from any parts of the filesystem,
it does not install software upon compilation e.g. via build scripts,
it does not connect to network endpoints and does not misuse system resources.
If any of the above happens it is either by the user explicitly telling the
crate to do so (it is an interpreter) or due to a bug or other unintended
behavior.
"""
[[audits.wasmparser]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -550,6 +653,12 @@ criteria = "safe-to-deploy"
version = "0.94.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmparser]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.95.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmparser-nostd]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-run"
@@ -603,6 +712,12 @@ criteria = "safe-to-deploy"
version = "0.2.43"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wasmprinter]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.2.44"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wast]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -651,6 +766,12 @@ criteria = "safe-to-deploy"
version = "49.0.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wast]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "50.0.0"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -681,6 +802,12 @@ criteria = "safe-to-deploy"
version = "1.0.51"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "1.0.52"
notes = "The Bytecode Alliance is the author of this crate."
[[audits.wat]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"

View File

@@ -482,10 +482,6 @@ criteria = "safe-to-deploy"
version = "0.6.5"
criteria = "safe-to-deploy"
[[exemptions.memory_units]]
version = "0.3.0"
criteria = "safe-to-run"
[[exemptions.miette]]
version = "5.1.0"
criteria = "safe-to-deploy"
@@ -1022,10 +1018,6 @@ criteria = "safe-to-run"
version = "0.2.80"
criteria = "safe-to-run"
[[exemptions.wasmi]]
version = "0.19.0"
criteria = "safe-to-run"
[[exemptions.web-sys]]
version = "0.3.57"
criteria = "safe-to-run"

View File

@@ -353,6 +353,17 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-run"
delta = "0.1.27 -> 0.1.29"
[[audits.mozilla.audits.unicode-normalization]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.1.19 -> 0.1.20"
notes = "I am the author of most of these changes upstream, and prepared the release myself, at which point I looked at the other changes since 0.1.19."
[[audits.mozilla.audits.unicode-normalization]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.1.20 -> 0.1.21"
[[audits.mozilla.audits.wasm-encoder]]
who = "Ryan Hunt <rhunt@eqrion.net>"
criteria = "safe-to-deploy"
@@ -396,7 +407,6 @@ delta = "0.87.0 -> 0.88.0"
who = "Ryan Hunt <rhunt@eqrion.net>"
criteria = "safe-to-deploy"
version = "44.0.0"
notes = "Maintained by the Bytecode Alliance, with contributions from Mozilla. wast has no unsafe code and the only ambient capability it uses is to read the full contents of a file that is given to it."
[[audits.mozilla.audits.wast]]
who = "Yury Delendik <ydelendik@mozilla.com>"

View File

@@ -27,7 +27,7 @@ fn components_importing_modules() -> Result<()> {
&engine,
r#"
(component
(import "" (core module))
(import "a" (core module))
)
"#,
)?;
@@ -36,7 +36,7 @@ fn components_importing_modules() -> Result<()> {
&engine,
r#"
(component
(import "" (core module $m1
(import "a" (core module $m1
(import "" "" (func))
(import "" "x" (global i32))

View File

@@ -88,12 +88,12 @@ fn cannot_serialize_exported_module() -> Result<()> {
&engine,
r#"(component
(core module $m)
(export "" (core module $m))
(export "a" (core module $m))
)"#,
)?;
let mut store = Store::new(&engine, ());
let instance = Linker::new(&engine).instantiate(&mut store, &component)?;
let module = instance.get_module(&mut store, "").unwrap();
let module = instance.get_module(&mut store, "a").unwrap();
assert!(module.serialize().is_err());
Ok(())
}

View File

@@ -400,7 +400,7 @@ fn everything() -> Result<()> {
r#"
(record
(field "A" u32)
(field "B" (enum "1" "2"))
(field "B" (enum "a" "b"))
(field "C" (record (field "D" bool) (field "E" u32)))
(field "F" (list (flags "G" "H" "I")))
(field "J" (variant
@@ -464,7 +464,7 @@ fn everything() -> Result<()> {
let f_element_type = &f_type.unwrap_list().ty();
let input = ty.unwrap_record().new_val([
("A", Val::U32(32343)),
("B", b_type.unwrap_enum().new_val("2")?),
("B", b_type.unwrap_enum().new_val("b")?),
(
"C",
c_type

View File

@@ -2411,7 +2411,7 @@ fn run_export_with_internal_adapter() -> Result<()> {
(func (export "add-five") (type $t) (canon lift (core func $m "add-five")))
)
(component $b
(import "interface-0.1.0" (instance $i
(import "interface-v1" (instance $i
(export "add-five" (func (type $t)))))
(core module $m
(func $add-five (import "interface-0.1.0" "add-five") (param i32) (result i32))
@@ -2428,7 +2428,7 @@ fn run_export_with_internal_adapter() -> Result<()> {
(export "run" (func 1))
)
(instance $a (instantiate $a))
(instance $b (instantiate $b (with "interface-0.1.0" (instance $a))))
(instance $b (instantiate $b (with "interface-v1" (instance $a))))
(export "run" (func $b "run"))
)
"#;

View File

@@ -18,7 +18,7 @@ fn can_compile() -> Result<()> {
Component::new(
&engine,
r#"(component
(import "" (func $f))
(import "a" (func $f))
(core func (canon lower (func $f)))
)"#,
)?;
@@ -26,7 +26,7 @@ fn can_compile() -> Result<()> {
&engine,
format!(
r#"(component
(import "" (func $f (param "a" string)))
(import "a" (func $f (param "a" string)))
{libc}
(core func (canon lower (func $f) (memory $libc "memory") (realloc (func $libc "realloc"))))
)"#
@@ -84,7 +84,7 @@ fn can_compile() -> Result<()> {
fn simple() -> Result<()> {
let component = r#"
(component
(import "" (func $log (param "a" string)))
(import "a" (func $log (param "a" string)))
(core module $libc
(memory (export "memory") 1)
@@ -126,7 +126,7 @@ fn simple() -> Result<()> {
let mut linker = Linker::new(&engine);
linker.root().func_wrap(
"",
"a",
|mut store: StoreContextMut<'_, Option<String>>, (arg,): (WasmStr,)| -> Result<_> {
let s = arg.to_str(&store)?.to_string();
assert!(store.data().is_none());
@@ -146,7 +146,7 @@ fn simple() -> Result<()> {
let mut linker = Linker::new(&engine);
linker.root().func_new(
&component,
"",
"a",
|mut store: StoreContextMut<'_, Option<String>>, args, _results| {
if let Val::String(s) = &args[0] {
assert!(store.data().is_none());

View File

@@ -214,14 +214,14 @@ fn test_ptr_out_of_bounds(engine: &Engine, src: &str, dst: &str) -> Result<()> {
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param "a" string)
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding={dst})
)
)
(component $c2
(import "" (func $f (param "a" string)))
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -237,7 +237,7 @@ fn test_ptr_out_of_bounds(engine: &Engine, src: &str, dst: &str) -> Result<()> {
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "" (func $c ""))))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
)
"#
);
@@ -282,14 +282,14 @@ fn test_ptr_overflow(engine: &Engine, src: &str, dst: &str) -> Result<()> {
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param "a" string)
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding={dst})
)
)
(component $c2
(import "" (func $f (param "a" string)))
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -305,7 +305,7 @@ fn test_ptr_overflow(engine: &Engine, src: &str, dst: &str) -> Result<()> {
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "" (func $c ""))))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
(export "f" (func $c2 "f"))
)
"#
@@ -387,14 +387,14 @@ fn test_realloc_oob(engine: &Engine, src: &str, dst: &str) -> Result<()> {
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param "a" string)
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding={dst})
)
)
(component $c2
(import "" (func $f (param "a" string)))
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -410,7 +410,7 @@ fn test_realloc_oob(engine: &Engine, src: &str, dst: &str) -> Result<()> {
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "" (func $c ""))))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
(export "f" (func $c2 "f"))
)
"#
@@ -534,14 +534,14 @@ fn test_raw_when_encoded(
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param "a" string)
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding={dst})
)
)
(component $c2
(import "" (func $f (param "a" string)))
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
(func (export "realloc") (param i32 i32 i32 i32) (result i32) i32.const 0)
@@ -560,7 +560,7 @@ fn test_raw_when_encoded(
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "" (func $c ""))))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
(export "f" (func $c2 "f"))
)
"#

View File

@@ -7,7 +7,7 @@
(func $foo (canon lift (core func $m "")))
(component $c
(import "" (func $foo))
(import "a" (func $foo))
(core func $foo (canon lower (func $foo)))
(core module $m2
@@ -17,7 +17,7 @@
(core instance $m2 (instantiate $m2 (with "" (instance (export "" (func $foo))))))
)
(instance $c (instantiate $c (with "" (func $foo))))
(instance $c (instantiate $c (with "a" (func $foo))))
)
;; boolean parameters
@@ -835,7 +835,7 @@
(func (export "s16") (param "a" s16) (canon lift (core func $m "s")))
)
(component $c2
(import "" (instance $i
(import "a" (instance $i
(export "u8" (func (param "a" u8)))
(export "s8" (func (param "a" s8)))
(export "u16" (func (param "a" u16)))
@@ -878,7 +878,7 @@
))
)
(instance $c1 (instantiate $c1))
(instance $c2 (instantiate $c2 (with "" (instance $c1))))
(instance $c2 (instantiate $c2 (with "a" (instance $c1))))
)
;; translation of locals between different types
@@ -956,7 +956,7 @@
(func (export "e") (type $func_e) (canon lift (core func $m "e")))
)
(component $c2
(import "" (instance $i
(import "a" (instance $i
(export "a" (func (type $func_a)))
(export "b" (func (type $func_b)))
(export "c" (func (type $func_c)))
@@ -1008,7 +1008,7 @@
))
)
(instance $c1 (instantiate $c1))
(instance $c2 (instantiate $c2 (with "" (instance $c1))))
(instance $c2 (instantiate $c2 (with "a" (instance $c1))))
)
;; different size variants
@@ -1063,7 +1063,7 @@
(func (export "a") (param "x" u8) (param "a" $a) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i
(import "a" (instance $i
(export "a" (func (param "x" u8) (param "a" $a)))
))
@@ -1111,7 +1111,7 @@
))
)
(instance $c1 (instantiate $c1))
(instance $c2 (instantiate $c2 (with "" (instance $c1))))
(instance $c2 (instantiate $c2 (with "a" (instance $c1))))
)
;; roundtrip some valid chars
@@ -1124,7 +1124,7 @@
(func (export "a") (param "a" char) (result char) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i
(import "a" (instance $i
(export "a" (func (param "a" char) (result char)))
))
@@ -1158,7 +1158,7 @@
(func (export "roundtrip") (param "a" char) (canon lift (core func $m "roundtrip")))
)
(instance $c1 (instantiate $c1))
(instance $c2 (instantiate $c2 (with "" (instance $c1))))
(instance $c2 (instantiate $c2 (with "a" (instance $c1))))
(export "roundtrip" (func $c2 "roundtrip"))
)
@@ -1176,7 +1176,7 @@
(func (export "a") (param "a" char) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i (export "a" (func (param "a" char)))))
(import "a" (instance $i (export "a" (func (param "a" char)))))
(core func $a (canon lower (func $i "a")))
(core module $m
(import "" "a" (func $a (param i32)))
@@ -1186,7 +1186,7 @@
(core instance (instantiate $m (with "" (instance (export "a" (func $a))))))
)
(instance $c1 (instantiate $c1))
(instance $c2 (instantiate $c2 (with "" (instance $c1))))
(instance $c2 (instantiate $c2 (with "a" (instance $c1))))
)
"unreachable")
(assert_trap
@@ -1197,7 +1197,7 @@
(func (export "a") (param "a" char) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i (export "a" (func (param "a" char)))))
(import "a" (instance $i (export "a" (func (param "a" char)))))
(core func $a (canon lower (func $i "a")))
(core module $m
(import "" "a" (func $a (param i32)))
@@ -1207,7 +1207,7 @@
(core instance (instantiate $m (with "" (instance (export "a" (func $a))))))
)
(instance $c1 (instantiate $c1))
(instance $c2 (instantiate $c2 (with "" (instance $c1))))
(instance $c2 (instantiate $c2 (with "a" (instance $c1))))
)
"unreachable")
(assert_trap
@@ -1218,7 +1218,7 @@
(func (export "a") (param "a" char) (canon lift (core func $m "a")))
)
(component $c2
(import "" (instance $i (export "a" (func (param "a" char)))))
(import "a" (instance $i (export "a" (func (param "a" char)))))
(core func $a (canon lower (func $i "a")))
(core module $m
(import "" "a" (func $a (param i32)))
@@ -1228,7 +1228,7 @@
(core instance (instantiate $m (with "" (instance (export "a" (func $a))))))
)
(instance $c1 (instantiate $c1))
(instance $c2 (instantiate $c2 (with "" (instance $c1))))
(instance $c2 (instantiate $c2 (with "a" (instance $c1))))
)
"unreachable")
@@ -1332,7 +1332,7 @@
(instance $c1 (instantiate $c1))
(component $c2
(import "" (instance $i
(import "a" (instance $i
(export "f0" (func (param "a" $f0)))
(export "f1" (func (param "a" $f1)))
(export "f8" (func (param "a" $f8)))
@@ -1397,7 +1397,7 @@
))
))
)
(instance (instantiate $c2 (with "" (instance $c1))))
(instance (instantiate $c2 (with "a" (instance $c1))))
)
;; Adapters are used slightly out-of-order here to stress the internals of

View File

@@ -70,7 +70,7 @@
;; Test to see if a component with a type export can be instantiated.
(component
(type string)
(export "" (type 0))
(export "a" (type 0))
)
;; double-check the start function runs by ensuring that a trap shows up and it

View File

@@ -330,8 +330,8 @@
)
(component $c1
(component $c2 (export "")
(component $c3 (export "")
(component $c2 (export "a")
(component $c3 (export "a")
(alias outer $C $m (core module $my_module))
(alias outer $C $c (component $my_component))
@@ -342,8 +342,8 @@
)
(instance $i1 (instantiate $c1))
(instance $i2 (instantiate (component $i1 "")))
(instance $i3 (instantiate (component $i2 "")))
(instance $i2 (instantiate (component $i1 "a")))
(instance $i3 (instantiate (component $i2 "a")))
(core instance $m1 (instantiate (module $i3 "m")))
(instance $c (instantiate (component $i3 "c")))
@@ -412,10 +412,10 @@
;; thread the host function through an instance
(component $c
(import "" (func $f (result u32)))
(import "a" (func $f (result u32)))
(export "f" (func $f))
)
(instance $c (instantiate $c (with "" (func $import))))
(instance $c (instantiate $c (with "a" (func $import))))
(alias export $c "f" (func $import2))
;; thread the host function into a nested component

View File

@@ -23,20 +23,20 @@
(assert_invalid
(component
(import "" (component))
(import "a" (component))
)
"root-level component imports are not supported")
(assert_invalid
(component
(component (export ""))
(component (export "a"))
)
"exporting a component from the root component is not supported")
(component
(core module $m (func (export "")))
(core instance $m (instantiate $m))
(func (export "") (canon lift (core func $m "")))
(func (export "a") (canon lift (core func $m "")))
)
(assert_return (invoke ""))
(assert_return (invoke "a"))

View File

@@ -8,13 +8,13 @@
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param "a" string)
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory"))
)
)
(component $c2
(import "" (func $f (param "a" string)))
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -30,7 +30,7 @@
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "" (func $c ""))))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
)
"unreachable")
@@ -44,13 +44,13 @@
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param "a" string)
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory"))
)
)
(component $c2
(import "" (func $f (param "a" string)))
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -66,7 +66,7 @@
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "" (func $c ""))))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
)
"unreachable")
@@ -80,14 +80,14 @@
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "") (param "a" string)
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding=utf8)
)
)
(component $c2
(import "" (func $f (param "a" string)))
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
@@ -103,6 +103,6 @@
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "" (func $c ""))))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
)
"unreachable")

View File

@@ -60,7 +60,7 @@
(type (instance))
(type (component
(import "" (func (type $empty)))
(import "x" (func (type $empty)))
(import "y" (func))
(import "z" (component))
@@ -71,7 +71,7 @@
))
(type (instance
(export "" (func (type $empty)))
(export "x" (func (type $empty)))
(export "y" (func))
(export "z" (component))
@@ -97,7 +97,7 @@
(component $C2
(alias outer $C $f (core type $my_f))
(import "" (core module (type $m)))
(import "a" (core module (type $m)))
(import "x" (core module
(alias outer $C2 $my_f (type $my_f))
(import "" "1" (func (type $my_f)))