Skip to main content

Parameter Based Constant Propagation

  • Conference paper
Programming Languages

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 54.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 72.00
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  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. Aycock, J.: A brief history of just-in-time. ACM Computing Surveys 35(2), 97–113 (2003)

    Article  Google Scholar 

  3. Bala, V., Duesterwald, E., Banerjia, S.: Dynamo: A transparent dynamic optimization system. In: PLDI, pp. 1–12. ACM (2000)

    Google Scholar 

  4. Bodik, R., Gupta, R., Sarkar, V.: ABCD: Eliminating array bounds checks on demand. In: PLDI, pp. 321–333. ACM (2000)

    Google Scholar 

  5. Chaganti, P.: Google Web Toolkit GWT Java AJAX Programming, 1st edn. PACKT (2007)

    Google Scholar 

  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)

    Article  Google Scholar 

  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. 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)

    Article  Google Scholar 

  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)

    Article  Google Scholar 

  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. 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. 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. Gardner, P., Maffeis, S., Smith, G.D.: Towards a program logic for JavaScript. In: POPL, pp. 31–44. ACM (2012)

    Google Scholar 

  14. Hackett, B., Guo, S.Y.: Fast and precise hybrid type inference for JavaScript. In: PLDI. ACM (2012)

    Google Scholar 

  15. Muchnick, S.S.: Advanced Compiler Design and Implementation. Morgan Kaufmann (1997)

    Google Scholar 

  16. Patterson, J.R.C.: Accurate static branch prediction by value range propagation. In: PLDI, pp. 67–78. ACM (1995)

    Google Scholar 

  17. Shankland, S.: How JavaScript became a browser-war battleground (2009), http://www2.galcit.caltech.edu/~jeshep/GraphicsBib/NatBib/node3.html (accessed in April 30, 2012)

  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)

    Chapter  Google Scholar 

  19. Wegman, M.N., Zadeck, F.K.: Constant propagation with conditional branches. TOPLAS 13(2) (1991)

    Google Scholar 

  20. Guo, S.Y., Palsberg, J.: The essence of compiling with traces. In: POPL, page to appear. ACM (2011)

    Google Scholar 

  21. Zaleski, M.: YETI: A Gradually Extensible Trace Interpreter. PhD thesis, University of Toronto (2007)

    Google Scholar 

  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 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Alves, P.R.O., de Assis Costa, I.R., Pereira, F.M.Q., Figueiredo, E.L. (2012). Parameter Based Constant Propagation. In: de Carvalho Junior, F.H., Barbosa, L.S. (eds) Programming Languages. Lecture Notes in Computer Science, vol 7554. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-33182-4_6

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-33182-4_6

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-33181-7

  • Online ISBN: 978-3-642-33182-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics