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

wasm memory not exported ? #24

Open
zonghaishang opened this issue Apr 14, 2021 · 3 comments
Open

wasm memory not exported ? #24

zonghaishang opened this issue Apr 14, 2021 · 3 comments

Comments

@zonghaishang
Copy link

Currently, data transfer is dependent on wasm's linear memory, but jwebassembly is not exported. Is it currently not supported?

  • memory[0] -> "memory"

I found out that both tinygo and teavm include memory export.

@Horcrux7
Copy link
Member

JWebAssembly does not used linear memory for data access. It is written for a GC. The linear memory contains only the class descriptions, string constants, etc. The program code that are not machine instructions.

@zonghaishang
Copy link
Author

JWebAssembly does not used linear memory for data access. It is written for a GC. The linear memory contains only the class descriptions, string constants, etc. The program code that are not machine instructions.

Maybe I don’t understand it correctly, I found that the webassembly specification should include the memory section:
https://webassembly.github.io/spec/core/binary/modules.html#binary-memsec

At present, the exchange of complex types of data and the host can only be passed through the linear memory of wasm.
https://github.com/mosn/mosn/blob/ebd131fbfb2c6eae7d0926ee305ecdeba194e348/pkg/wasm/runtime/wasmer/instance.go#L363

@Horcrux7
Copy link
Member

Maybe I don’t understand it correctly, I found that the webassembly specification should include the memory section:
https://webassembly.github.io/spec/core/binary/modules.html#binary-memsec

It can contain a memory section. It is optional. JWebAssembly use also a memory section but only for it internal data.

At present, the exchange of complex types of data and the host can only be passed through the linear memory of wasm.
https://github.com/mosn/mosn/blob/ebd131fbfb2c6eae7d0926ee305ecdeba194e348/pkg/wasm/runtime/wasmer/instance.go#L363

Via memory section you can only share pointers in a byte array. If your complex types are bytes in linear memory like in languages like C++ then this is valid. Java das not work with linear memory. The underlying memory manager of the VM can work with it. But this is a layer that JWebAssembly will not implement.

The target of JWebAssembly is the usage of a GC and there complex object will be share by reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants