Skip to content

wasm memory not exported ? #24

Open

Description

@zonghaishang

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.

Activity

  1. Horcrux7 commented on Apr 14, 2021

    @Horcrux7
    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.

  2. zonghaishang commented on Apr 15, 2021

    @zonghaishang
    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

  3. Horcrux7 commented on Apr 15, 2021

    @Horcrux7
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions