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:
@@ -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))
|
||||
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"))
|
||||
)
|
||||
"#;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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"))
|
||||
)
|
||||
"#
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user