3 ms·
If you're distributing an executable (not a library), you can just AOT compile the generated wasm to machine code. For example, the WasmExplorer already lets y
by icebraining 7y ago
If you're distributing an executable (not a library), you can just AOT compile the generated wasm to machine code.
For example, the WasmExplorer already lets you compile C++ -> wasm -> x86 assembly: https://mbebenita.github.io/WasmExplorer/?state=%7B%22options%22%3A%7B%22showGutter%22%3Atrue%2C%22showConsole%22%3Atrue%2C%22showOptions%22%3Atrue%2C%22autoCompile%22%3Atrue%2C%22showLLVM%22%3Afalse%2C%22darkMode%22%3Atrue%2C%22fastMath%22%3Afalse%2C%22noInline%22%3Afalse%2C%22noRTTI%22%3Afalse%2C%22noExceptions%22%3Afalse%2C%22cleanWast%22%3Afalse%2C%22wasmBaseline%22%3Afalse%2C%22dialect%22%3A%22C%2B%2B11%22%2C%22optimizationLevel%22%3A%22s%22%7D%2C%22source%22%3A%22int%20testFunction(int*%20input%2C%20int%20length)%20%7B%5Cn%20%20int%20sum%20%3D%200%3B%5Cn%20%20for%20(int%20i%20%3D%200%3B%20i%20%3C%20length%3B%20%2B%2Bi)%20%7B%5Cn%20%20%20%20sum%20%2B%3D%20input%5Bi%5D%3B%5Cn%20%20%7D%5Cn%20%20return%20sum%3B%5Cn%7D%22%7D https://mbebenita.github.io/WasmExplorer/?state=%7B%22option...
- the8472 7y agoI doubt you get the same performance as direct compilation. LLVM ir carries lots of annotations useful to optimizing passes, e.g. aliasing information.
- sunfish 7y agoThe twist is, you can produce wasm from LLVM, including running the full mid-level optimizer first, which is the part of LLVM where those annotations and aliasing information are most valuable.
- bpye 7y agoIf this turns out to be useful then what's stopping us adding similar annotations in a custom section for Webassembly?