Fix an issue in adapter module partitioning (#4622)
When an adapter module depends on a particular core wasm instance this means that it actually depends on not only that instance but all prior core wasm instances as well. This is because core wasm instances must be instantiated in the specified order within a component and that cannot change depending on the dataflow between adapters. This commit fixes a possible panic from linearizing the component dfg where an adapter module tried to depend on an instance that hadn't been instantiated yet because the ordering dependency between core wasm instances hadn't been modeled.
This commit is contained in:
@@ -1393,3 +1393,44 @@
|
||||
)
|
||||
(instance (instantiate $c2 (with "" (instance $c1))))
|
||||
)
|
||||
|
||||
;; Adapters are used slightly out-of-order here to stress the internals of
|
||||
;; dependencies between adapters.
|
||||
(component
|
||||
(core module $m
|
||||
(func (export "execute"))
|
||||
(func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
|
||||
(memory (export "memory") 1)
|
||||
)
|
||||
|
||||
(component $root
|
||||
(core instance $m (instantiate $m))
|
||||
(func (export "execute")
|
||||
(canon lift (core func $m "execute"))
|
||||
)
|
||||
)
|
||||
(component $c
|
||||
(import "backend" (instance $i
|
||||
(export "execute" (func))
|
||||
))
|
||||
(core module $shim2 (import "" "0" (func)))
|
||||
(core instance $m (instantiate $m))
|
||||
|
||||
;; This adapter, when fused with itself on the second instantiation of this
|
||||
;; component, will dependend on the prior instance `$m` so it which means
|
||||
;; that the adapter module containing this must be placed in the right
|
||||
;; location.
|
||||
(core func $execute
|
||||
(canon lower (func $i "execute") (memory $m "memory") (realloc (func $m "realloc")))
|
||||
)
|
||||
(core instance (instantiate $shim2
|
||||
(with "" (instance
|
||||
(export "0" (func $execute))
|
||||
))
|
||||
))
|
||||
(func (export "execute") (canon lift (core func $m "execute")))
|
||||
)
|
||||
(instance $root (instantiate $root))
|
||||
(instance $c1 (instantiate $c (with "backend" (instance $root))))
|
||||
(instance $c2 (instantiate $c (with "backend" (instance $c1))))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user