Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instance.memory may cause a (small) problem in the future #18

Closed
edvakf opened this issue Jun 18, 2019 · 2 comments
Closed

instance.memory may cause a (small) problem in the future #18

edvakf opened this issue Jun 18, 2019 · 2 comments
Assignees
Labels
❓ question Further information is requested

Comments

@edvakf
Copy link
Contributor

edvakf commented Jun 18, 2019

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

In the current version of WebAssembly, at most one memory may be defined or imported in a single module, and all constructs implicitly reference this memory 0. This restriction may be lifted in future versions.

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

@edvakf edvakf added the ❓ question Further information is requested label Jun 18, 2019
@Hywan
Copy link
Contributor

Hywan commented Jun 21, 2019

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.

@Hywan Hywan self-assigned this Jun 21, 2019
@Hywan
Copy link
Contributor

Hywan commented May 11, 2021

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!

@Hywan Hywan closed this as completed May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants