wasm3 icon indicating copy to clipboard operation
wasm3 copied to clipboard

API for import kind: global, memory, table?

Open coderzh opened this issue 5 years ago • 3 comments

Hi, I know there is a function m3_LinkRawFunction to link an import function. But how can I link an import global, memory and table?

BTW, wasm3 is awesome! many thanks!

coderzh avatar Feb 24 '20 15:02 coderzh

Thanks! The API at this point is rather minimal. As you've discovered, there is missing functionality for connecting to the outside world.

soundandform avatar Feb 27 '20 01:02 soundandform

m3_SetGlobal, m3_GetGlobal API was added

vshymanskyy avatar Apr 08 '21 15:04 vshymanskyy

Is there any new thinking on this issue? I understand m3_SetGlobal and m3_GetGlobal were added, but the actual memory is not shared. So if the wasm3 consumer is trying to share this global (or if it is shared across modules), it seems like the consumer would have to try to keep multiple copies of the data/memory in sync. It might be conceptually correct that the synchronization only needs to happen when crossing the boundary between the consuming native code and the wasm code, but that would mean both on wasm function returns and also wasm calls into the native hosting code, and the consuming code wouldn't know what globals were mutated by the wasm code so presumably the consuming code would have to copy the global values in all of these cases of crossing the boundary.

Is there a better way to deal with this now, or any plans to improve this? If changes to wasm3 are needed for this, is it as simple as allowing the global to have a pointer to an external 32/64 bit piece of memory (rather than the M3Global struct owning the memory)?

ryantrem avatar Sep 27 '22 23:09 ryantrem