archives

Emscripten now (sort of) self-hosting

Summarizing from the Emscripten blog, there is a new eliminator pass, a new parallel optimizer, and a new relooper.

The self-hosting part:

Note that this update makes Emscripten a 'self-hosting compiler' in a sense: one of the major optimization passes must be compiled to JS from C++, using Emscripten itself. Since this is an optimization pass, there is no chicken-and-egg problem: We bootstrap the relooper by first compiling it without optimizations, which works because we don't need to reloop there. We then use that unoptimized build of the relooper (which reloops properly, but slowly since it itself is unoptimized) in Emscripten to compile the relooper once more, generating the final fully-optimized version of the relooper, or "relooped relooper" if you will.

Emscripten seems to be quite an undertaking. I'm never sure whether I should be more impressed or more appalled. I started leaning more toward "impressed" when I found out that the Google gmail app (the one you run in your browser) is written in Java, the bytecode then compiled to javascript, and the resulting javascript identifiers rewritten for compression and interpretation efficiency.