Update support for the module linking proposal
This commit updates the various tooling used by wasmtime which has new updates to the module linking proposal. This is done primarily to sync with WebAssembly/module-linking#26. The main change implemented here is that wasmtime now supports creating instances from a set of values, nott just from instantiating a module. Additionally subtyping handling of modules with respect to imports is now properly handled by desugaring two-level imports to imports of instances. A number of small refactorings are included here as well, but most of them are in accordance with the changes to `wasmparser` and the updated binary format for module linking.
This commit is contained in:
@@ -9,22 +9,36 @@
|
||||
|
||||
(module
|
||||
(import "a" "m" (module))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "" (func))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "a" (func))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "b" (global i32))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module
|
||||
(export "" (func))
|
||||
(export "a" (func))
|
||||
))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module
|
||||
(export "a" (func))
|
||||
(export "" (func))
|
||||
))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module
|
||||
(export "a" (func))
|
||||
(export "" (func))
|
||||
(export "b" (global i32))
|
||||
))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module
|
||||
(export "b" (global i32))
|
||||
(export "a" (func))
|
||||
@@ -37,64 +51,60 @@
|
||||
(module (export "m")
|
||||
(func (export ""))))
|
||||
|
||||
(module
|
||||
(import "a" "m" (module))
|
||||
(import "a" "m" (module (export "" (func))))
|
||||
)
|
||||
(module (import "a" "m" (module)))
|
||||
(module (import "a" "m" (module (export "" (func)))))
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (func (param i32))))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (func (result i32))))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (global i32)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (table 1 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (memory 1)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (module)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (instance)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
|
||||
(module $a
|
||||
(module (export "m")
|
||||
(global (export "") i32 (i32.const 0))))
|
||||
|
||||
;; globals
|
||||
(module
|
||||
(import "a" "m" (module))
|
||||
(import "a" "m" (module (export "" (global i32))))
|
||||
)
|
||||
(module (import "a" "m" (module)))
|
||||
(module (import "a" "m" (module (export "" (global i32)))))
|
||||
(assert_unlinkable
|
||||
(module
|
||||
(import "a" "m" (module (export "" (global (mut i32)))))
|
||||
)
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (global f32)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (func)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (table 1 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (memory 1)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (module)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (instance)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
|
||||
;; tables
|
||||
(module $a
|
||||
@@ -105,40 +115,52 @@
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "" (table 1 funcref))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "" (table 0 funcref))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "max" (table 1 10 funcref))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "max" (table 0 10 funcref))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "max" (table 0 11 funcref))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "max" (table 0 funcref))))
|
||||
)
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (global f32)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (func)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (table 2 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (table 1 10 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "max" (table 2 10 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "max" (table 1 9 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (memory 1)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (module)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (instance)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
|
||||
;; memories
|
||||
(module $a
|
||||
@@ -149,40 +171,52 @@
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "" (memory 1))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "" (memory 0))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "max" (memory 1 10))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "max" (memory 0 10))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "max" (memory 0 11))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "max" (memory 0))))
|
||||
)
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (global f32)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (func)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (table 1 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (memory 2)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (memory 1 10)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "max" (memory 2 10)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "max" (memory 2)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (module)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (instance)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
|
||||
;; modules
|
||||
(module $a
|
||||
@@ -206,72 +240,102 @@
|
||||
)
|
||||
;; import a mixture
|
||||
(module (export "e")
|
||||
(import "" (func))
|
||||
(import "" (func))
|
||||
(import "" (global i32))
|
||||
(import "a" (func))
|
||||
(import "b" (func))
|
||||
(import "c" (global i32))
|
||||
)
|
||||
)
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "a" (module))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "b" (module))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "b" (module (export "" (func))))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "c" (module))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "c" (module
|
||||
(export "a" (func))
|
||||
))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "c" (module
|
||||
(export "a" (func))
|
||||
(export "b" (func (result i32)))
|
||||
))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "c" (module
|
||||
(export "c" (global i32))
|
||||
))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "c" (module
|
||||
(export "c" (global i32))
|
||||
(export "a" (func))
|
||||
))))
|
||||
|
||||
;; for now import strings aren't matched at all, imports must simply pairwise
|
||||
;; line up
|
||||
(import "a" "m" (module (export "d" (module (import "" (func))))))
|
||||
(import "a" "m" (module (export "d" (module (import "x" (func))))))
|
||||
(import "a" "m" (module (export "d" (module (import "x" "y" (func))))))
|
||||
|
||||
(import "a" "m" (module (export "e" (module
|
||||
(import "x" "y" (func))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "d" (module
|
||||
(import "" (func))
|
||||
(import "a" (func))
|
||||
(import "z" (global i32))
|
||||
))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "d" (module (import "" (func))))))
|
||||
)
|
||||
(assert_unlinkable
|
||||
(module
|
||||
(import "a" "m" (module (export "d" (module (import "x" (func))))))
|
||||
)
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module
|
||||
(import "a" "m" (module (export "d" (module (import "x" "y" (func))))))
|
||||
)
|
||||
"incompatible import type for `a`")
|
||||
(module
|
||||
(import "a" "m" (module (export "e" (module
|
||||
(import "a" (func))
|
||||
(import "b" (func))
|
||||
(import "c" (global i32))
|
||||
))))
|
||||
)
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (module (export "a" (func)))))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "d" (module)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "d" (module (import "" (module)))))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (global f32)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (func)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (table 1 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (memory 2)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (module (export "foo" (func)))))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (instance)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
|
||||
;; instances
|
||||
(module $a
|
||||
@@ -303,46 +367,65 @@
|
||||
)
|
||||
(module
|
||||
(import "a" "a" (instance))
|
||||
)
|
||||
(module
|
||||
(import "a" "b" (instance))
|
||||
)
|
||||
(module
|
||||
(import "a" "b" (instance (export "" (func))))
|
||||
)
|
||||
(module
|
||||
(import "a" "c" (instance))
|
||||
)
|
||||
(module
|
||||
(import "a" "c" (instance (export "a" (func))))
|
||||
)
|
||||
(module
|
||||
(import "a" "c" (instance (export "b" (func (result i32)))))
|
||||
)
|
||||
(module
|
||||
(import "a" "c" (instance (export "c" (global i32))))
|
||||
)
|
||||
(module
|
||||
(import "a" "c" (instance
|
||||
(export "a" (func))
|
||||
(export "b" (func (result i32)))
|
||||
(export "c" (global i32))
|
||||
))
|
||||
)
|
||||
(module
|
||||
(import "a" "c" (instance
|
||||
(export "c" (global i32))
|
||||
(export "a" (func))
|
||||
))
|
||||
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "i" (instance))))
|
||||
)
|
||||
(module
|
||||
(import "a" "m" (module (export "i" (instance (export "" (func))))))
|
||||
)
|
||||
(assert_unlinkable
|
||||
(module (import "a" "a" (instance (export "" (global f32)))))
|
||||
"instance types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "i" (instance (export "x" (func)))))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (func)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (table 1 funcref)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (memory 2)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (memory 1 10)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "max" (memory 2 10)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
(assert_unlinkable
|
||||
(module (import "a" "m" (module (export "" (module)))))
|
||||
"module types incompatible")
|
||||
"incompatible import type for `a`")
|
||||
|
||||
Reference in New Issue
Block a user