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.
122 lines
2.4 KiB
Plaintext
122 lines
2.4 KiB
Plaintext
(component
|
|
(core module $m)
|
|
(core instance (instantiate $m))
|
|
)
|
|
|
|
(component
|
|
(core module $m
|
|
(func (export ""))
|
|
)
|
|
(core instance $i (instantiate $m))
|
|
|
|
(core module $m2
|
|
(func (import "" ""))
|
|
)
|
|
(core instance (instantiate $m2 (with "" (instance $i))))
|
|
)
|
|
|
|
(component
|
|
(core module $m
|
|
(func (export "a"))
|
|
)
|
|
(core instance $i (instantiate $m))
|
|
|
|
(core module $m2
|
|
(func (import "" "b"))
|
|
)
|
|
(core instance (instantiate $m2
|
|
(with "" (instance (export "b" (func $i "a"))))
|
|
))
|
|
)
|
|
|
|
;; all kinds of imports for core wasm modules, and register a start function on
|
|
;; one module to ensure that everything is correct
|
|
(component
|
|
(core module $m
|
|
(func (export "a"))
|
|
(table (export "b") 1 funcref)
|
|
(memory (export "c") 1)
|
|
(global (export "d") i32 i32.const 1)
|
|
)
|
|
(core instance $i (instantiate $m))
|
|
|
|
(core module $m2
|
|
(import "" "a" (func $f))
|
|
(import "" "b" (table 1 funcref))
|
|
(import "" "c" (memory 1))
|
|
(import "" "d" (global $g i32))
|
|
|
|
(func $start
|
|
global.get $g
|
|
i32.const 1
|
|
i32.ne
|
|
if
|
|
unreachable
|
|
end
|
|
|
|
call $f
|
|
)
|
|
|
|
(start $start)
|
|
|
|
(data (i32.const 0) "hello")
|
|
(elem (i32.const 0) $start)
|
|
)
|
|
(core instance (instantiate $m2
|
|
(with "" (instance $i))
|
|
))
|
|
)
|
|
|
|
;; double-check the start function runs by ensuring that a trap shows up and it
|
|
;; sees the wrong value for the global import
|
|
(assert_trap
|
|
(component
|
|
(core module $m
|
|
(global (export "g") i32 i32.const 1)
|
|
)
|
|
(core instance $i (instantiate $m))
|
|
|
|
(core module $m2
|
|
(import "" "g" (global $g i32))
|
|
|
|
(func $start
|
|
global.get $g
|
|
i32.const 0
|
|
i32.ne
|
|
if
|
|
unreachable
|
|
end
|
|
)
|
|
|
|
(start $start)
|
|
)
|
|
(core instance (instantiate $m2 (with "" (instance $i))))
|
|
)
|
|
"unreachable")
|
|
|
|
;; shuffle around imports to get to what the target core wasm module needs
|
|
(component
|
|
(core module $m
|
|
(func (export "1"))
|
|
(table (export "2") 1 funcref)
|
|
(memory (export "3") 1)
|
|
(global (export "4") i32 i32.const 1)
|
|
)
|
|
(core instance $i (instantiate $m))
|
|
|
|
(core module $m2
|
|
(import "" "a" (func $f))
|
|
(import "" "b" (table 1 funcref))
|
|
(import "" "c" (memory 1))
|
|
(import "" "d" (global $g i32))
|
|
)
|
|
(core instance (instantiate $m2
|
|
(with "" (instance
|
|
(export "a" (func $i "1"))
|
|
(export "b" (table $i "2"))
|
|
(export "c" (memory $i "3"))
|
|
(export "d" (global $i "4"))
|
|
))
|
|
))
|
|
)
|