2 ms·
If you want to compile the code as-is, then wabt is the most straightforward tool for that (specifically wast2wasm). If you want to also optimize the code, the
by azakai 10y ago
If you want to compile the code as-is, then wabt is the most straightforward tool for that (specifically wast2wasm).
If you want to also optimize the code, then binaryen can do both (wasm-opt to optimize, wasm-as to convert to binary).
Since this is for a compiler backend, then the optimizations are probably relevant for you.
- reitzensteinm 10y agoSorry, I wasn't clear, I mean run the entire thing in the browser, to make it interactive. Since Chrome apparently supports the text format as a way to view the binary, I was hoping that it would support a two way process. However, from searching around, it looks like I'll have to emit bytecode directly, at least for the near future. Which isn't the end of the world I guess!
- azakai 10y agoOh I see, sorry for misunderstanding. Yeah, I think it would have been nice to have text format input support in browsers, but the decision was against that. But you do have other options than emitting binary wasm yourself. You can use a compiled version of wabt or binaryen, here's an example of binaryen.js, https://github.com/WebAssembly/binaryen/blob/master/test/binaryen.js/test.js https://github.com/WebAssembly/binaryen/blob/master/test/bin... edit: actually it looks like the test doesn't cover WasmBinaryWriter, which is what would be needed for this, we should improve that
- binji 10y agoHere's the emscripten-compiled wast2wasm (from wabt): https://cdn.rawgit.com/WebAssembly/wabt/2baa1ecb0b36bea6268c52ea49246aafbed05f02/demo/index.html https://cdn.rawgit.com/WebAssembly/wabt/2baa1ecb0b36bea6268c... It uses the code from here: https://github.com/WebAssembly/wabt/tree/master/demo https://github.com/WebAssembly/wabt/tree/master/demo