Emscripten: an LLVM-to-JavaScript compiler

We present Emscripten, a compiler from LLVM (Low Level Virtual Machine) assembly to JavaScript. This opens up two avenues for running code written in languages other than JavaScript on the web: (1) Compile code directly into LLVM assembly, and then compile that into JavaScript using Emscripten, or (2) Compile a language's entire runtime into LLVM and then JavaScript, as in the previous approach, and then use the compiled runtime to run code written in that language. For example, the former approach can work for C and C++, while the latter can work for Python; all three examples open up new opportunities for running code on the web. Emscripten itself is written in JavaScript and is available under the MIT license (a permissive open source license), at http://www.emscripten.org. As a compiler from LLVM to JavaScript, the challenges in designing Emscripten are somewhat the reverse of the norm - one must go from a low-level assembly into a high-level language, and recreate parts of the original high-level structure of the code that were lost in the compilation to low-level LLVM. We detail the methods used in Emscripten to deal with those challenges, and in particular present and prove the validity of Emscripten's Relooper algorithm, which recreates high-level loop structures from low-level branching data.

author = {Zakai, Alon},
year = {2011},
month = {10},
pages = {301-312},
title = {Emscripten: an LLVM-to-JavaScript compiler},
doi = {10.1145/2048147.2048224}


Just test notes. Emscripten is obviously a powerful web technology and in a asense the first major effort at cross compiling systems languages for the web. Of course, JS isn't exactly a great compilation target and so we want to consider WASM.