Parameter Based Constant Propagation

  • Péricles Rafael Oliveira Alves
  • Igor Rafael de Assis Costa
  • Fernando Magno Quintão Pereira
  • Eduardo Lage Figueiredo
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7554)


JavaScript is nowadays the lingua franca of web browsers. This programming language is not only the main tool that developers have to implement the client side of web applications, but it is also the target of frameworks such as Google Web Toolkit. Given this importance, it is fundamental that JavaScript programs can be executed efficiently. Just-in-time (JIT) compilation is one of the keys to achieve this much necessary efficiency. An advantage that a JIT compiler has over a traditional compiler is the possibility to use runtime values to specialize the target code. In this paper we push JIT speculation to a new extreme: we have empirically observed that many JavaScript functions are called only once during a typical browser section. A natural way to capitalize on this observation is to specialize the code produced by a function to the particular values that are passed to this function as parameters. We have implemented this approach on IonMonkey, the newest JIT compiler used in the Mozilla Firefox browser. By coupling this type of parameter specialization with constant propagation, a classical compiler optimization, we have been able to experimentally observe speedups of up to 25% on well-known algorithms. These gains are even more remarkable because they have been obtained over a worldly known, industrial quality JavaScript runtime environment.


Constant Propagation Activation Record Compiler Optimization Native Code Memory Layout 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Alpern, B., Wegman, M.N., Zadeck, F.K.: Detecting equality of variables in programs. In: POPL, pp. 1–11. ACM (1988)Google Scholar
  2. 2.
    Aycock, J.: A brief history of just-in-time. ACM Computing Surveys 35(2), 97–113 (2003)CrossRefGoogle Scholar
  3. 3.
    Bala, V., Duesterwald, E., Banerjia, S.: Dynamo: A transparent dynamic optimization system. In: PLDI, pp. 1–12. ACM (2000)Google Scholar
  4. 4.
    Bodik, R., Gupta, R., Sarkar, V.: ABCD: Eliminating array bounds checks on demand. In: PLDI, pp. 321–333. ACM (2000)Google Scholar
  5. 5.
    Chaganti, P.: Google Web Toolkit GWT Java AJAX Programming, 1st edn. PACKT (2007)Google Scholar
  6. 6.
    Chambers, C., Ungar, D.: Customization: Optimizing compiler technology for SELF, a dynamically-typed object-oriented programming language. SIGPLAN Not. 24(7), 146–160 (1989)CrossRefGoogle Scholar
  7. 7.
    Chang, M., Smith, E., Reitmaier, R., Bebenita, M., Gal, A., Wimmer, C., Eich, B., Franz, M.: Tracing for web 3.0: Trace compilation for the next generation web applications. In: VEE, pp. 71–80. ACM (2009)Google Scholar
  8. 8.
    Chang, P.P., Mahlke, S.A., Hwu, W.-M.W.: Using profile information to assist classic code optimizations. Software Practice and Experience 21(12), 1301–1321 (1991)CrossRefGoogle Scholar
  9. 9.
    Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Zadeck, F.K.: Efficiently computing static single assignment form and the control dependence graph. TOPLAS 13(4), 451–490 (1991)CrossRefGoogle Scholar
  10. 10.
    Richards, G., Lebresne, S., Burg, B., Vitek, J.: An analysis of the dynamic behavior of JavaScript programs. In: PLDI, pp. 1–12 (2010)Google Scholar
  11. 11.
    Gal, A., Eich, B., Shaver, M., Anderson, D., Kaplan, B., Hoare, G., Mandelin, D., Zbarsky, B., Orendorff, J., Ruderman, J., Smith, E., Reitmair, R., Haghighat, M.R., Bebenita, M., Change, M., Franz, M.: Trace-based just-in-time type specialization for dynamic languages. In: PLDI, pp. 465–478. ACM (2009)Google Scholar
  12. 12.
    Gal, A., Probst, C.W., Franz, M.: HotpathVM: An effective JIT compiler for resource-constrained devices. In: VEE, pp. 144–153 (2006)Google Scholar
  13. 13.
    Gardner, P., Maffeis, S., Smith, G.D.: Towards a program logic for JavaScript. In: POPL, pp. 31–44. ACM (2012)Google Scholar
  14. 14.
    Hackett, B., Guo, S.Y.: Fast and precise hybrid type inference for JavaScript. In: PLDI. ACM (2012)Google Scholar
  15. 15.
    Muchnick, S.S.: Advanced Compiler Design and Implementation. Morgan Kaufmann (1997)Google Scholar
  16. 16.
    Patterson, J.R.C.: Accurate static branch prediction by value range propagation. In: PLDI, pp. 67–78. ACM (1995)Google Scholar
  17. 17.
    Shankland, S.: How JavaScript became a browser-war battleground (2009), (accessed in April 30, 2012)
  18. 18.
    Sol, R., Guillon, C., Pereira, F.M.Q., Bigonha, M.A.S.: Dynamic Elimination of Overflow Tests in a Trace Compiler. In: Knoop, J. (ed.) CC 2011. LNCS, vol. 6601, pp. 2–21. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  19. 19.
    Wegman, M.N., Zadeck, F.K.: Constant propagation with conditional branches. TOPLAS 13(2) (1991)Google Scholar
  20. 20.
    Guo, S.Y., Palsberg, J.: The essence of compiling with traces. In: POPL, page to appear. ACM (2011)Google Scholar
  21. 21.
    Zaleski, M.: YETI: A Gradually Extensible Trace Interpreter. PhD thesis, University of Toronto (2007)Google Scholar
  22. 22.
    Zhou, H., Chen, W., Chow, F.C.: An SSA-based algorithm for optimal speculative code motion under an execution profile. In: PLDI, pp. 98–108. ACM (2011)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Péricles Rafael Oliveira Alves
    • 1
  • Igor Rafael de Assis Costa
    • 1
  • Fernando Magno Quintão Pereira
    • 1
  • Eduardo Lage Figueiredo
    • 1
  1. 1.Departamento de Ciência da ComputaçãoUFMGBelo HorizonteBrazil

Personalised recommendations