wwwg/wasmdec

WebAssembly Spec compliance for instructions

Opened this issue · 0 comments

binji commented

Hi, I just saw your project on WasmWeekly! I worked on something similar here, and there's a wasm-to-rust converter here too that you may be interested in.

One thing I noticed is that you aren't currently handling traps. It will be hard to pass the WebAssembly spec testsuite without those.

There are some instructions that have subtle behaviors as well; in particular, most of the floating point instructions map to C instructions or math functions, but min/max have different behavior with NaNs. I've also found that MSVC on 64-bit architectures will be slightly off for some values on the uint64-to-float and uint64-to-double conversions. Another thing to watch out for: WebAssembly doesn't work properly with x87 floating point instructions, and requires SSE2 instructions instead. This mostly only becomes an issue on MSVC for 32-bit architectures where the calling convention still may pass floating point values using x87 registers even when you enable SSE2. You can use the __vectorcall calling convention to work around that.

The spec tests will cover most of these behaviors. They're written using the .wast testing format, including assertions and multiple modules. You can use wabt's wast2json tool to convert them to a single JSON file of assertions with a .wasm files for each module.