-
Notifications
You must be signed in to change notification settings - Fork 98
Closed
Description
i'm reading https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md
namely, the example cited below.
if i read it correctly, in the example libc instance exports its memory and main instance imports it.
my understanding is that in that case these modules (Main and Libc) need to have some negotiation about how
the shared memory is used. (eg. where to put their string literals)
i couldn't find any mechanism for such a negotiation. is there something i'm missing?
(component
(import "wasi:logging" (instance $logging
(export "log" (func (param string)))
))
(import "libc" (core module $Libc
(export "mem" (memory 1))
(export "realloc" (func (param i32 i32) (result i32)))
))
(core instance $libc (instantiate $Libc))
(core func $log (canon lower
(func $logging "log")
(memory (core memory $libc "mem")) (realloc (func $libc "realloc"))
))
(core module $Main
(import "libc" "memory" (memory 1))
(import "libc" "realloc" (func (param i32 i32) (result i32)))
(import "wasi:logging" "log" (func $log (param i32 i32)))
(func (export "run") (param i32 i32) (result i32 i32)
... (call $log) ...
)
)
(core instance $main (instantiate $Main
(with "libc" (instance $libc))
(with "wasi:logging" (instance (export "log" (func $log))))
))
(func $run (param string) (result string) (canon lift
(core func $main "run")
(memory $libc "mem") (realloc (func $libc "realloc"))
))
(export "run" (func $run))
)
Metadata
Metadata
Assignees
Labels
No labels