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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Bala, V., Duesterwald, E., Banerjia, S.: Transparent dynamic optimization: The design and implementation of dynamo. Tech. Rep. HPL-1999-78, HP Laboratories Cambridge (1999)
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)
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)
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)
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)
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)
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)
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)
Bruening, D.L.: Effient, Transparent, and Comprehensive Runtime Code Manipulation. Ph.D. thesis, Massachusetts Institute of Technology (September 2004)
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)
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)
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)
Gal, A., Franz, M.: Incremental Dynamic Code Generation with Trace Trees. Tech. Rep. ICS-TR-06-16, University of California, Irvine (2006)
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)
Gill, A.: Cheap deforestation for non-strict functional languages. Ph.D. thesis, The University of Glasgow (January 1996)
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)
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)
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)
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)
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)
Hughes, J.: Why Functional Programming Matters. The Computer Journal 32(2), 98–107 (1989)
Leshchinskiy, R.: Recycle Your Arrays! In: Gill, A., Swift, T. (eds.) PADL 2009. LNCS, vol. 5418, pp. 209–223. Springer, Heidelberg (2008)
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)
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)
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)
Mitchell, N.: Rethinking Supercompilation. In: Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP 2010, pp. 309–320. ACM (2010)
Pall, M.: LuaJIT 2, http://luajit.org/
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
Peyton Jones, S.: Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. Journal of Functional Programming 2, 127–202 (1992)
Peyton Jones, S., Marlow, S.: Secrets of the glasgow haskell compiler inliner. Journal of Functional Programming 12(5), 393–434 (2002)
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)
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)
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)
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)
Wadler, P.: Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science 73, 231–248 (1990)
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)
Wansbrough, K., Peyton Jones, S.: Simple Usage Polymorphism. In: The Third ACM SIGPLAN Workshop on Types in Compilation (2000)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Schilling, T. (2012). Challenges for a Trace-Based Just-In-Time Compiler for Haskell. In: Gill, A., Hage, J. (eds) Implementation and Application of Functional Languages. IFL 2011. Lecture Notes in Computer Science, vol 7257. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-34407-7_4
Download citation
DOI: https://doi.org/10.1007/978-3-642-34407-7_4
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-34406-0
Online ISBN: 978-3-642-34407-7
eBook Packages: Computer ScienceComputer Science (R0)