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

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"))
)
"#