Challenges for a Trace-Based Just-In-Time Compiler for Haskell

  • Thomas Schilling
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7257)

Abstract

Haskell’s use of lazy evaluation and type classes has endowed it with enhanced expressiveness, but also poses difficult challenges for compiler writers if high performance is a requirement. Most research so far has used static compilation techniques to solve these issues.

In this work, we argue that an implementation based on a virtual machine with a dynamic optimizer based on trace-compilation may be able to remove Haskell’s execution overheads with similar efficacy. This could improve on static techniques in the following ways: (1) more predictable optimization in hot spots, (2) cross-module optimization while retaining binary compatibility, and (3) no need to compile multiple module variants for profiling or debugging.

We present a work-in-progress prototype that implements a trace-based just-in-time compiler for Haskell and identify the missing pieces of the puzzle required to achieve an implementation that can be competitive with state of the art ahead-of-time Haskell compilers.

References

  1. 1.
    Bala, V., Duesterwald, E., Banerjia, S.: Transparent dynamic optimization: The design and implementation of dynamo. Tech. Rep. HPL-1999-78, HP Laboratories Cambridge (1999)Google Scholar
  2. 2.
    Bala, V., Duesterwald, E., Banerjia, S.: Dynamo: A Transparent Dynamic Optimization System. In: Proceedings of the ACM SIGPLAN 2000 Conference on Programming Language Design and Implementation, PLDI 2000, pp. 1–12. ACM (2000)Google Scholar
  3. 3.
    Bebenita, M., Brandner, F., Fahndrich, M., Logozzo, F., Schulte, W., Tillmann, N., Venter, H.: SPUR: A Trace-based JIT Compiler for CIL. In: Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA 2010, pp. 708–725. ACM, New York (2010)CrossRefGoogle Scholar
  4. 4.
    Bebenita, M., Chang, M., Wagner, G., Gal, A., Wimmer, C., Franz, M.: Trace-based compilation in execution environments without interpreters. In: PPPJ 2010, pp. 59–68. ACM, New York (2010)CrossRefGoogle Scholar
  5. 5.
    Bolingbroke, M., Peyton Jones, S.: Supercompilation by Evaluation. In: Proceedings of the Third ACM Haskell Symposium on Haskell, Haskell 2010, pp. 135–146. ACM (2010)Google Scholar
  6. 6.
    Bolz, C.F., Cuni, A., Fijałkowski, M., Leuschel, M., Pedroni, S., Rigo, A.: Allocation Removal by Partial Evaluation in a Tracing JIT. In: Proceedings of the 20th ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM 2011, pp. 43–52. ACM (2011)Google Scholar
  7. 7.
    Bolz, C.F., Cuni, A., Fijalkowski, M., Rigo, A.: Tracing the Meta-Level: PyPy’s Tracing JIT compiler. In: ICOOOLPS 2009: Proceedings of the 4th Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pp. 18–25 (2009)Google Scholar
  8. 8.
    Boquist, U., Johnsson, T.: The GRIN Project: A Highly Optimising Back End for Lazy Functional Languages. In: Implementation of Functional Languages, pp. 58–84 (1996)Google Scholar
  9. 9.
    Bruening, D.L.: Effient, Transparent, and Comprehensive Runtime Code Manipulation. Ph.D. thesis, Massachusetts Institute of Technology (September 2004)Google Scholar
  10. 10.
    Coutts, D., Leshchinskiy, R., Stewart, D.: Stream fusion: From lists to streams to nothing at all. In: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, ICFP 2007, pp. 315–326. ACM (2007)Google Scholar
  11. 11.
    Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Zadeck, F.K.: Efficiently computing static single assignment form and the control dependence graph. ACM Trans. Program. Lang. Syst. 13(4), 451–490 (1991)CrossRefGoogle Scholar
  12. 12.
    Davis, B., Beatty, A., Casey, K., Gregg, D., Waldron, J.: The Case for Virtual Register Machines. In: Proceedings of the 2003 Workshop on Interpreters, Virtual Machines and Emulators, IVME 2003, pp. 41–49. ACM Press (2003)Google Scholar
  13. 13.
    Gal, A., Franz, M.: Incremental Dynamic Code Generation with Trace Trees. Tech. Rep. ICS-TR-06-16, University of California, Irvine (2006)Google Scholar
  14. 14.
    Gal, A., Orendorff, J., Ruderman, J., Smith, E., Reitmaier, R., Bebenita, M., Chang, M., Franz, M., Eich, B., Shaver, M., Anderson, D., Mandelin, D., Haghighat, M.R., Kaplan, B., Hoare, G., Zbarsky, B.: Trace-based Just-in-time type Specialization for Dynamic Languages. In: PLDI 2009, pp. 465–478. ACM (2009)Google Scholar
  15. 15.
    Gill, A.: Cheap deforestation for non-strict functional languages. Ph.D. thesis, The University of Glasgow (January 1996)Google Scholar
  16. 16.
    Gill, A., Launchbury, J., Peyton Jones, S.: A short cut to deforestation. In: Proceedings of the Conference on Functional Programming Languages and Computer Architecture, FPCA 1993, pp. 223–232. ACM (1993)Google Scholar
  17. 17.
    Gustavsson, J.: A type based sharing analysis for update avoidance and optimisation. In: Proceedings of the Third ACM SIGPLAN International Conference on Functional Programming, ICFP 1998, pp. 39–50. ACM (1998)Google Scholar
  18. 18.
    Hage, J., Holdermans, S., Middelkoop, A.: A generic usage analysis with subeffect qualifiers. In: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, ICFP 2007, pp. 235–246. ACM (2007)Google Scholar
  19. 19.
    Hayashizaki, H., Wu, P., Inoue, H., Serrano, M.J., Nakatani, T.: Improving the Performance of Trace-based Systems by False Loop Filtering. In: ASPLOS 2011, pp. 405–418. ACM (2011)Google Scholar
  20. 20.
    Hölzle, U., Chambers, C., Ungar, D.: Optimizing Dynamically-typed Object-oriented Languages with Polymorphic Inline Caches. In: America, P. (ed.) ECOOP 1991. LNCS, vol. 512, pp. 21–38. Springer, Heidelberg (1991)CrossRefGoogle Scholar
  21. 21.
    Hughes, J.: Why Functional Programming Matters. The Computer Journal 32(2), 98–107 (1989)CrossRefGoogle Scholar
  22. 22.
    Leshchinskiy, R.: Recycle Your Arrays! In: Gill, A., Swift, T. (eds.) PADL 2009. LNCS, vol. 5418, pp. 209–223. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  23. 23.
    Marlow, S., Peyton Jones, S.: Making a Fast Curry: Push/Enter vs. Eval/Apply for Higher-order Languages. In: Proceedings of the Ninth ACM SIGPLAN International Conference on Functional Programming, ICFP 2004, pp. 4–15. ACM (2004)Google Scholar
  24. 24.
    Marlow, S., Peyton Jones, S., Singh, S.: Runtime Support for Multicore Haskell. In: Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming, ICFP 2009, pp. 65–78. ACM (2009)Google Scholar
  25. 25.
    Marlow, S., Yakushev, A.R., Peyton Jones, S.: Faster laziness using dynamic pointer tagging. In: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, ICFP 2007, pp. 277–288. ACM (2007)Google Scholar
  26. 26.
    Mitchell, N.: Rethinking Supercompilation. In: Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP 2010, pp. 309–320. ACM (2010)Google Scholar
  27. 27.
    Pall, M.: LuaJIT 2, http://luajit.org/
  28. 28.
    Pall, M.: LuaJIT 2.0 intellectual property disclosure and research opportunities. Lua-l mailing list message (2009), http://lua-users.org/lists/lua-l/2009-11/msg00089.html
  29. 29.
    Peyton Jones, S.: Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. Journal of Functional Programming 2, 127–202 (1992)MATHCrossRefGoogle Scholar
  30. 30.
    Peyton Jones, S., Marlow, S.: Secrets of the glasgow haskell compiler inliner. Journal of Functional Programming 12(5), 393–434 (2002)MathSciNetMATHCrossRefGoogle Scholar
  31. 31.
    Peyton Jones, S., Tolmach, A., Hoare, T.: Playing by the rules: rewriting as a practical optimisation technique in GHC. In: Haskell 2001, pp. 203–233 (2001)Google Scholar
  32. 32.
    Rigo, A., Pedroni, S.: PyPy’s Approach to Virtual Machine Construction. In: OOPSLA 2006: Companion to the 21st ACM SIGPLAN Symposium on Object-Oriented Programming Systems, Languages, and Applications (2006)Google Scholar
  33. 33.
    Shi, Y., Gregg, D., Beatty, A., Ertl, M.A.: Virtual machine showdown: Stack versus registers. In: Proceedings of the 1st ACM/USENIX International Conference on Virtual Execution Environments, VEE 2005, pp. 153–163. ACM (2005)Google Scholar
  34. 34.
    Mogensen, T.Æ.: Types for 0, 1 or Many Uses. In: Clack, C., Hammond, K., Davie, T. (eds.) IFL 1997. LNCS, vol. 1467, pp. 112–122. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  35. 35.
    Wadler, P.: Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science 73, 231–248 (1990)MathSciNetMATHCrossRefGoogle Scholar
  36. 36.
    Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Proceedings of the 16th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1989, pp. 60–76. ACM (1989)Google Scholar
  37. 37.
    Wansbrough, K., Peyton Jones, S.: Simple Usage Polymorphism. In: The Third ACM SIGPLAN Workshop on Types in Compilation (2000)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Thomas Schilling
    • 1
  1. 1.School of ComputingUniversity of KentUK

Personalised recommendations