Closed edvakf closed 3 years ago
Yeah I know, the memory API isn't perfect right now, but we are not in the 1.* branch yet, so we are free to change it. Behind the scene, the runtime supports multiple memory, but we only read the first one if any. Using instance.exports.memory
is indeed an interesting API.
The new API proposed in #48 is now the following:
instance.exports.<export name>
<export name>
is the name of the export, whatever it is, a Function
, a Memory
, a Global
or a Table
. Problem solved then!
Summary
At the current version of WebAssembly, an instance has at most one memory instance, but it may not be true in the future.
If there are more than one memory, the interface of
instance.memory
will not be the best interface.Additional details
http://webassembly.github.io/spec/core/syntax/modules.html#syntax-mem
Just for your information, the memory is exposed to the JavaScript API through
exportsObject
, ie.instance.exports.mem1
.https://webassembly.github.io/spec/js-api/#dom-module-exports