Update wasm-tools crates (#4246)
This commit updates the wasm-tools family of crates, notably pulling in the refactorings and updates from bytecodealliance/wasm-tools#621 for the latest iteration of the component model. This commit additionally updates all support for the component model for these changes, notably: * Many bits and pieces of type information was refactored. Many `FooTypeIndex` namings are now `TypeFooIndex`. Additionally there is now `TypeIndex` as well as `ComponentTypeIndex` for the two type index spaces in a component. * A number of new sections are now processed to handle the core and component variants. * Internal maps were split such as the `funcs` map into `component_funcs` and `funcs` (same for `instances`). * Canonical options are now processed individually instead of one bulk `into` definition. Overall this was not a major update to the internals of handling the component model in Wasmtime. Instead this was mostly a surface-level refactoring to make sure that everything lines up with the new binary format for components. * All text syntax used in tests was updated to the new syntax.
This commit is contained in:
@@ -8,7 +8,7 @@ mod import;
|
||||
// A simple bump allocator which can be used with modules
|
||||
const REALLOC_AND_FREE: &str = r#"
|
||||
(global $last (mut i32) (i32.const 8))
|
||||
(func $realloc (export "canonical_abi_realloc")
|
||||
(func $realloc (export "realloc")
|
||||
(param $old_ptr i32)
|
||||
(param $old_size i32)
|
||||
(param $align i32)
|
||||
@@ -62,8 +62,6 @@ const REALLOC_AND_FREE: &str = r#"
|
||||
(global.get $last)
|
||||
(local.get $new_size)))
|
||||
)
|
||||
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32))
|
||||
"#;
|
||||
|
||||
fn engine() -> Engine {
|
||||
@@ -83,7 +81,7 @@ fn components_importing_modules() -> Result<()> {
|
||||
&engine,
|
||||
r#"
|
||||
(component
|
||||
(import "" (module))
|
||||
(import "" (core module))
|
||||
)
|
||||
"#,
|
||||
)?;
|
||||
@@ -92,7 +90,7 @@ fn components_importing_modules() -> Result<()> {
|
||||
&engine,
|
||||
r#"
|
||||
(component
|
||||
(import "" (module $m1
|
||||
(import "" (core module $m1
|
||||
(import "" "" (func))
|
||||
(import "" "x" (global i32))
|
||||
|
||||
@@ -102,21 +100,21 @@ fn components_importing_modules() -> Result<()> {
|
||||
(export "d" (global i64))
|
||||
))
|
||||
|
||||
(module $m2
|
||||
(core module $m2
|
||||
(func (export ""))
|
||||
(global (export "x") i32 i32.const 0)
|
||||
)
|
||||
(instance $i2 (instantiate (module $m2)))
|
||||
(instance $i1 (instantiate (module $m1) (with "" (instance $i2))))
|
||||
(core instance $i2 (instantiate (module $m2)))
|
||||
(core instance $i1 (instantiate (module $m1) (with "" (instance $i2))))
|
||||
|
||||
(module $m3
|
||||
(core module $m3
|
||||
(import "mod" "1" (memory 1))
|
||||
(import "mod" "2" (table 1 funcref))
|
||||
(import "mod" "3" (global i64))
|
||||
(import "mod" "4" (func (result f32)))
|
||||
)
|
||||
|
||||
(instance $i3 (instantiate (module $m3)
|
||||
(core instance $i3 (instantiate (module $m3)
|
||||
(with "mod" (instance
|
||||
(export "1" (memory $i1 "b"))
|
||||
(export "2" (table $i1 "a"))
|
||||
|
||||
@@ -12,16 +12,16 @@ const CANON_64BIT_NAN: u64 = 0b0111111111111000000000000000000000000000000000000
|
||||
fn thunks() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "thunk"))
|
||||
(func (export "thunk-trap") unreachable)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
(func (export "thunk")
|
||||
(canon.lift (func) (func $i "thunk"))
|
||||
(canon lift (core func $i "thunk"))
|
||||
)
|
||||
(func (export "thunk-trap")
|
||||
(canon.lift (func) (func $i "thunk-trap"))
|
||||
(canon lift (core func $i "thunk-trap"))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -46,42 +46,40 @@ fn thunks() -> Result<()> {
|
||||
fn typecheck() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "thunk"))
|
||||
(func (export "take-string") (param i32 i32))
|
||||
(func (export "two-args") (param i32 i32 i32))
|
||||
(func (export "ret-one") (result i32) unreachable)
|
||||
|
||||
(memory (export "memory") 1)
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate (module $m)))
|
||||
(func (export "thunk")
|
||||
(canon.lift (func) (func $i "thunk"))
|
||||
(canon lift (core func $i "thunk"))
|
||||
)
|
||||
(func (export "tuple-thunk")
|
||||
(canon.lift (func (param (tuple)) (result (tuple))) (func $i "thunk"))
|
||||
(func (export "tuple-thunk") (param (tuple)) (result (tuple))
|
||||
(canon lift (core func $i "thunk"))
|
||||
)
|
||||
(func (export "take-string")
|
||||
(canon.lift (func (param string)) (into $i) (func $i "take-string"))
|
||||
(func (export "take-string") (param string)
|
||||
(canon lift (core func $i "take-string") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
(func (export "take-two-args")
|
||||
(canon.lift (func (param s32) (param (list u8))) (into $i) (func $i "two-args"))
|
||||
(func (export "take-two-args") (param s32) (param (list u8))
|
||||
(canon lift (core func $i "two-args") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
(func (export "ret-tuple")
|
||||
(canon.lift (func (result (tuple u8 s8))) (into $i) (func $i "ret-one"))
|
||||
(func (export "ret-tuple") (result (tuple u8 s8))
|
||||
(canon lift (core func $i "ret-one") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
(func (export "ret-tuple1")
|
||||
(canon.lift (func (result (tuple u32))) (into $i) (func $i "ret-one"))
|
||||
(func (export "ret-tuple1") (result (tuple u32))
|
||||
(canon lift (core func $i "ret-one") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
(func (export "ret-string")
|
||||
(canon.lift (func (result string)) (into $i) (func $i "ret-one"))
|
||||
(func (export "ret-string") (result string)
|
||||
(canon lift (core func $i "ret-one") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
(func (export "ret-list-u8")
|
||||
(canon.lift (func (result (list u8))) (into $i) (func $i "ret-one"))
|
||||
(func (export "ret-list-u8") (result (list u8))
|
||||
(canon lift (core func $i "ret-one") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -129,7 +127,7 @@ fn typecheck() -> Result<()> {
|
||||
fn integers() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "take-i32-100") (param i32)
|
||||
local.get 0
|
||||
i32.const 100
|
||||
@@ -150,40 +148,40 @@ fn integers() -> Result<()> {
|
||||
(func (export "ret-i64-minus-1") (result i64) i64.const -1)
|
||||
(func (export "ret-i32-100000") (result i32) i32.const 100000)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(func (export "take-u8") (canon.lift (func (param u8)) (func $i "take-i32-100")))
|
||||
(func (export "take-s8") (canon.lift (func (param s8)) (func $i "take-i32-100")))
|
||||
(func (export "take-u16") (canon.lift (func (param u16)) (func $i "take-i32-100")))
|
||||
(func (export "take-s16") (canon.lift (func (param s16)) (func $i "take-i32-100")))
|
||||
(func (export "take-u32") (canon.lift (func (param u32)) (func $i "take-i32-100")))
|
||||
(func (export "take-s32") (canon.lift (func (param s32)) (func $i "take-i32-100")))
|
||||
(func (export "take-u64") (canon.lift (func (param u64)) (func $i "take-i64-100")))
|
||||
(func (export "take-s64") (canon.lift (func (param s64)) (func $i "take-i64-100")))
|
||||
(core instance $i (instantiate (module $m)))
|
||||
(func (export "take-u8") (param u8) (canon lift (core func $i "take-i32-100")))
|
||||
(func (export "take-s8") (param s8) (canon lift (core func $i "take-i32-100")))
|
||||
(func (export "take-u16") (param u16) (canon lift (core func $i "take-i32-100")))
|
||||
(func (export "take-s16") (param s16) (canon lift (core func $i "take-i32-100")))
|
||||
(func (export "take-u32") (param u32) (canon lift (core func $i "take-i32-100")))
|
||||
(func (export "take-s32") (param s32) (canon lift (core func $i "take-i32-100")))
|
||||
(func (export "take-u64") (param u64) (canon lift (core func $i "take-i64-100")))
|
||||
(func (export "take-s64") (param s64) (canon lift (core func $i "take-i64-100")))
|
||||
|
||||
(func (export "ret-u8") (canon.lift (func (result u8)) (func $i "ret-i32-0")))
|
||||
(func (export "ret-s8") (canon.lift (func (result s8)) (func $i "ret-i32-0")))
|
||||
(func (export "ret-u16") (canon.lift (func (result u16)) (func $i "ret-i32-0")))
|
||||
(func (export "ret-s16") (canon.lift (func (result s16)) (func $i "ret-i32-0")))
|
||||
(func (export "ret-u32") (canon.lift (func (result u32)) (func $i "ret-i32-0")))
|
||||
(func (export "ret-s32") (canon.lift (func (result s32)) (func $i "ret-i32-0")))
|
||||
(func (export "ret-u64") (canon.lift (func (result u64)) (func $i "ret-i64-0")))
|
||||
(func (export "ret-s64") (canon.lift (func (result s64)) (func $i "ret-i64-0")))
|
||||
(func (export "ret-u8") (result u8) (canon lift (core func $i "ret-i32-0")))
|
||||
(func (export "ret-s8") (result s8) (canon lift (core func $i "ret-i32-0")))
|
||||
(func (export "ret-u16") (result u16) (canon lift (core func $i "ret-i32-0")))
|
||||
(func (export "ret-s16") (result s16) (canon lift (core func $i "ret-i32-0")))
|
||||
(func (export "ret-u32") (result u32) (canon lift (core func $i "ret-i32-0")))
|
||||
(func (export "ret-s32") (result s32) (canon lift (core func $i "ret-i32-0")))
|
||||
(func (export "ret-u64") (result u64) (canon lift (core func $i "ret-i64-0")))
|
||||
(func (export "ret-s64") (result s64) (canon lift (core func $i "ret-i64-0")))
|
||||
|
||||
(func (export "retm1-u8") (canon.lift (func (result u8)) (func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-s8") (canon.lift (func (result s8)) (func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-u16") (canon.lift (func (result u16)) (func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-s16") (canon.lift (func (result s16)) (func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-u32") (canon.lift (func (result u32)) (func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-s32") (canon.lift (func (result s32)) (func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-u64") (canon.lift (func (result u64)) (func $i "ret-i64-minus-1")))
|
||||
(func (export "retm1-s64") (canon.lift (func (result s64)) (func $i "ret-i64-minus-1")))
|
||||
(func (export "retm1-u8") (result u8) (canon lift (core func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-s8") (result s8) (canon lift (core func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-u16") (result u16) (canon lift (core func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-s16") (result s16) (canon lift (core func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-u32") (result u32) (canon lift (core func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-s32") (result s32) (canon lift (core func $i "ret-i32-minus-1")))
|
||||
(func (export "retm1-u64") (result u64) (canon lift (core func $i "ret-i64-minus-1")))
|
||||
(func (export "retm1-s64") (result s64) (canon lift (core func $i "ret-i64-minus-1")))
|
||||
|
||||
(func (export "retbig-u8") (canon.lift (func (result u8)) (func $i "ret-i32-100000")))
|
||||
(func (export "retbig-s8") (canon.lift (func (result s8)) (func $i "ret-i32-100000")))
|
||||
(func (export "retbig-u16") (canon.lift (func (result u16)) (func $i "ret-i32-100000")))
|
||||
(func (export "retbig-s16") (canon.lift (func (result s16)) (func $i "ret-i32-100000")))
|
||||
(func (export "retbig-u32") (canon.lift (func (result u32)) (func $i "ret-i32-100000")))
|
||||
(func (export "retbig-s32") (canon.lift (func (result s32)) (func $i "ret-i32-100000")))
|
||||
(func (export "retbig-u8") (result u8) (canon lift (core func $i "ret-i32-100000")))
|
||||
(func (export "retbig-s8") (result s8) (canon lift (core func $i "ret-i32-100000")))
|
||||
(func (export "retbig-u16") (result u16) (canon lift (core func $i "ret-i32-100000")))
|
||||
(func (export "retbig-s16") (result s16) (canon lift (core func $i "ret-i32-100000")))
|
||||
(func (export "retbig-u32") (result u32) (canon lift (core func $i "ret-i32-100000")))
|
||||
(func (export "retbig-s32") (result s32) (canon lift (core func $i "ret-i32-100000")))
|
||||
)
|
||||
"#;
|
||||
|
||||
@@ -406,7 +404,7 @@ fn integers() -> Result<()> {
|
||||
fn type_layers() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "take-i32-100") (param i32)
|
||||
local.get 0
|
||||
i32.const 2
|
||||
@@ -415,8 +413,8 @@ fn type_layers() -> Result<()> {
|
||||
unreachable
|
||||
)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(func (export "take-u32") (canon.lift (func (param u32)) (func $i "take-i32-100")))
|
||||
(core instance $i (instantiate $m))
|
||||
(func (export "take-u32") (param u32) (canon lift (core func $i "take-i32-100")))
|
||||
)
|
||||
"#;
|
||||
|
||||
@@ -448,7 +446,7 @@ fn type_layers() -> Result<()> {
|
||||
fn floats() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "i32.reinterpret_f32") (param f32) (result i32)
|
||||
local.get 0
|
||||
i32.reinterpret_f32
|
||||
@@ -466,19 +464,19 @@ fn floats() -> Result<()> {
|
||||
f64.reinterpret_i64
|
||||
)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "f32-to-u32")
|
||||
(canon.lift (func (param float32) (result u32)) (func $i "i32.reinterpret_f32"))
|
||||
(func (export "f32-to-u32") (param float32) (result u32)
|
||||
(canon lift (core func $i "i32.reinterpret_f32"))
|
||||
)
|
||||
(func (export "f64-to-u64")
|
||||
(canon.lift (func (param float64) (result u64)) (func $i "i64.reinterpret_f64"))
|
||||
(func (export "f64-to-u64") (param float64) (result u64)
|
||||
(canon lift (core func $i "i64.reinterpret_f64"))
|
||||
)
|
||||
(func (export "u32-to-f32")
|
||||
(canon.lift (func (param u32) (result float32)) (func $i "f32.reinterpret_i32"))
|
||||
(func (export "u32-to-f32") (param u32) (result float32)
|
||||
(canon lift (core func $i "f32.reinterpret_i32"))
|
||||
)
|
||||
(func (export "u64-to-f64")
|
||||
(canon.lift (func (param u64) (result float64)) (func $i "f64.reinterpret_i64"))
|
||||
(func (export "u64-to-f64") (param u64) (result float64)
|
||||
(canon lift (core func $i "f64.reinterpret_i64"))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -526,16 +524,16 @@ fn floats() -> Result<()> {
|
||||
fn bools() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "pass") (param i32) (result i32) local.get 0)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "u32-to-bool")
|
||||
(canon.lift (func (param u32) (result bool)) (func $i "pass"))
|
||||
(func (export "u32-to-bool") (param u32) (result bool)
|
||||
(canon lift (core func $i "pass"))
|
||||
)
|
||||
(func (export "bool-to-u32")
|
||||
(canon.lift (func (param bool) (result u32)) (func $i "pass"))
|
||||
(func (export "bool-to-u32") (param bool) (result u32)
|
||||
(canon lift (core func $i "pass"))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -560,16 +558,16 @@ fn bools() -> Result<()> {
|
||||
fn chars() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "pass") (param i32) (result i32) local.get 0)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "u32-to-char")
|
||||
(canon.lift (func (param u32) (result char)) (func $i "pass"))
|
||||
(func (export "u32-to-char") (param u32) (result char)
|
||||
(canon lift (core func $i "pass"))
|
||||
)
|
||||
(func (export "char-to-u32")
|
||||
(canon.lift (func (param char) (result u32)) (func $i "pass"))
|
||||
(func (export "char-to-u32") (param char) (result u32)
|
||||
(canon lift (core func $i "pass"))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -609,7 +607,7 @@ fn chars() -> Result<()> {
|
||||
fn tuple_result() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "foo") (param i32 i32 f32 f64) (result i32)
|
||||
(local $base i32)
|
||||
@@ -624,24 +622,16 @@ fn tuple_result() -> Result<()> {
|
||||
(func (export "invalid") (result i32)
|
||||
i32.const -8
|
||||
)
|
||||
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(type $result (tuple s8 u16 float32 float64))
|
||||
(func (export "tuple")
|
||||
(canon.lift
|
||||
(func (param s8) (param u16) (param float32) (param float64) (result $result))
|
||||
(into $i)
|
||||
(func $i "foo")
|
||||
)
|
||||
(param s8) (param u16) (param float32) (param float64) (result $result)
|
||||
(canon lift (core func $i "foo") (memory $i "memory"))
|
||||
)
|
||||
(func (export "invalid")
|
||||
(canon.lift (func (result $result)) (into $i) (func $i "invalid"))
|
||||
(func (export "invalid") (result $result)
|
||||
(canon lift (core func $i "invalid") (memory $i "memory"))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -673,7 +663,7 @@ fn tuple_result() -> Result<()> {
|
||||
fn strings() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "roundtrip") (param i32 i32) (result i32)
|
||||
(local $base i32)
|
||||
@@ -694,36 +684,36 @@ fn strings() -> Result<()> {
|
||||
|
||||
{REALLOC_AND_FREE}
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "list8-to-str")
|
||||
(canon.lift
|
||||
(func (param (list u8)) (result string))
|
||||
(into $i)
|
||||
(func $i "roundtrip")
|
||||
(func (export "list8-to-str") (param (list u8)) (result string)
|
||||
(canon lift
|
||||
(core func $i "roundtrip")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
(func (export "str-to-list8")
|
||||
(canon.lift
|
||||
(func (param string) (result (list u8)))
|
||||
(into $i)
|
||||
(func $i "roundtrip")
|
||||
(func (export "str-to-list8") (param string) (result (list u8))
|
||||
(canon lift
|
||||
(core func $i "roundtrip")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
(func (export "list16-to-str")
|
||||
(canon.lift
|
||||
(func (param (list u16)) (result string))
|
||||
string=utf16
|
||||
(into $i)
|
||||
(func $i "roundtrip")
|
||||
(func (export "list16-to-str") (param (list u16)) (result string)
|
||||
(canon lift
|
||||
(core func $i "roundtrip")
|
||||
string-encoding=utf16
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
(func (export "str-to-list16")
|
||||
(canon.lift
|
||||
(func (param string) (result (list u16)))
|
||||
string=utf16
|
||||
(into $i)
|
||||
(func $i "roundtrip")
|
||||
(func (export "str-to-list16") (param string) (result (list u16))
|
||||
(canon lift
|
||||
(core func $i "roundtrip")
|
||||
string-encoding=utf16
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
)"#
|
||||
@@ -792,7 +782,7 @@ fn strings() -> Result<()> {
|
||||
fn many_parameters() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "foo") (param i32) (result i32)
|
||||
(local $base i32)
|
||||
@@ -826,7 +816,7 @@ fn many_parameters() -> Result<()> {
|
||||
|
||||
{REALLOC_AND_FREE}
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(type $result (tuple (list u8) u32))
|
||||
(type $t (func
|
||||
@@ -847,8 +837,12 @@ fn many_parameters() -> Result<()> {
|
||||
|
||||
(result $result)
|
||||
))
|
||||
(func (export "many-param")
|
||||
(canon.lift (type $t) (into $i) (func $i "foo"))
|
||||
(func (export "many-param") (type $t)
|
||||
(canon lift
|
||||
(core func $i "foo")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
)"#
|
||||
);
|
||||
@@ -950,23 +944,21 @@ fn some_traps() -> Result<()> {
|
||||
let middle_of_memory = (i32::MAX / 2) & (!0xff);
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "take-many") (param i32))
|
||||
(func (export "take-list") (param i32 i32))
|
||||
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "take-list-unreachable")
|
||||
(canon.lift (func (param (list u8))) (into $i) (func $i "take-list"))
|
||||
(func (export "take-list-unreachable") (param (list u8))
|
||||
(canon lift (core func $i "take-list") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
(func (export "take-string-unreachable")
|
||||
(canon.lift (func (param string)) (into $i) (func $i "take-list"))
|
||||
(func (export "take-string-unreachable") (param string)
|
||||
(canon lift (core func $i "take-list") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
|
||||
(type $t (func
|
||||
@@ -981,60 +973,56 @@ fn some_traps() -> Result<()> {
|
||||
(param string)
|
||||
(param string)
|
||||
))
|
||||
(func (export "take-many-unreachable")
|
||||
(canon.lift (type $t) (into $i) (func $i "take-many"))
|
||||
(func (export "take-many-unreachable") (type $t)
|
||||
(canon lift (core func $i "take-many") (memory $i "memory") (realloc (func $i "realloc")))
|
||||
)
|
||||
|
||||
(module $m2
|
||||
(core module $m2
|
||||
(memory (export "memory") 1)
|
||||
(func (export "take-many") (param i32))
|
||||
(func (export "take-list") (param i32 i32))
|
||||
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
i32.const {middle_of_memory})
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $i2 (instantiate (module $m2)))
|
||||
(core instance $i2 (instantiate $m2))
|
||||
|
||||
(func (export "take-list-base-oob")
|
||||
(canon.lift (func (param (list u8))) (into $i2) (func $i2 "take-list"))
|
||||
(func (export "take-list-base-oob") (param (list u8))
|
||||
(canon lift (core func $i2 "take-list") (memory $i2 "memory") (realloc (func $i2 "realloc")))
|
||||
)
|
||||
(func (export "take-string-base-oob")
|
||||
(canon.lift (func (param string)) (into $i2) (func $i2 "take-list"))
|
||||
(func (export "take-string-base-oob") (param string)
|
||||
(canon lift (core func $i2 "take-list") (memory $i2 "memory") (realloc (func $i2 "realloc")))
|
||||
)
|
||||
(func (export "take-many-base-oob")
|
||||
(canon.lift (type $t) (into $i2) (func $i2 "take-many"))
|
||||
(func (export "take-many-base-oob") (type $t)
|
||||
(canon lift (core func $i2 "take-many") (memory $i2 "memory") (realloc (func $i2 "realloc")))
|
||||
)
|
||||
|
||||
(module $m3
|
||||
(core module $m3
|
||||
(memory (export "memory") 1)
|
||||
(func (export "take-many") (param i32))
|
||||
(func (export "take-list") (param i32 i32))
|
||||
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
i32.const 65532)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $i3 (instantiate (module $m3)))
|
||||
(core instance $i3 (instantiate $m3))
|
||||
|
||||
(func (export "take-list-end-oob")
|
||||
(canon.lift (func (param (list u8))) (into $i3) (func $i3 "take-list"))
|
||||
(func (export "take-list-end-oob") (param (list u8))
|
||||
(canon lift (core func $i3 "take-list") (memory $i3 "memory") (realloc (func $i3 "realloc")))
|
||||
)
|
||||
(func (export "take-string-end-oob")
|
||||
(canon.lift (func (param string)) (into $i3) (func $i3 "take-list"))
|
||||
(func (export "take-string-end-oob") (param string)
|
||||
(canon lift (core func $i3 "take-list") (memory $i3 "memory") (realloc (func $i3 "realloc")))
|
||||
)
|
||||
(func (export "take-many-end-oob")
|
||||
(canon.lift (type $t) (into $i3) (func $i3 "take-many"))
|
||||
(func (export "take-many-end-oob") (type $t)
|
||||
(canon lift (core func $i3 "take-many") (memory $i3 "memory") (realloc (func $i3 "realloc")))
|
||||
)
|
||||
|
||||
(module $m4
|
||||
(core module $m4
|
||||
(memory (export "memory") 1)
|
||||
(func (export "take-many") (param i32))
|
||||
|
||||
(global $cnt (mut i32) (i32.const 0))
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
global.get $cnt
|
||||
if (result i32)
|
||||
i32.const 100000
|
||||
@@ -1044,13 +1032,11 @@ fn some_traps() -> Result<()> {
|
||||
i32.const 0
|
||||
end
|
||||
)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $i4 (instantiate (module $m4)))
|
||||
(core instance $i4 (instantiate $m4))
|
||||
|
||||
(func (export "take-many-second-oob")
|
||||
(canon.lift (type $t) (into $i4) (func $i4 "take-many"))
|
||||
(func (export "take-many-second-oob") (type $t)
|
||||
(canon lift (core func $i4 "take-many") (memory $i4 "memory") (realloc (func $i4 "realloc")))
|
||||
)
|
||||
)"#
|
||||
);
|
||||
@@ -1184,7 +1170,7 @@ fn some_traps() -> Result<()> {
|
||||
fn char_bool_memory() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "ret-tuple") (param i32 i32) (result i32)
|
||||
(local $base i32)
|
||||
@@ -1212,10 +1198,12 @@ fn char_bool_memory() -> Result<()> {
|
||||
|
||||
{REALLOC_AND_FREE}
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "ret-tuple")
|
||||
(canon.lift (func (param u32) (param u32) (result (tuple bool char))) (into $i) (func $i "ret-tuple"))
|
||||
(func (export "ret-tuple") (param u32) (param u32) (result (tuple bool char))
|
||||
(canon lift (core func $i "ret-tuple")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc")))
|
||||
)
|
||||
)"#
|
||||
);
|
||||
@@ -1244,7 +1232,7 @@ fn char_bool_memory() -> Result<()> {
|
||||
fn string_list_oob() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "ret-list") (result i32)
|
||||
(local $base i32)
|
||||
@@ -1269,13 +1257,19 @@ fn string_list_oob() -> Result<()> {
|
||||
|
||||
{REALLOC_AND_FREE}
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "ret-list-u8")
|
||||
(canon.lift (func (result (list u8))) (into $i) (func $i "ret-list"))
|
||||
(func (export "ret-list-u8") (result (list u8))
|
||||
(canon lift (core func $i "ret-list")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
(func (export "ret-string")
|
||||
(canon.lift (func (result string)) (into $i) (func $i "ret-list"))
|
||||
(func (export "ret-string") (result string)
|
||||
(canon lift (core func $i "ret-list")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
)"#
|
||||
);
|
||||
@@ -1300,7 +1294,7 @@ fn string_list_oob() -> Result<()> {
|
||||
fn tuples() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "foo")
|
||||
(param i32 f64 i32)
|
||||
@@ -1323,23 +1317,14 @@ fn tuples() -> Result<()> {
|
||||
|
||||
i32.const 3
|
||||
)
|
||||
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "foo")
|
||||
(canon.lift
|
||||
(func
|
||||
(param (tuple s32 float64))
|
||||
(param (tuple s8))
|
||||
(result (tuple u16))
|
||||
)
|
||||
(func $i "foo")
|
||||
)
|
||||
(param (tuple s32 float64))
|
||||
(param (tuple s8))
|
||||
(result (tuple u16))
|
||||
(canon lift (core func $i "foo"))
|
||||
)
|
||||
)"#
|
||||
);
|
||||
@@ -1358,7 +1343,7 @@ fn tuples() -> Result<()> {
|
||||
fn option() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "pass0") (param i32) (result i32)
|
||||
local.get 0
|
||||
@@ -1405,60 +1390,41 @@ fn option() -> Result<()> {
|
||||
|
||||
{REALLOC_AND_FREE}
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "option-unit-to-u32")
|
||||
(canon.lift
|
||||
(func (param (option unit)) (result u32))
|
||||
(func $i "pass0")
|
||||
(func (export "option-unit-to-u32") (param (option unit)) (result u32)
|
||||
(canon lift (core func $i "pass0"))
|
||||
)
|
||||
(func (export "option-u8-to-tuple") (param (option u8)) (result (tuple u32 u32))
|
||||
(canon lift (core func $i "pass1") (memory $i "memory"))
|
||||
)
|
||||
(func (export "option-u32-to-tuple") (param (option u32)) (result (tuple u32 u32))
|
||||
(canon lift (core func $i "pass1") (memory $i "memory"))
|
||||
)
|
||||
(func (export "option-string-to-tuple") (param (option string)) (result (tuple u32 string))
|
||||
(canon lift
|
||||
(core func $i "pass2")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
(func (export "option-u8-to-tuple")
|
||||
(canon.lift
|
||||
(func (param (option u8)) (result (tuple u32 u32)))
|
||||
(into $i)
|
||||
(func $i "pass1")
|
||||
(func (export "to-option-unit") (param u32) (result (option unit))
|
||||
(canon lift (core func $i "pass0"))
|
||||
)
|
||||
(func (export "to-option-u8") (param u32) (param u32) (result (option u8))
|
||||
(canon lift (core func $i "pass1") (memory $i "memory"))
|
||||
)
|
||||
(func (export "to-option-u32") (param u32) (param u32) (result (option u32))
|
||||
(canon lift
|
||||
(core func $i "pass1")
|
||||
(memory $i "memory")
|
||||
)
|
||||
)
|
||||
(func (export "option-u32-to-tuple")
|
||||
(canon.lift
|
||||
(func (param (option u32)) (result (tuple u32 u32)))
|
||||
(into $i)
|
||||
(func $i "pass1")
|
||||
)
|
||||
)
|
||||
(func (export "option-string-to-tuple")
|
||||
(canon.lift
|
||||
(func (param (option string)) (result (tuple u32 string)))
|
||||
(into $i)
|
||||
(func $i "pass2")
|
||||
)
|
||||
)
|
||||
(func (export "to-option-unit")
|
||||
(canon.lift
|
||||
(func (param u32) (result (option unit)))
|
||||
(func $i "pass0")
|
||||
)
|
||||
)
|
||||
(func (export "to-option-u8")
|
||||
(canon.lift
|
||||
(func (param u32) (param u32) (result (option u8)))
|
||||
(into $i)
|
||||
(func $i "pass1")
|
||||
)
|
||||
)
|
||||
(func (export "to-option-u32")
|
||||
(canon.lift
|
||||
(func (param u32) (param u32) (result (option u32)))
|
||||
(into $i)
|
||||
(func $i "pass1")
|
||||
)
|
||||
)
|
||||
(func (export "to-option-string")
|
||||
(canon.lift
|
||||
(func (param u32) (param string) (result (option string)))
|
||||
(into $i)
|
||||
(func $i "pass2")
|
||||
(func (export "to-option-string") (param u32) (param string) (result (option string))
|
||||
(canon lift
|
||||
(core func $i "pass2")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
)"#
|
||||
@@ -1543,7 +1509,7 @@ fn option() -> Result<()> {
|
||||
fn expected() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "pass0") (param i32) (result i32)
|
||||
local.get 0
|
||||
@@ -1590,40 +1556,30 @@ fn expected() -> Result<()> {
|
||||
|
||||
{REALLOC_AND_FREE}
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "take-expected-unit")
|
||||
(canon.lift
|
||||
(func (param (expected unit unit)) (result u32))
|
||||
(func $i "pass0")
|
||||
)
|
||||
(func (export "take-expected-unit") (param (expected unit unit)) (result u32)
|
||||
(canon lift (core func $i "pass0"))
|
||||
)
|
||||
(func (export "take-expected-u8-f32")
|
||||
(canon.lift
|
||||
(func (param (expected u8 float32)) (result (tuple u32 u32)))
|
||||
(into $i)
|
||||
(func $i "pass1")
|
||||
)
|
||||
(func (export "take-expected-u8-f32") (param (expected u8 float32)) (result (tuple u32 u32))
|
||||
(canon lift (core func $i "pass1") (memory $i "memory"))
|
||||
)
|
||||
(type $list (list u8))
|
||||
(func (export "take-expected-string")
|
||||
(canon.lift
|
||||
(func (param (expected string $list)) (result (tuple u32 string)))
|
||||
(into $i)
|
||||
(func $i "pass2")
|
||||
(func (export "take-expected-string") (param (expected string $list)) (result (tuple u32 string))
|
||||
(canon lift
|
||||
(core func $i "pass2")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
(func (export "to-expected-unit")
|
||||
(canon.lift
|
||||
(func (param u32) (result (expected unit unit)))
|
||||
(func $i "pass0")
|
||||
)
|
||||
(func (export "to-expected-unit") (param u32) (result (expected unit unit))
|
||||
(canon lift (core func $i "pass0"))
|
||||
)
|
||||
(func (export "to-expected-s16-f32")
|
||||
(canon.lift
|
||||
(func (param u32) (param u32) (result (expected s16 float32)))
|
||||
(into $i)
|
||||
(func $i "pass1")
|
||||
(func (export "to-expected-s16-f32") (param u32) (param u32) (result (expected s16 float32))
|
||||
(canon lift
|
||||
(core func $i "pass1")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
)"#
|
||||
@@ -1684,7 +1640,7 @@ fn expected() -> Result<()> {
|
||||
fn fancy_list() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "take") (param i32 i32) (result i32)
|
||||
(local $base i32)
|
||||
@@ -1715,17 +1671,17 @@ fn fancy_list() -> Result<()> {
|
||||
|
||||
{REALLOC_AND_FREE}
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(type $a (option u8))
|
||||
(type $b (expected unit string))
|
||||
(type $input (list (tuple $a $b)))
|
||||
(type $output (tuple u32 u32 (list u8)))
|
||||
(func (export "take")
|
||||
(canon.lift
|
||||
(func (param $input) (result $output))
|
||||
(into $i)
|
||||
(func $i "take")
|
||||
(func (export "take") (param $input) (result $output)
|
||||
(canon lift
|
||||
(core func $i "take")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
)"#
|
||||
@@ -1808,13 +1764,10 @@ impl<'a> SliceExt<'a> for &'a [u8] {
|
||||
fn invalid_alignment() -> Result<()> {
|
||||
let component = format!(
|
||||
r#"(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(memory (export "memory") 1)
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
i32.const 1)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
unreachable)
|
||||
|
||||
|
||||
(func (export "take-i32") (param i32))
|
||||
(func (export "ret-1") (result i32) i32.const 1)
|
||||
@@ -1823,24 +1776,31 @@ fn invalid_alignment() -> Result<()> {
|
||||
(i32.store offset=4 (i32.const 8) (i32.const 1))
|
||||
i32.const 8)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "many-params")
|
||||
(canon.lift
|
||||
(func
|
||||
(param string) (param string) (param string) (param string)
|
||||
(param string) (param string) (param string) (param string)
|
||||
(param string) (param string) (param string) (param string)
|
||||
)
|
||||
(into $i)
|
||||
(func $i "take-i32")
|
||||
(param string) (param string) (param string) (param string)
|
||||
(param string) (param string) (param string) (param string)
|
||||
(param string) (param string) (param string) (param string)
|
||||
(canon lift
|
||||
(core func $i "take-i32")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
(func (export "string-ret")
|
||||
(canon.lift (func (result string)) (into $i) (func $i "ret-1"))
|
||||
(func (export "string-ret") (result string)
|
||||
(canon lift
|
||||
(core func $i "ret-1")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
(func (export "list-u32-ret")
|
||||
(canon.lift (func (result (list u32))) (into $i) (func $i "ret-unaligned-list"))
|
||||
(func (export "list-u32-ret") (result (list u32))
|
||||
(canon lift
|
||||
(core func $i "ret-unaligned-list")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
)"#
|
||||
);
|
||||
|
||||
@@ -7,20 +7,18 @@ use wasmtime::{Store, StoreContextMut, Trap};
|
||||
fn can_compile() -> Result<()> {
|
||||
let engine = super::engine();
|
||||
let libc = r#"
|
||||
(module $libc
|
||||
(core module $libc
|
||||
(memory (export "memory") 1)
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $libc (instantiate (module $libc)))
|
||||
(core instance $libc (instantiate $libc))
|
||||
"#;
|
||||
Component::new(
|
||||
&engine,
|
||||
r#"(component
|
||||
(import "" (func $f))
|
||||
(func (canon.lower (func $f)))
|
||||
(core func (canon lower (func $f)))
|
||||
)"#,
|
||||
)?;
|
||||
Component::new(
|
||||
@@ -29,7 +27,7 @@ fn can_compile() -> Result<()> {
|
||||
r#"(component
|
||||
(import "" (func $f (param string)))
|
||||
{libc}
|
||||
(func (canon.lower (into $libc) (func $f)))
|
||||
(core func (canon lower (func $f) (memory $libc "memory") (realloc (func $libc "realloc"))))
|
||||
)"#
|
||||
),
|
||||
)?;
|
||||
@@ -39,14 +37,14 @@ fn can_compile() -> Result<()> {
|
||||
r#"(component
|
||||
(import "f1" (func $f1 (param string) (result string)))
|
||||
{libc}
|
||||
(func (canon.lower (into $libc) (func $f1)))
|
||||
(core func (canon lower (func $f1) (memory $libc "memory") (realloc (func $libc "realloc"))))
|
||||
|
||||
(import "f2" (func $f2 (param u32) (result (list u8))))
|
||||
(instance $libc2 (instantiate (module $libc)))
|
||||
(func (canon.lower (into $libc2) (func $f2)))
|
||||
(core instance $libc2 (instantiate $libc))
|
||||
(core func (canon lower (func $f2) (memory $libc2 "memory") (realloc (func $libc2 "realloc"))))
|
||||
|
||||
(func (canon.lower (into $libc2) (func $f1)))
|
||||
(func (canon.lower (into $libc) (func $f2)))
|
||||
(core func (canon lower (func $f1) (memory $libc2 "memory") (realloc (func $libc2 "realloc"))))
|
||||
(core func (canon lower (func $f2) (memory $libc "memory") (realloc (func $libc "realloc"))))
|
||||
)"#
|
||||
),
|
||||
)?;
|
||||
@@ -56,9 +54,9 @@ fn can_compile() -> Result<()> {
|
||||
r#"(component
|
||||
(import "log" (func $log (param string)))
|
||||
{libc}
|
||||
(func $log_lower (canon.lower (into $libc) (func $log)))
|
||||
(core func $log_lower (canon lower (func $log) (memory $libc "memory") (realloc (func $libc "realloc"))))
|
||||
|
||||
(module $logger
|
||||
(core module $logger
|
||||
(import "host" "log" (func $log (param i32 i32)))
|
||||
(import "libc" "memory" (memory 1))
|
||||
|
||||
@@ -67,13 +65,13 @@ fn can_compile() -> Result<()> {
|
||||
i32.const 0
|
||||
call $log)
|
||||
)
|
||||
(instance $logger (instantiate (module $logger)
|
||||
(core instance $logger (instantiate $logger
|
||||
(with "host" (instance (export "log" (func $log_lower))))
|
||||
(with "libc" (instance $libc))
|
||||
))
|
||||
|
||||
(func (export "call")
|
||||
(canon.lift (func) (func $logger "call"))
|
||||
(canon lift (core func $logger "call"))
|
||||
)
|
||||
)"#
|
||||
),
|
||||
@@ -87,19 +85,17 @@ fn simple() -> Result<()> {
|
||||
(component
|
||||
(import "" (func $log (param string)))
|
||||
|
||||
(module $libc
|
||||
(core module $libc
|
||||
(memory (export "memory") 1)
|
||||
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $libc (instantiate (module $libc)))
|
||||
(func $log_lower
|
||||
(canon.lower (into $libc) (func $log))
|
||||
(core instance $libc (instantiate $libc))
|
||||
(core func $log_lower
|
||||
(canon lower (func $log) (memory $libc "memory") (realloc (func $libc "realloc")))
|
||||
)
|
||||
(module $m
|
||||
(core module $m
|
||||
(import "libc" "memory" (memory 1))
|
||||
(import "host" "log" (func $log (param i32 i32)))
|
||||
|
||||
@@ -110,12 +106,12 @@ fn simple() -> Result<()> {
|
||||
|
||||
(data (i32.const 5) "hello world")
|
||||
)
|
||||
(instance $i (instantiate (module $m)
|
||||
(core instance $i (instantiate $m
|
||||
(with "libc" (instance $libc))
|
||||
(with "host" (instance (export "log" (func $log_lower))))
|
||||
))
|
||||
(func (export "call")
|
||||
(canon.lift (func) (func $i "call"))
|
||||
(canon lift (core func $i "call"))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -150,7 +146,7 @@ fn attempt_to_leave_during_malloc() -> Result<()> {
|
||||
(import "thunk" (func $thunk))
|
||||
(import "ret-string" (func $ret_string (result string)))
|
||||
|
||||
(module $host_shim
|
||||
(core module $host_shim
|
||||
(table (export "table") 2 funcref)
|
||||
(func $shim_thunk (export "thunk")
|
||||
i32.const 0
|
||||
@@ -160,21 +156,18 @@ fn attempt_to_leave_during_malloc() -> Result<()> {
|
||||
i32.const 1
|
||||
call_indirect (param i32))
|
||||
)
|
||||
(instance $host_shim (instantiate (module $host_shim)))
|
||||
(core instance $host_shim (instantiate $host_shim))
|
||||
|
||||
(module $m
|
||||
(core module $m
|
||||
(import "host" "thunk" (func $thunk))
|
||||
(import "host" "ret-string" (func $ret_string (param i32)))
|
||||
|
||||
(memory (export "memory") 1)
|
||||
|
||||
(func $realloc (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
(func $realloc (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
call $thunk
|
||||
unreachable)
|
||||
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
unreachable)
|
||||
|
||||
(func $run (export "run")
|
||||
i32.const 8
|
||||
call $ret_string)
|
||||
@@ -182,24 +175,24 @@ fn attempt_to_leave_during_malloc() -> Result<()> {
|
||||
(func (export "take-string") (param i32 i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $m (instantiate (module $m) (with "host" (instance $host_shim))))
|
||||
(core instance $m (instantiate $m (with "host" (instance $host_shim))))
|
||||
|
||||
(module $host_shim_filler_inner
|
||||
(core module $host_shim_filler_inner
|
||||
(import "shim" "table" (table 2 funcref))
|
||||
(import "host" "thunk" (func $thunk))
|
||||
(import "host" "ret-string" (func $ret_string (param i32)))
|
||||
(elem (i32.const 0) $thunk $ret_string)
|
||||
)
|
||||
|
||||
(func $thunk_lower
|
||||
(canon.lower (into $m) (func $thunk))
|
||||
(core func $thunk_lower
|
||||
(canon lower (func $thunk) (memory $m "memory") (realloc (func $m "realloc")))
|
||||
)
|
||||
|
||||
(func $ret_string_lower
|
||||
(canon.lower (into $m) (func $ret_string))
|
||||
(core func $ret_string_lower
|
||||
(canon lower (func $ret_string) (memory $m "memory") (realloc (func $m "realloc")))
|
||||
)
|
||||
|
||||
(instance (instantiate (module $host_shim_filler_inner)
|
||||
(core instance (instantiate $host_shim_filler_inner
|
||||
(with "shim" (instance $host_shim))
|
||||
(with "host" (instance
|
||||
(export "thunk" (func $thunk_lower))
|
||||
@@ -208,10 +201,10 @@ fn attempt_to_leave_during_malloc() -> Result<()> {
|
||||
))
|
||||
|
||||
(func (export "run")
|
||||
(canon.lift (func) (func $m "run"))
|
||||
(canon lift (core func $m "run"))
|
||||
)
|
||||
(func (export "take-string")
|
||||
(canon.lift (func (param string)) (into $m) (func $m "take-string"))
|
||||
(func (export "take-string") (param string)
|
||||
(canon lift (core func $m "take-string") (memory $m "memory") (realloc (func $m "realloc")))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -287,20 +280,20 @@ fn attempt_to_reenter_during_host() -> Result<()> {
|
||||
let component = r#"
|
||||
(component
|
||||
(import "thunk" (func $thunk))
|
||||
(func $thunk_lower (canon.lower (func $thunk)))
|
||||
(core func $thunk_lower (canon lower (func $thunk)))
|
||||
|
||||
(module $m
|
||||
(core module $m
|
||||
(import "host" "thunk" (func $thunk))
|
||||
|
||||
(func $run (export "run")
|
||||
call $thunk)
|
||||
)
|
||||
(instance $m (instantiate (module $m)
|
||||
(core instance $m (instantiate $m
|
||||
(with "host" (instance (export "thunk" (func $thunk_lower))))
|
||||
))
|
||||
|
||||
(func (export "run")
|
||||
(canon.lift (func) (func $m "run"))
|
||||
(canon lift (core func $m "run"))
|
||||
)
|
||||
)
|
||||
"#;
|
||||
@@ -348,18 +341,18 @@ fn stack_and_heap_args_and_rets() -> Result<()> {
|
||||
(import "f3" (func $f3 (param u32) (result string)))
|
||||
(import "f4" (func $f4 (param $many_params) (result string)))
|
||||
|
||||
(module $libc
|
||||
(core module $libc
|
||||
{REALLOC_AND_FREE}
|
||||
(memory (export "memory") 1)
|
||||
)
|
||||
(instance $libc (instantiate (module $libc)))
|
||||
(core instance $libc (instantiate (module $libc)))
|
||||
|
||||
(func $f1_lower (canon.lower (into $libc) (func $f1)))
|
||||
(func $f2_lower (canon.lower (into $libc) (func $f2)))
|
||||
(func $f3_lower (canon.lower (into $libc) (func $f3)))
|
||||
(func $f4_lower (canon.lower (into $libc) (func $f4)))
|
||||
(core func $f1_lower (canon lower (func $f1) (memory $libc "memory") (realloc (func $libc "realloc"))))
|
||||
(core func $f2_lower (canon lower (func $f2) (memory $libc "memory") (realloc (func $libc "realloc"))))
|
||||
(core func $f3_lower (canon lower (func $f3) (memory $libc "memory") (realloc (func $libc "realloc"))))
|
||||
(core func $f4_lower (canon lower (func $f4) (memory $libc "memory") (realloc (func $libc "realloc"))))
|
||||
|
||||
(module $m
|
||||
(core module $m
|
||||
(import "host" "f1" (func $f1 (param i32) (result i32)))
|
||||
(import "host" "f2" (func $f2 (param i32) (result i32)))
|
||||
(import "host" "f3" (func $f3 (param i32 i32)))
|
||||
@@ -454,7 +447,7 @@ fn stack_and_heap_args_and_rets() -> Result<()> {
|
||||
|
||||
(data (i32.const 1000) "abc")
|
||||
)
|
||||
(instance $m (instantiate (module $m)
|
||||
(core instance $m (instantiate $m
|
||||
(with "libc" (instance $libc))
|
||||
(with "host" (instance
|
||||
(export "f1" (func $f1_lower))
|
||||
@@ -465,7 +458,7 @@ fn stack_and_heap_args_and_rets() -> Result<()> {
|
||||
))
|
||||
|
||||
(func (export "run")
|
||||
(canon.lift (func) (func $m "run"))
|
||||
(canon lift (core func $m "run"))
|
||||
)
|
||||
)
|
||||
"#
|
||||
@@ -542,23 +535,21 @@ fn bad_import_alignment() -> Result<()> {
|
||||
string
|
||||
))
|
||||
(import "unaligned-argptr" (func $unaligned_argptr (param $many_arg)))
|
||||
(module $libc_panic
|
||||
(core module $libc_panic
|
||||
(memory (export "memory") 1)
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
)
|
||||
(instance $libc_panic (instantiate (module $libc_panic)))
|
||||
(core instance $libc_panic (instantiate $libc_panic))
|
||||
|
||||
(func $unaligned_retptr_lower
|
||||
(canon.lower (into $libc_panic) (func $unaligned_retptr))
|
||||
(core func $unaligned_retptr_lower
|
||||
(canon lower (func $unaligned_retptr) (memory $libc_panic "memory") (realloc (func $libc_panic "realloc")))
|
||||
)
|
||||
(func $unaligned_argptr_lower
|
||||
(canon.lower (into $libc_panic) (func $unaligned_argptr))
|
||||
(core func $unaligned_argptr_lower
|
||||
(canon lower (func $unaligned_argptr) (memory $libc_panic "memory") (realloc (func $libc_panic "realloc")))
|
||||
)
|
||||
|
||||
(module $m
|
||||
(core module $m
|
||||
(import "host" "unaligned-retptr" (func $unaligned_retptr (param i32)))
|
||||
(import "host" "unaligned-argptr" (func $unaligned_argptr (param i32)))
|
||||
|
||||
@@ -567,7 +558,7 @@ fn bad_import_alignment() -> Result<()> {
|
||||
(func (export "unaligned-argptr")
|
||||
(call $unaligned_argptr (i32.const 1)))
|
||||
)
|
||||
(instance $m (instantiate (module $m)
|
||||
(core instance $m (instantiate $m
|
||||
(with "host" (instance
|
||||
(export "unaligned-retptr" (func $unaligned_retptr_lower))
|
||||
(export "unaligned-argptr" (func $unaligned_argptr_lower))
|
||||
@@ -575,10 +566,10 @@ fn bad_import_alignment() -> Result<()> {
|
||||
))
|
||||
|
||||
(func (export "unaligned-retptr")
|
||||
(canon.lift (func) (func $m "unaligned-retptr"))
|
||||
(canon lift (core func $m "unaligned-retptr"))
|
||||
)
|
||||
(func (export "unaligned-argptr")
|
||||
(canon.lift (func) (func $m "unaligned-argptr"))
|
||||
(canon lift (core func $m "unaligned-argptr"))
|
||||
)
|
||||
)
|
||||
"#
|
||||
|
||||
@@ -1,54 +1,72 @@
|
||||
;; basic function lifting
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export ""))
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "thunk")
|
||||
(canon.lift (func) (func $i ""))
|
||||
(canon lift (core func $i ""))
|
||||
)
|
||||
)
|
||||
|
||||
;; use an aliased type
|
||||
(component $c
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export ""))
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(type $to_alias (func))
|
||||
(alias outer $c $to_alias (type $alias))
|
||||
|
||||
(func (export "thunk")
|
||||
(canon.lift (type $alias) (func $i ""))
|
||||
(func (export "thunk") (type $alias)
|
||||
(canon lift (core func $i ""))
|
||||
)
|
||||
)
|
||||
|
||||
;; test out some various canonical abi
|
||||
(component $c
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "") (param i32 i32))
|
||||
(memory (export "memory") 1)
|
||||
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32)
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32)
|
||||
unreachable)
|
||||
(func (export "canonical_abi_free") (param i32 i32 i32))
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(func (export "thunk")
|
||||
(canon.lift (func (param string)) (into $i) (func $i ""))
|
||||
(func (export "thunk") (param string)
|
||||
(canon lift
|
||||
(core func $i "")
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "thunk8")
|
||||
(canon.lift (func (param string)) string=utf8 (into $i) (func $i ""))
|
||||
(func (export "thunk8") (param string)
|
||||
(canon lift
|
||||
(core func $i "")
|
||||
string-encoding=utf8
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "thunk16")
|
||||
(canon.lift (func (param string)) string=utf16 (into $i) (func $i ""))
|
||||
(func (export "thunk16") (param string)
|
||||
(canon lift
|
||||
(core func $i "")
|
||||
string-encoding=utf16
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "thunklatin16")
|
||||
(canon.lift (func (param string)) string=latin1+utf16 (into $i) (func $i ""))
|
||||
(func (export "thunklatin16") (param string)
|
||||
(canon lift
|
||||
(core func $i "")
|
||||
string-encoding=latin1+utf16
|
||||
(memory $i "memory")
|
||||
(realloc (func $i "realloc"))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
(component
|
||||
(module $m)
|
||||
(instance (instantiate (module $m)))
|
||||
(core module $m)
|
||||
(core instance (instantiate $m))
|
||||
)
|
||||
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export ""))
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(module $m2
|
||||
(core module $m2
|
||||
(func (import "" ""))
|
||||
)
|
||||
(instance (instantiate (module $m2) (with "" (instance $i))))
|
||||
(core instance (instantiate $m2 (with "" (instance $i))))
|
||||
)
|
||||
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "a"))
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(module $m2
|
||||
(core module $m2
|
||||
(func (import "" "b"))
|
||||
)
|
||||
(instance (instantiate (module $m2)
|
||||
(core instance (instantiate $m2
|
||||
(with "" (instance (export "b" (func $i "a"))))
|
||||
))
|
||||
)
|
||||
@@ -32,15 +32,15 @@
|
||||
;; all kinds of imports for core wasm modules, and register a start function on
|
||||
;; one module to ensure that everything is correct
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "a"))
|
||||
(table (export "b") 1 funcref)
|
||||
(memory (export "c") 1)
|
||||
(global (export "d") i32 i32.const 1)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(module $m2
|
||||
(core module $m2
|
||||
(import "" "a" (func $f))
|
||||
(import "" "b" (table 1 funcref))
|
||||
(import "" "c" (memory 1))
|
||||
@@ -62,7 +62,7 @@
|
||||
(data (i32.const 0) "hello")
|
||||
(elem (i32.const 0) $start)
|
||||
)
|
||||
(instance (instantiate (module $m2)
|
||||
(core instance (instantiate $m2
|
||||
(with "" (instance $i))
|
||||
))
|
||||
)
|
||||
@@ -71,12 +71,12 @@
|
||||
;; sees the wrong value for the global import
|
||||
(assert_trap
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(global (export "g") i32 i32.const 1)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(module $m2
|
||||
(core module $m2
|
||||
(import "" "g" (global $g i32))
|
||||
|
||||
(func $start
|
||||
@@ -90,27 +90,27 @@
|
||||
|
||||
(start $start)
|
||||
)
|
||||
(instance (instantiate (module $m2) (with "" (instance $i))))
|
||||
(core instance (instantiate $m2 (with "" (instance $i))))
|
||||
)
|
||||
"unreachable")
|
||||
|
||||
;; shuffle around imports to get to what the target core wasm module needs
|
||||
(component
|
||||
(module $m
|
||||
(core module $m
|
||||
(func (export "1"))
|
||||
(table (export "2") 1 funcref)
|
||||
(memory (export "3") 1)
|
||||
(global (export "4") i32 i32.const 1)
|
||||
)
|
||||
(instance $i (instantiate (module $m)))
|
||||
(core instance $i (instantiate $m))
|
||||
|
||||
(module $m2
|
||||
(core module $m2
|
||||
(import "" "a" (func $f))
|
||||
(import "" "b" (table 1 funcref))
|
||||
(import "" "c" (memory 1))
|
||||
(import "" "d" (global $g i32))
|
||||
)
|
||||
(instance (instantiate (module $m2)
|
||||
(core instance (instantiate $m2
|
||||
(with "" (instance
|
||||
(export "a" (func $i "1"))
|
||||
(export "b" (table $i "2"))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "undefined-name" (module))
|
||||
(import "undefined-name" (core module))
|
||||
)
|
||||
"import `undefined-name` not defined")
|
||||
(component $i)
|
||||
@@ -8,7 +8,7 @@
|
||||
(import "i" (instance))
|
||||
)
|
||||
(assert_unlinkable
|
||||
(component (import "i" (module)))
|
||||
(component (import "i" (core module)))
|
||||
"expected module found instance")
|
||||
(assert_unlinkable
|
||||
(component (import "i" (func)))
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
(component $foo
|
||||
(module (export "a-module"))
|
||||
(core module (export "a-module"))
|
||||
)
|
||||
|
||||
;; the above instance can be imported into this component
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module))
|
||||
(export "a-module" (core module))
|
||||
))
|
||||
)
|
||||
|
||||
;; specifying extra imports is ok
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module
|
||||
(export "a-module" (core module
|
||||
(import "foo" "bar" (func))
|
||||
))
|
||||
))
|
||||
@@ -22,7 +22,7 @@
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module
|
||||
(export "a-module" (core module
|
||||
(export "the-export" (func))
|
||||
))
|
||||
))
|
||||
@@ -30,7 +30,7 @@
|
||||
"module export `the-export` not defined")
|
||||
|
||||
(component $foo
|
||||
(module (export "a-module")
|
||||
(core module (export "a-module")
|
||||
(import "env" "something" (func))
|
||||
)
|
||||
)
|
||||
@@ -39,14 +39,14 @@
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module))
|
||||
(export "a-module" (core module))
|
||||
))
|
||||
)
|
||||
"module import `env::something` not defined")
|
||||
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module
|
||||
(export "a-module" (core module
|
||||
(import "env" "something" (func))
|
||||
))
|
||||
))
|
||||
@@ -55,7 +55,7 @@
|
||||
;; extra imports still ok
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module
|
||||
(export "a-module" (core module
|
||||
(import "env" "something" (func))
|
||||
(import "env" "other" (global i32))
|
||||
))
|
||||
@@ -63,7 +63,7 @@
|
||||
)
|
||||
|
||||
(component $foo
|
||||
(module (export "a-module")
|
||||
(core module (export "a-module")
|
||||
(func (export "f"))
|
||||
)
|
||||
)
|
||||
@@ -71,13 +71,13 @@
|
||||
;; dropping exports is ok
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module))
|
||||
(export "a-module" (core module))
|
||||
))
|
||||
)
|
||||
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module
|
||||
(export "a-module" (core module
|
||||
(export "f" (func))
|
||||
))
|
||||
))
|
||||
@@ -86,7 +86,7 @@
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module
|
||||
(export "a-module" (core module
|
||||
(export "f" (func (param i32)))
|
||||
))
|
||||
))
|
||||
@@ -96,7 +96,7 @@
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "a-module" (module
|
||||
(export "a-module" (core module
|
||||
(export "f" (global i32))
|
||||
))
|
||||
))
|
||||
@@ -104,7 +104,7 @@
|
||||
"expected global found func")
|
||||
|
||||
(component $foo
|
||||
(module (export "m")
|
||||
(core module (export "m")
|
||||
(func (export "f"))
|
||||
(table (export "t") 1 funcref)
|
||||
(memory (export "m") 1)
|
||||
@@ -116,28 +116,28 @@
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "f" (global i32))))
|
||||
(export "m" (core module (export "f" (global i32))))
|
||||
))
|
||||
)
|
||||
"expected global found func")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "t" (func))))
|
||||
(export "m" (core module (export "t" (func))))
|
||||
))
|
||||
)
|
||||
"expected func found table")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "m" (func))))
|
||||
(export "m" (core module (export "m" (func))))
|
||||
))
|
||||
)
|
||||
"expected func found memory")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "g" (func))))
|
||||
(export "m" (core module (export "g" (func))))
|
||||
))
|
||||
)
|
||||
"expected func found global")
|
||||
@@ -146,42 +146,42 @@
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "f" (func (param i32)))))
|
||||
(export "m" (core module (export "f" (func (param i32)))))
|
||||
))
|
||||
)
|
||||
"export `f` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "t" (table 1 externref))))
|
||||
(export "m" (core module (export "t" (table 1 externref))))
|
||||
))
|
||||
)
|
||||
"export `t` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "t" (table 2 funcref))))
|
||||
(export "m" (core module (export "t" (table 2 funcref))))
|
||||
))
|
||||
)
|
||||
"export `t` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "m" (memory 2))))
|
||||
(export "m" (core module (export "m" (memory 2))))
|
||||
))
|
||||
)
|
||||
"export `m` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "g" (global f32))))
|
||||
(export "m" (core module (export "g" (global f32))))
|
||||
))
|
||||
)
|
||||
"export `g` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (export "g" (global (mut i32)))))
|
||||
(export "m" (core module (export "g" (global (mut i32)))))
|
||||
))
|
||||
)
|
||||
"export `g` has the wrong type")
|
||||
@@ -189,7 +189,7 @@
|
||||
;; subtyping ok
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module
|
||||
(export "m" (core module
|
||||
(export "t" (table 0 funcref))
|
||||
(export "m" (memory 0))
|
||||
))
|
||||
@@ -197,38 +197,38 @@
|
||||
)
|
||||
|
||||
(component $foo
|
||||
(module (export "f") (func (import "" "")))
|
||||
(module (export "t") (table (import "" "") 1 funcref))
|
||||
(module (export "m") (memory (import "" "") 1))
|
||||
(module (export "g") (global (import "" "") i32))
|
||||
(core module (export "f") (func (import "" "")))
|
||||
(core module (export "t") (table (import "" "") 1 funcref))
|
||||
(core module (export "m") (memory (import "" "") 1))
|
||||
(core module (export "g") (global (import "" "") i32))
|
||||
)
|
||||
|
||||
;; wrong class of item
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "f" (module (import "" "" (global i32))))
|
||||
(export "f" (core module (import "" "" (global i32))))
|
||||
))
|
||||
)
|
||||
"expected func found global")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "t" (module (import "" "" (func))))
|
||||
(export "t" (core module (import "" "" (func))))
|
||||
))
|
||||
)
|
||||
"expected table found func")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (import "" "" (func))))
|
||||
(export "m" (core module (import "" "" (func))))
|
||||
))
|
||||
)
|
||||
"expected memory found func")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "g" (module (import "" "" (func))))
|
||||
(export "g" (core module (import "" "" (func))))
|
||||
))
|
||||
)
|
||||
"expected global found func")
|
||||
@@ -237,42 +237,42 @@
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "f" (module (import "" "" (func (param i32)))))
|
||||
(export "f" (core module (import "" "" (func (param i32)))))
|
||||
))
|
||||
)
|
||||
"module import `::` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "t" (module (import "" "" (table 1 externref))))
|
||||
(export "t" (core module (import "" "" (table 1 externref))))
|
||||
))
|
||||
)
|
||||
"module import `::` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "t" (module (import "" "" (table 0 funcref))))
|
||||
(export "t" (core module (import "" "" (table 0 funcref))))
|
||||
))
|
||||
)
|
||||
"module import `::` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "m" (module (import "" "" (memory 0))))
|
||||
(export "m" (core module (import "" "" (memory 0))))
|
||||
))
|
||||
)
|
||||
"module import `::` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "g" (module (import "" "" (global f32))))
|
||||
(export "g" (core module (import "" "" (global f32))))
|
||||
))
|
||||
)
|
||||
"module import `::` has the wrong type")
|
||||
(assert_unlinkable
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "g" (module (import "" "" (global (mut i32)))))
|
||||
(export "g" (core module (import "" "" (global (mut i32)))))
|
||||
))
|
||||
)
|
||||
"module import `::` has the wrong type")
|
||||
@@ -280,45 +280,45 @@
|
||||
;; subtyping ok, but in the opposite direction of imports
|
||||
(component
|
||||
(import "foo" (instance
|
||||
(export "t" (module (import "" "" (table 2 funcref))))
|
||||
(export "m" (module (import "" "" (memory 2))))
|
||||
(export "t" (core module (import "" "" (table 2 funcref))))
|
||||
(export "m" (core module (import "" "" (memory 2))))
|
||||
))
|
||||
)
|
||||
|
||||
;; An instance can reexport a module, define a module, and everything can be
|
||||
;; used by something else
|
||||
(component $src
|
||||
(module (export "m")
|
||||
(core module (export "m")
|
||||
(global (export "g") i32 i32.const 2)
|
||||
)
|
||||
)
|
||||
|
||||
(component $reexport
|
||||
(module $m1
|
||||
(core module $m1
|
||||
(global (export "g") i32 i32.const 1)
|
||||
)
|
||||
(import "src" (instance $src
|
||||
(export "m" (module (export "g" (global i32))))
|
||||
(export "m" (core module (export "g" (global i32))))
|
||||
))
|
||||
|
||||
(module $m3
|
||||
(core module $m3
|
||||
(global (export "g") i32 i32.const 3)
|
||||
)
|
||||
|
||||
(export "m1" (module $m1))
|
||||
(export "m2" (module $src "m"))
|
||||
(export "m3" (module $m3))
|
||||
(export "m1" (core module $m1))
|
||||
(export "m2" (core module $src "m"))
|
||||
(export "m3" (core module $m3))
|
||||
)
|
||||
|
||||
(component
|
||||
(type $modulety (module (export "g" (global i32))))
|
||||
(core type $modulety (module (export "g" (global i32))))
|
||||
(import "reexport" (instance $reexport
|
||||
(export "m1" (module (type $modulety)))
|
||||
(export "m2" (module (type $modulety)))
|
||||
(export "m3" (module (type $modulety)))
|
||||
(export "m1" (core module (type $modulety)))
|
||||
(export "m2" (core module (type $modulety)))
|
||||
(export "m3" (core module (type $modulety)))
|
||||
))
|
||||
|
||||
(module $assert_ok
|
||||
(core module $assert_ok
|
||||
(import "m1" "g" (global $m1 i32))
|
||||
(import "m2" "g" (global $m2 i32))
|
||||
(import "m3" "g" (global $m3 i32))
|
||||
@@ -350,11 +350,11 @@
|
||||
(start $assert_ok)
|
||||
)
|
||||
|
||||
(instance $m1 (instantiate (module $reexport "m1")))
|
||||
(instance $m2 (instantiate (module $reexport "m2")))
|
||||
(instance $m3 (instantiate (module $reexport "m3")))
|
||||
(core instance $m1 (instantiate (module $reexport "m1")))
|
||||
(core instance $m2 (instantiate (module $reexport "m2")))
|
||||
(core instance $m3 (instantiate (module $reexport "m3")))
|
||||
|
||||
(instance (instantiate (module $assert_ok)
|
||||
(core instance (instantiate $assert_ok
|
||||
(with "m1" (instance $m1))
|
||||
(with "m2" (instance $m2))
|
||||
(with "m3" (instance $m3))
|
||||
@@ -364,7 +364,7 @@
|
||||
;; order of imports and exports can be shuffled between definition site and
|
||||
;; use-site
|
||||
(component $provider
|
||||
(module (export "m")
|
||||
(core module (export "m")
|
||||
(import "" "1" (global $i1 i32))
|
||||
(import "" "2" (global $i2 i32))
|
||||
(import "" "3" (global $i3 i32))
|
||||
@@ -413,7 +413,7 @@
|
||||
|
||||
(component
|
||||
(import "provider" (instance $provider
|
||||
(export "m" (module
|
||||
(export "m" (core module
|
||||
(import "" "4" (global i32))
|
||||
(import "" "3" (global i32))
|
||||
(import "" "2" (global i32))
|
||||
@@ -426,18 +426,18 @@
|
||||
))
|
||||
))
|
||||
|
||||
(module $imports
|
||||
(core module $imports
|
||||
(global (export "1") i32 (i32.const 1))
|
||||
(global (export "3") i32 (i32.const 3))
|
||||
(global (export "2") i32 (i32.const 2))
|
||||
(global (export "4") i32 (i32.const 4))
|
||||
)
|
||||
(instance $imports (instantiate (module $imports)))
|
||||
(instance $m (instantiate (module $provider "m")
|
||||
(core instance $imports (instantiate $imports))
|
||||
(core instance $m (instantiate (module $provider "m")
|
||||
(with "" (instance $imports))
|
||||
))
|
||||
|
||||
(module $import_globals
|
||||
(core module $import_globals
|
||||
(import "" "g4" (global $g4 i32))
|
||||
(import "" "g3" (global $g3 i32))
|
||||
(import "" "g2" (global $g2 i32))
|
||||
@@ -473,5 +473,5 @@
|
||||
(start $assert_imports)
|
||||
)
|
||||
|
||||
(instance (instantiate (module $import_globals) (with "" (instance $m))))
|
||||
(core instance (instantiate $import_globals (with "" (instance $m))))
|
||||
)
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
(component)
|
||||
|
||||
(component
|
||||
(module)
|
||||
(core module)
|
||||
)
|
||||
|
||||
(component
|
||||
(module)
|
||||
(module)
|
||||
(module)
|
||||
(core module)
|
||||
(core module)
|
||||
(core module)
|
||||
)
|
||||
|
||||
(component
|
||||
(module
|
||||
(core module
|
||||
(func (export "a") (result i32) i32.const 0)
|
||||
(func (export "b") (result i64) i64.const 0)
|
||||
)
|
||||
(module
|
||||
(core module
|
||||
(func (export "c") (result f32) f32.const 0)
|
||||
(func (export "d") (result f64) f64.const 0)
|
||||
)
|
||||
|
||||
@@ -52,7 +52,8 @@
|
||||
(type $empty (func))
|
||||
(type (func (param string) (result u32)))
|
||||
(type (component))
|
||||
(type (module))
|
||||
(core type (module))
|
||||
(core type (func))
|
||||
(type (instance))
|
||||
|
||||
(type (component
|
||||
@@ -62,7 +63,7 @@
|
||||
|
||||
(type $t (instance))
|
||||
|
||||
(export "a" (module))
|
||||
(export "a" (core module))
|
||||
(export "b" (instance (type $t)))
|
||||
))
|
||||
|
||||
@@ -73,11 +74,11 @@
|
||||
|
||||
(type $t (instance))
|
||||
|
||||
(export "a" (module))
|
||||
(export "a" (core module))
|
||||
(export "b" (instance (type $t)))
|
||||
))
|
||||
|
||||
(type (module
|
||||
(core type (module
|
||||
(import "" "" (func (param i32)))
|
||||
(import "" "1" (func (result i32)))
|
||||
(export "1" (global i32))
|
||||
|
||||
Reference in New Issue
Block a user