mincaml icon indicating copy to clipboard operation
mincaml copied to clipboard

Wasm backend TODOs

Open osa1 opened this issue 1 year ago • 0 comments

In the Wasm backend we compile the runtime system to Wasm with emcc and then link it with the mc-generated Wasm.

It seems to mostly work fine, except linking the element sections is tricky, because moving an element in the table means we have to update its index in the code, and there is not special instructions for pushing an element index to the stack, it's just i32.const.

We should refactor the code a little bit and keep track of all the element index locations in the code so that we can update them when linking.

I think it might also make sense to generate wasm_syntax AST (instead of Wasm encoding of the module) in the code generator. Currently we generate Wasm binary, and then directly decode it using wasm_syntax for linking. We can avoid the decoding step.

osa1 avatar Sep 25 '22 08:09 osa1