High level problem:
I have a piece of Rust code that is compiled to wasm32 and running in the browser.
Inside the browser, I want to generate wasm32 code on the fly, and call it, passing it float* or int*
Previously, there were claims that this is not possible due to wasm32 not being designed for jit / dynamic code generation.
However, if I'm reading https://stackoverflow.com/questions/54348108/is-it-possible-to-do-dynamic-linking-in-webassembly-with-rust correctly, the following is possible:
4a. from rust running in browser/wasm32: generate some wast/wasm32 on the fly
4b. load the wasm32 module, sharing the 'address space' (i.e. something like a dlopen)
4c. call functions in the new module
If the above is true, does anyone have an example of doing this in Rust ?
Ah, I should clarify, I'm not asking for, at runtime, a "rustc -> wasm" compiler.
I'm asking for a "some restricted set of instructions -> wasm" dynamic code generator. Even a "c -> wasm" or "mips -> wasm" or "sorta x86 -> wasm" would be fine. The part I need is all the glue that takes the wast, loads it as a module, dynamically loads it, and calls the function ...
Searching for 'tiny wasm compiler' I found this https://github.com/maierfelix/mini-c which seems promising, the example https://maierfelix.github.io/mini-c/ does if I understand correctly, exactly what you want.
Definitly doable, but you will have to glue them together with some JS, just like wasm-bindgen allows you to call JS Objects.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.