06
The Engine Wars
For ten years, from the late nineties to the mid-2000s, the JavaScript engines in browsers barely changed. According to Wirfs-Brock and Eich, the design of SpiderMonkey at Netscape and Mozilla and of JScript at Microsoft stayed the same all that time, and if programs ran faster, it was only because processors got faster. For most of that period the engine in a browser was looked after by one person, and not even full-time. Nobody minded, because JavaScript was used for button handlers, and a button handler has no use for speed.
People started to mind when mail, maps and office documents moved into the browser. By 2006–2007 web developers were complaining about speed louder and louder, and browser makers began assembling real teams for their engines. To speed something up you need to be able to measure it, and in 2007 the WebKit team at Apple released the SunSpider benchmark suite. Its tests were small but taken from the code of real web applications. Very soon developers all over the world were comparing browsers by their SunSpider scores, and browsers, which under the rules of this game could not compete on new language features, began to compete on speed.
In 2008 three new engines entered this market almost at once, and each answered in its own way the question of how to run fast a language without classes or declared types. At WebKit they first rewrote the interpreter, and in September released SquirrelFish Extreme, which added compilation to machine code and techniques borrowed from Self and from fast Lua implementations. Google decided to do without an interpreter altogether and compile everything straight to machine code, relying on hidden classes: that was V8. The most unusual bet was made by Mozilla.
In August 2008 Brendan Eich announced on his blog TraceMonkey, an engine that Mozilla, together with Andreas Gal from the University of California, Irvine, had put together in about two months based on Gal’s doctoral work. Tracing works like this. An ordinary compiler takes a whole function with all its branches, even the ones the program enters once a year. A tracing compiler watches which path the program actually runs along in a loop that repeats thousands of times, records that path as one straight track with no forks, and compiles only that track. At every turn where the program could go the other way there is a check, and if it fails, the program returns to the interpreter. It is like a courier who knows one route he drives every morning and races along it better than anyone, until a street is closed. On tight computational loops tracing produced fantastic results, and the first TraceMonkey measurements made it look as if Mozilla had overtaken everyone.
Gratis, solo falta un paso
El resto del libro es gratis
Deja tu correo y te mando un enlace para confirmarlo. Después del clic, todos los capítulos se abren aquí, en este dispositivo, durante un año. Cuando salga un libro nuevo, escribiré a esa dirección; responde “basta” a cualquier correo y no vuelvo a escribir.
¿Tienes cuenta INITE? Entra y el libro se abre sin correo.
No se cobra nada por el libro. Si quieres apoyarlo, puedes donar desde cualquier capítulo.
Cómo se guarda la dirección