Upgrade wasm-tools crates, namely the component model (#4715)
* Upgrade wasm-tools crates, namely the component model This commit pulls in the latest versions of all of the `wasm-tools` family of crates. There were two major changes that happened in `wasm-tools` in the meantime: * bytecodealliance/wasm-tools#697 - this commit introduced a new API for more efficiently reading binary operators from a wasm binary. The old `Operator`-based reading was left in place, however, and continues to be what Wasmtime uses. I hope to update Wasmtime in a future PR to use this new API, but for now the biggest change is... * bytecodealliance/wasm-tools#703 - this commit was a major update to the component model AST. This commit almost entirely deals with the fallout of this change. The changes made to the component model were: 1. The `unit` type no longer exists. This was generally a simple change where the `Unit` case in a few different locations were all removed. 2. The `expected` type was renamed to `result`. This similarly was relatively lightweight and mostly just a renaming on the surface. I took this opportunity to rename `val::Result` to `val::ResultVal` and `types::Result` to `types::ResultType` to avoid clashing with the standard library types. The `Option`-based types were handled with this as well. 3. The payload type of `variant` and `result` types are now optional. This affected many locations that calculate flat type representations, ABI information, etc. The `#[derive(ComponentType)]` macro now specifically handles Rust-defined `enum` types which have no payload to the equivalent in the component model. 4. Functions can now return multiple parameters. This changed the signature of invoking component functions because the return value is now bound by `ComponentNamedList` (renamed from `ComponentParams`). This had a large effect in the tests, fuzz test case generation, etc. 5. Function types with 2-or-more parameters/results must uniquely name all parameters/results. This mostly affected the text format used throughout the tests. I haven't added specifically new tests for multi-return but I changed a number of tests to use it. Additionally I've updated the fuzzers to all exercise multi-return as well so I think we should get some good coverage with that. * Update version numbers * Use crates.io
This commit is contained in:
@@ -121,7 +121,7 @@
|
||||
(memory (export "memory") 0)
|
||||
)
|
||||
(core instance $m (instantiate $m))
|
||||
(func $f (param (list unit))
|
||||
(func $f (param (list (record)))
|
||||
(canon lift
|
||||
(core func $m "x")
|
||||
(realloc (func $m "realloc"))
|
||||
|
||||
@@ -94,10 +94,10 @@
|
||||
(component
|
||||
(type $roundtrip (func
|
||||
;; 20 u32 params
|
||||
(param u32) (param u32) (param u32) (param u32) (param u32)
|
||||
(param u32) (param u32) (param u32) (param u32) (param u32)
|
||||
(param u32) (param u32) (param u32) (param u32) (param u32)
|
||||
(param u32) (param u32) (param u32) (param u32) (param u32)
|
||||
(param "a1" u32) (param "a2" u32) (param "a3" u32) (param "a4" u32) (param "a5" u32)
|
||||
(param "a6" u32) (param "a7" u32) (param "a8" u32) (param "a9" u32) (param "a10" u32)
|
||||
(param "a11" u32) (param "a12" u32) (param "a13" u32) (param "a14" u32) (param "a15" u32)
|
||||
(param "a16" u32) (param "a17" u32) (param "a18" u32) (param "a19" u32) (param "a20" u32)
|
||||
|
||||
;; 10 u32 results
|
||||
(result (tuple u32 u32 u32 u32 u32 u32 u32 u32 u32 u32))
|
||||
@@ -717,8 +717,8 @@
|
||||
|
||||
;; simple variant translation
|
||||
(component
|
||||
(type $a (variant (case "x" unit)))
|
||||
(type $b (variant (case "y" unit)))
|
||||
(type $a (variant (case "x")))
|
||||
(type $b (variant (case "y")))
|
||||
|
||||
(component $c1
|
||||
(core module $m
|
||||
@@ -756,7 +756,7 @@
|
||||
;; invalid variant discriminant in a parameter
|
||||
(assert_trap
|
||||
(component
|
||||
(type $a (variant (case "x" unit)))
|
||||
(type $a (variant (case "x")))
|
||||
|
||||
(component $c1
|
||||
(core module $m
|
||||
@@ -789,7 +789,7 @@
|
||||
;; invalid variant discriminant in a result
|
||||
(assert_trap
|
||||
(component
|
||||
(type $a (variant (case "x" unit)))
|
||||
(type $a (variant (case "x")))
|
||||
|
||||
(component $c1
|
||||
(core module $m
|
||||
@@ -889,6 +889,12 @@
|
||||
(type $d (variant (case "a" float32) (case "b" float64)))
|
||||
(type $e (variant (case "a" float32) (case "b" s64)))
|
||||
|
||||
(type $func_a (func (param "x" bool) (param "a" $a)))
|
||||
(type $func_b (func (param "x" bool) (param "b" $b)))
|
||||
(type $func_c (func (param "x" bool) (param "c" $c)))
|
||||
(type $func_d (func (param "x" bool) (param "d" $d)))
|
||||
(type $func_e (func (param "x" bool) (param "e" $d)))
|
||||
|
||||
(component $c1
|
||||
(core module $m
|
||||
(func (export "a") (param i32 i32 i32)
|
||||
@@ -943,19 +949,19 @@
|
||||
)
|
||||
)
|
||||
(core instance $m (instantiate $m))
|
||||
(func (export "a") (param bool) (param $a) (canon lift (core func $m "a")))
|
||||
(func (export "b") (param bool) (param $b) (canon lift (core func $m "b")))
|
||||
(func (export "c") (param bool) (param $c) (canon lift (core func $m "c")))
|
||||
(func (export "d") (param bool) (param $d) (canon lift (core func $m "d")))
|
||||
(func (export "e") (param bool) (param $e) (canon lift (core func $m "e")))
|
||||
(func (export "a") (type $func_a) (canon lift (core func $m "a")))
|
||||
(func (export "b") (type $func_b) (canon lift (core func $m "b")))
|
||||
(func (export "c") (type $func_c) (canon lift (core func $m "c")))
|
||||
(func (export "d") (type $func_d) (canon lift (core func $m "d")))
|
||||
(func (export "e") (type $func_e) (canon lift (core func $m "e")))
|
||||
)
|
||||
(component $c2
|
||||
(import "" (instance $i
|
||||
(export "a" (func (param bool) (param $a)))
|
||||
(export "b" (func (param bool) (param $b)))
|
||||
(export "c" (func (param bool) (param $c)))
|
||||
(export "d" (func (param bool) (param $d)))
|
||||
(export "e" (func (param bool) (param $e)))
|
||||
(export "a" (func (type $func_a)))
|
||||
(export "b" (func (type $func_b)))
|
||||
(export "c" (func (type $func_c)))
|
||||
(export "d" (func (type $func_d)))
|
||||
(export "e" (func (type $func_e)))
|
||||
))
|
||||
|
||||
(core func $a (canon lower (func $i "a")))
|
||||
@@ -1008,10 +1014,10 @@
|
||||
;; different size variants
|
||||
(component
|
||||
(type $a (variant
|
||||
(case "a" unit)
|
||||
(case "a")
|
||||
(case "b" float32)
|
||||
(case "c" (tuple float32 u32))
|
||||
(case "d" (tuple float32 unit u64 u8))
|
||||
(case "d" (tuple float32 (record) u64 u8))
|
||||
))
|
||||
|
||||
(component $c1
|
||||
@@ -1054,11 +1060,11 @@
|
||||
)
|
||||
)
|
||||
(core instance $m (instantiate $m))
|
||||
(func (export "a") (param u8) (param $a) (canon lift (core func $m "a")))
|
||||
(func (export "a") (param "x" u8) (param "a" $a) (canon lift (core func $m "a")))
|
||||
)
|
||||
(component $c2
|
||||
(import "" (instance $i
|
||||
(export "a" (func (param u8) (param $a)))
|
||||
(export "a" (func (param "x" u8) (param "a" $a)))
|
||||
))
|
||||
|
||||
(core func $a (canon lower (func $i "a")))
|
||||
@@ -1157,9 +1163,9 @@
|
||||
(export "roundtrip" (func $c2 "roundtrip"))
|
||||
)
|
||||
|
||||
(assert_return (invoke "roundtrip" (char.const "x")) (unit.const))
|
||||
(assert_return (invoke "roundtrip" (char.const "⛳")) (unit.const))
|
||||
(assert_return (invoke "roundtrip" (char.const "🍰")) (unit.const))
|
||||
(assert_return (invoke "roundtrip" (char.const "x")))
|
||||
(assert_return (invoke "roundtrip" (char.const "⛳")))
|
||||
(assert_return (invoke "roundtrip" (char.const "🍰")))
|
||||
|
||||
;; invalid chars
|
||||
(assert_trap
|
||||
|
||||
@@ -39,4 +39,4 @@
|
||||
(func (export "") (canon lift (core func $m "")))
|
||||
)
|
||||
|
||||
(assert_return (invoke "") (unit.const))
|
||||
(assert_return (invoke ""))
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
(component
|
||||
(type string)
|
||||
(type (func (param string)))
|
||||
(type $r (record (field "x" unit) (field "y" string)))
|
||||
(type $r (record (field "x" (record)) (field "y" string)))
|
||||
(type $u (union $r string))
|
||||
(type $e (expected $u u32))
|
||||
(type $e (result $u (error u32)))
|
||||
(type (result $u))
|
||||
(type (result (error $u)))
|
||||
(type (result))
|
||||
|
||||
(type (func (param $e) (result (option $r))))
|
||||
|
||||
@@ -21,17 +24,17 @@
|
||||
|
||||
;; primitives in functions
|
||||
(type (func
|
||||
(param bool)
|
||||
(param u8)
|
||||
(param s8)
|
||||
(param u16)
|
||||
(param s16)
|
||||
(param u32)
|
||||
(param s32)
|
||||
(param u64)
|
||||
(param s64)
|
||||
(param char)
|
||||
(param string)
|
||||
(param "a" bool)
|
||||
(param "b" u8)
|
||||
(param "c" s8)
|
||||
(param "d" u16)
|
||||
(param "e" s16)
|
||||
(param "f" u32)
|
||||
(param "g" s32)
|
||||
(param "h" u64)
|
||||
(param "i" s64)
|
||||
(param "j" char)
|
||||
(param "k" string)
|
||||
))
|
||||
|
||||
;; primitives in types
|
||||
|
||||
@@ -110,17 +110,17 @@
|
||||
(assert_return (invoke "64.store64 o1" (i32.const 7)))
|
||||
|
||||
;; misaligned stores
|
||||
(assert_return (invoke "32.store8" (i32.const 1)) (i32.const 0))
|
||||
(assert_return (invoke "32.store8" (i32.const 1)))
|
||||
(assert_trap (invoke "32.store16" (i32.const 1)) "misaligned memory access")
|
||||
(assert_trap (invoke "32.store32" (i32.const 1)) "misaligned memory access")
|
||||
(assert_return (invoke "64.store8" (i32.const 1)) (i64.const 0))
|
||||
(assert_return (invoke "64.store8" (i32.const 1)))
|
||||
(assert_trap (invoke "64.store16" (i32.const 1)) "misaligned memory access")
|
||||
(assert_trap (invoke "64.store32" (i32.const 1)) "misaligned memory access")
|
||||
(assert_trap (invoke "64.store64" (i32.const 1)) "misaligned memory access")
|
||||
(assert_return (invoke "32.store8 o1" (i32.const 0)) (i32.const 0))
|
||||
(assert_return (invoke "32.store8 o1" (i32.const 0)))
|
||||
(assert_trap (invoke "32.store16 o1" (i32.const 0)) "misaligned memory access")
|
||||
(assert_trap (invoke "32.store32 o1" (i32.const 0)) "misaligned memory access")
|
||||
(assert_return (invoke "64.store8 o1" (i32.const 0)) (i64.const 0))
|
||||
(assert_return (invoke "64.store8 o1" (i32.const 0)))
|
||||
(assert_trap (invoke "64.store16 o1" (i32.const 0)) "misaligned memory access")
|
||||
(assert_trap (invoke "64.store32 o1" (i32.const 0)) "misaligned memory access")
|
||||
(assert_trap (invoke "64.store64 o1" (i32.const 0)) "misaligned memory access")
|
||||
|
||||
Reference in New Issue
Block a user