Run LLVM Assembly In Your Browser

This is a demo of compiling and running LLVM assembly in JavaScript.

Press the button to see it compile and run a tiny "hello world" program. You can also try modifying the LLVM assembly and pressing the button again - note though that LLVM assembly is typed, so if you add characters to the string for example, you will need to adjust its length, both where it is defined and where it is used (otherwise you will get errors, which will show up in the output area).

This demo works by using parts of the LLVM toolchain (llvm-dis and llvm-as), compiled by emscripten from C++ to JavaScript, to check the assembly for errors and pretty-print it. Then the emscripten compiler (originally written in JavaScript, but ported from the normal batch/shell mode to the browser environment) is run on the output, and the code executed directly.

This demo was done as a fun hacking project over a holiday vacation, so there are some caveats: The generated code is not optimized at all, so benchmarking is pointless; if you want to benchmark, run emscripten normally with -O2. Compilation speed has also not been optimized at all. Also, this demo has hardly been tested and glues together several codebases in ways they were not originally intended, there might be things that do not work.

Source code

Fork me on GitHub