Especialização especulativa de valores baseada em parâmetros - Igor Rafael de Assis Costa (2013)
JavaScript emerges today as one of the most important programming languages for the development of client-side web applications. Therefore, it is essential that browsers be able to execute JavaScript programs efficiently. However, the dynamic nature of this programming language makes it very challenging to achieve this much needed efficiency. The just-in-time compiler seems to be the current weapon of choice that developers use to face these challenges. In this work we propose Parameter-based Speculative Value Specialization as a way to improve the quality of the code produced by JIT engines. We have empirically observed that almost 60% of the JavaScript functions found in the worlds 100 most popular websites are called only once, or are called with the same parameters. Capitalizing on this observation, we adapt several classic compiler optimizations to specialize code based on the run-time values of functions actual parameters. We have implemented the techniques proposed in this work in IonMonkey, an industrial quality JavaScript JIT compiler developed in the Mozilla Foundation. Our experiments, run across three popular JavaScript benchmarks, SunSpider, V8 and Kraken, show that, in spite of its highly speculative nature, our optimization pays for itself. As an example, we have been able to speedup the V8 benchmark by 4.83%, and to reduce the size of its native code by 18.84%.