kawamuray / wasmtime-java

Java or JVM-language binding for Wasmtime
Apache License 2.0
127 stars 29 forks source link

Is there a MemoryInterop example with C++ #48

Open lanny886 opened 1 year ago

lanny886 commented 1 year ago

I generate .wasm from cpp with emcc , pass malloc address to java, but can not read value by ByteBuffer, also can not modify value by ByteBuffer when read value in c++ later. By the way, when pass const char* address to java, can read value correctly.

kawamuray commented 1 year ago

wasm module/runtime can read/write from/to linear memory only https://wasmbyexample.dev/examples/webassembly-linear-memory/webassembly-linear-memory.rust.en-us.html so maybe the address you're passing around isn't valid in that regard. Anyway, without more information provided there's too many possibilities to guess. One thing you can do is to try running your wasm module using wasmtime command directly, and if it still fails that is a problem of either wasntime runtime or your compiled wasm module.