HAYCORN — 19 July 2011

State-of-the-art JS compilers: no bytecode, no intermediate representation other than source

A brief note; something I discovered recently found surprising: JavaScript compilers, which these days end up essentially compiling the same source code into machine code multiple times (the same function might sometimes take ints and sometimes take floats, for example), do it by going back to the source code and re-parsing the source. In particular, they don’t start from an intermediate representation like an AST or bytecode. This applies both the v8 and Firefox. (Actually it’s not clear that Firefox actually operates this way, but Eich says that it could.) I wonder if they have essentially two versions of the parser, one for unverified source code (better debugging information, but slower) and another for source code known to be syntactically correct? And what does this mean for Parrot?