Get the latest tech news
Compilation of JavaScript to WASM, Part 2: Ahead-of-Time vs. JIT
uation of my “fast JS on Wasm” series; the first post covered PBL, a portable interpreter that supports inline caches, this post adds ahead-of-time compilation, and the final post will discuss the details of that ahead-of-time compilation. Please read the first post first for useful context! The most popular programming language in the world, by a wide margin – thanks to the ubiquity of the web – is JavaScript (or, if you prefer to follow international standards, ECMAScript per ECMA-262).
Well, not necessarily: it turns out that computers are great at automating boring tasks, and we could simply collect all ICs ever generated during a bunch of JavaScript execution (say, the entire testsuite for SpiderMonkey) and build them in. Fortunately, this is now the easiest part: we do a mostly 1-to-1 translation of JS source to code that consists of a series of IC sites, invoking the current IC-stub pointer for each operator instance in turn. If you do indeed wonder this, then you’ll love the upcoming part 3 of this series, where I describe how we can derive these compiler backends automatically from the interpreters, reducing maintenance burden and complexity significantly.
Or read this on Hacker News