Skip to content

Load/run WASM created with wit-bindgen #5

@Manuthor

Description

@Manuthor

Hello!

I am interested by loading in Java a WebAssembly created using the crate wit_bindgen. Actually I was looking for the Java bindings for this but I could not find any related project. As you probably already know, having this would allow to have a common WASM loaded by different languages (Python, Java, C, etc.).

I run your project wasmtime-java (and thanks for this) with a wit-bindgen generated WASM but I encounter 2 problems:

  • this first problem deals with the de/allocation functions: for wasmtime-java, the WASM file needs to have the 2 exported functions __alloc_bytes and __dealloc_bytes). Even this is not ideal, I temporarly added these functions (of course it would be better to use the existing wit-bindgen allocation functions)
  • the second problem occurs when function-signature (in WASM) looks like fn my_function(input: Vec<u8>) -> Vec<u8>. I cannot find a way to load the return value. I confirm that I can "see" the expected result in the WASM memory but I dont understand how to find the correct offset of this result in memory (and the related result size in bytes). The offset returned by the function call (which is correct) does not match the good offset of the result.

Could I ask your opinion about this?
Thanks!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions