danleh / wasabi

A dynamic analysis framework for WebAssembly programs.
http://wasabi.software-lab.org
MIT License
366 stars 48 forks source link

Wasm with MultiValue Proposal #35

Closed michelledaviest closed 1 year ago

michelledaviest commented 2 years ago

Hello!

I implemented the Multi Value Proposal for Wasm, so Blocks, Loops and IfThenElse refer to FunctionTypes rather than BlockTypes.

All tests pass except that the produced .wasm file does not pass validation, ie, wasm-validate errors with the following message: error: expected valid block signature type. I spent a lot of time looking into this but couldn't pin point the problem exactly.

It's possible that the FunctionType that is the BlockType is not already present in the type section. This is the case while parsing and I added a few FIXME's that were design decisions that you might want a say in: (https://github.com/michelledaviest/wasabi/blob/master/crates/wasabi_wasm/src/ast.rs#L1759) and (https://github.com/michelledaviest/wasabi/blob/master/crates/wasabi_wasm/src/parse.rs#L1179).

However, while encoding the AST as a valid Wasm file, the new types are being added into the type section before the types are encoded, and the new BlockTypes refer to the correct FunctionTypes. So, I don't really understand why this is failing.

I'll look at it again a bit late, but this is my progress so far! :)

Thanks, Michelle.