[whatwg] Proposal for separating script downloads and execution

Bjoern Hoehrmann derhoermi at gmx.net
Thu Feb 10 14:09:22 PST 2011

* Boris Zbarsky wrote:
>On 2/10/11 3:23 PM, Bjoern Hoehrmann wrote:
>> There are multiple phases between receiving bytes on the wire and having
>> executed the code they represent. Parsing would seem unlikely to be the
>> main problem here (parsing is mainly checking for syntax errors while or
>> after removing the character encoding from the bytes received)
>And constructing whatever output model (AST, bytecode, whatever) your 
>parser produces.

I can grant you persisting information about the structure to some point
but generating byte code is not the job of the parser, that's what code
generators are for. It's not uncommon however to persist only minimal
information and extract structure only as needed. Perl's URI parser for
instance does that which is a sound optimization there.

>Based on my profiles of script loading and execution in Spidermonkey, 
>parsing _is_ in fact pretty expensive (very commonly much more expensive 
>than the initial execution for large scripts, since most of the script 
>is cold).

Yes, but it's a long way from there to saying that "parsing" must be a-
voided because parsing is inherently slow. As it becomes more common to
load very large libraries where you don't actually use most things, or
use them only much later, it may also be that your "parser" simply does
too much work up-front. I have no idea, I just don't think saying we
should not look at individual factors in finding a proper optimization
is the best approach.
Björn Höhrmann · mailto:bjoern at hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

More information about the whatwg mailing list