Abstract
Applications written in dynamically typed scripting languages are increasingly popular for Web software development. Even on the server side, programmers are using dynamically typed scripting languages such as Ruby and Python to build complex applications quickly. As the number and complexity of dynamically typed scripting language applications grows, optimizing their performance is becoming important. Some of the best performing compilers and optimizers for dynamically typed scripting languages are developed entirely from scratch and target a specific language. This approach is not scalable, given the variety of dynamically typed scripting languages, and the effort involved in developing and maintaining separate infrastructures for each. In this paper, we evaluate the feasibility of adapting and extending an existing production-quality method-based Just-In-Time (JIT) compiler for a language with dynamic types. Our goal is to identify the challenges and shortcomings with the current infrastructure, and to propose and evaluate runtime techniques and optimizations that can be incorporated into a common optimization infrastructure for static and dynamic languages. We discuss three extensions to the compiler to support dynamically typed languages: (1) simplification of control flow graphs, (2) mapping of memory locations to stack-allocated variables, and (3) reduction of runtime overhead using language semantics. We also propose four new optimizations for Python in (2) and (3). These extensions are effective in reduction of compiler working memory and improvement of runtime performance. We present a detailed performance evaluation of our approach for Python, finding an overall improvement of 1.69x on average (up to 2.74x) over our JIT compiler without any optimization for dynamically typed languages and Python.
- Agesen, O., Detlefs, D., and Moss, J. E. Garbage collection and local variable type-precision and liveness in Java virtual machines. In Proceedings of the ACM SIGPLAN 1998 conference on Programming language design and implementation, pp.269--279, 1998. Google Scholar
Digital Library
- Ancona, D., Ancona, M., Cuni, A., and Matsakis, N. D. RPython: a step towards reconciling dynamically and statically typed OO languages. In Proceedings of the 2007 Symposium on Dynamic Languages, pp.53--64, 2007. Google Scholar
Digital Library
- Arnold, M., Fink S. J., Grove, D., Hind, M., and Sweeney, P. F. A Survey of Adaptive Optimization in Virtual Machines. In Proceedings of the IEEE, 93(2), 2005.Google Scholar
Cross Ref
- Barrett, K., Cassels, B., Haahr, P., Moon, D. A., Playford, K., and Withington, P. T. A monotonic superclass linearization for Dylan. In Proceedings of the ACM international Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp.69--82, 1996. Google Scholar
Digital Library
- Bebenita, M., Brandner, F., Fahndrich, M., Logozzo, F., Schulte, W., Tillmann, N., and 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, pp.708--725, 2010. Google Scholar
Digital Library
- Bebenita, M., Brandner, F., Fahndrich, M., Logozzo, F., Schulte, W., Tillmann, N., and Venter, H. Mozilla Foundation, https://wiki.mozilla.org/JaegerMonkey/.Google Scholar
- Bolz, C., Cuni, A., Fijalkowski, M., and Rigo, A. Tracing the Meta-Level: PyPy's Tracing JIT Compiler. In Proceedings of the 4th work-shop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pp.18--25, 2009. Google Scholar
Digital Library
- Bolz, C., Cuni, A., Fijalkowski, M., Leuschel, M., Rigo, A., and Pedroni, S. Runtime Feedback in a Meta-Tracing JIT for Efficient Dynamic Languages, In Proceedings of the 6th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, 2011. Google Scholar
Digital Library
- Chambers, C. and Ungar, D. and Lee, E. An efficient implementation of SELF a dynamically-typed object-oriented language based on pro-totypes, In Proceedings of the ACM international Conference on Object Oriented Programming Systems Languages and Applications, pp.49--70, 1989. Google Scholar
Digital Library
- Chambers, C. and Ungar, D. Customization: optimizing compiler technology for self, a dynamically-typed object-oriented programming language. In Proceedings of the ACM SIGPLAN Conference on Programming language design and implementation, pp.146--160, 1989. Google Scholar
Digital Library
- Chambers, C., Ungar, D., and Lee. E. An efficient implementation of SELF a dynamically-typed object-oriented language based on proto-types. In the ACM international Conference proceedings on Object-oriented programming systems, languages and applications. pp.49--70, 1989. Google Scholar
Digital Library
- Choi, J.-D., Grove, D., Hind, M., and Sarkar, V. Efficient and precise modeling of exceptions for the analysis of Java programs. In Proceedings of the 1999 ACM SIGPLAN-SIGSOFT workshop on Program analysis for software tools and engineering, pp.21--31, 1999. Google Scholar
Digital Library
- Christopher, T. W. Reference count garbage collection. Software-Practice and Experience, 14(6), pp.503--507, 1984.Google Scholar
Cross Ref
- Deutsch, L. P. and Schiffman, A. M. Efficient implementation of the smalltalk-80 system. In Proceedings of the 11th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages., pp.297--302, 1984. Google Scholar
Digital Library
- Gal, A., Eich, A., et al. Trace-based just-in-time type specialization for dynamic languages. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pp.465--478, 2009. Google Scholar
Digital Library
- Gosling, J. Java intermediate bytecodes: ACM SIGPLAN workshop on intermediate representations, pp.111--118, 1995. Google Scholar
Digital Library
- Holkner, A. and Harland, J. Evaluating the dynamic behaviour of Python applications. In Proceedings of the Thirty-Second Australasian Conference on Computer Science - Volume 91, pp.19--28, 2009. Google Scholar
Digital Library
- IronPython, http://ironpython.net/.Google Scholar
- Joisha, P. G. Compiler optimizations for nondeferred reference: counting garbage collection. In Proceedings of the 5th international symposium on Memory management. pp.150--161, 2006. Google Scholar
Digital Library
- Kulkarni, P. A. JIT compilation policy for modern machines, In Proceedings of the ACM international conference on Object oriented programming systems languages and applications, pp.773--788, 2011. Google Scholar
Digital Library
- Lattner, C. and Adve, V. LLVM: A Compilation Framework for Life-long Program Analysis & Transformation. In Proceedings of the inter-national Symposium on Code Generation and Optimization: Feedback-Directed and Runtime Optimization, pp.75--86, 2004. Google Scholar
Digital Library
- LuaJIT roadmap 2008, http://lua-users.org/lists/lua-l/2008-02/msg00051.html.Google Scholar
- Microsoft corporation. Dynamic Language Runtime, http://dlr.codeplex.com/Google Scholar
- Mostafa, N., Krintz, C., Cascaval, C., Edelsohn, D., Nagpurkar, P., Wu, P. Understanding the Potential of Interpreter-based Optimizations for Python, UCSB Technical Report 2010--14, 2010.Google Scholar
- Muchnick, S. S. Advanced Compiler Design and Implementation. Morgan Kaufmann Publishers Inc., 1998. Google Scholar
Digital Library
- N. Grcevski, A. Kielstra, K. Stoodley, M. G. Stoodley, and V. Sundaresan. Java just-in-time compiler and virtual machine improvements for server and middleware applications. In Proceedings of the 3rd Virtual Machine Research and Technology Symposium, pp.151--162. 2004. Google Scholar
Digital Library
- Paleczny, M., Vick, C., and Click. C. The java hotspot server compiler. In Proceedings of the Symposium on Java Virtual Machine Re-search and Technology Symposium, pp.1--12, 2001. Google Scholar
Digital Library
- Python Programming Language, http://www.python.org/Google Scholar
- Rossum, G. van. http://mail.python.org/pipermail/python-dev/2006-December/070323.html.Google Scholar
- Rubinius, http://rubini.us/Google Scholar
- Ruby on Rails, http://rubyonrails.org/Google Scholar
- Shi, Y., Gregg, D., Beatty, A., and Ertl, M. A. Virtual machine show-down: stack versus registers. In Proceedings of the 1st ACM/USENIX international Conference on Virtual Execution Environments, pp.153--163, 2005. Google Scholar
Digital Library
- Shire, B. PHP and Facebook, http://blog.facebook.com/blog.php?post=2356432130Google Scholar
- Speeding up JSON encoding in PyPy, http://morepypy.blogspot.com/2011/10/speeding-up-json-encoding-in-pypy.html.Google Scholar
- Suganuma, T., Ogasawara, T., Takeuchi, M., Yasue, T., Kawahito, M., Ishizaki, K., Komatsu, H., and Nakatani, T. Overview of the IBM Java just-in-time compiler. IBM System Journal, 39(1), pp.175--193, 2000. Google Scholar
Digital Library
- Tamarin on LLVM - More Numbers, http://www.masonchang.com/blog/2011/4/21/tamarin-on-llvm-more-numbers.htmlGoogle Scholar
- Tatsubori, M., Tozawa, A., Suzumura, T., Trent, S., and Onodera, T. Evaluation of a just-in-time compiler retrofitted for PHP. In Proceedings of the 6th ACM SIGPLAN/SIGOPS international Conference on Virtual Execution Environments, pp.121--132, 2010. Google Scholar
Digital Library
- The Da Vinci Machine Project, http://openjdk.java.net/projects/mlvm/.Google Scholar
- The Jython Project, http://www.jython.org/Project/.Google Scholar
- Unladen Swallow Benchmarks, http://code.google.com/p/unladen-swallow/wiki/Benchmarks/.Google Scholar
- Unladen Swallow, Change log, http://code.google.com/p/unladen-swallow/source/detail?r=1102.Google Scholar
- Unladen Swallow, Change log, http://code.google.com/p/unladen-swallow/source/detail?r=923.Google Scholar
- Unladen Swallow, Change log, http://code.google.com/p/unladen-swallow/source/detail?r=957.Google Scholar
- Unladen Swallow, http://code.google.com/p/unladen-swallow/.Google Scholar
- Unladen Swallow, Optimize IMPORT_NAME, http://codereview.appspot.com/217052Google Scholar
- Unladen Swallow, Optimize LOAD_GLOBAL, http://codereview.appspot.com/109043Google Scholar
- Using tracing to jump out of a loop causes the Python object stack to overflow, http://code.google.com/p/unladen-Swallow/issues/detail?id=91Google Scholar
- V8 JavaScript Engine. http://code.google.com/p/v8/.Google Scholar
- Yermolovich, A., Wimmer, C., and Franz, M. Optimization of dynamic languages using hierarchical layering of virtual machines, In Proceedings of the 5th symposium on Dynamic languages, pp. 79-88, 2009. Google Scholar
Digital Library
Index Terms
Adding dynamically-typed language support to a statically-typed language compiler: performance evaluation, analysis, and tradeoffs
Recommendations
On the benefits and pitfalls of extending a statically typed language JIT compiler for dynamic scripting languages
OOPSLA '12Whenever the need to compile a new dynamically typed language arises, an appealing option is to repurpose an existing statically typed language Just-In-Time (JIT) compiler (repurposed JIT compiler). Existing repurposed JIT compilers (RJIT compilers), ...
On the benefits and pitfalls of extending a statically typed language JIT compiler for dynamic scripting languages
OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applicationsWhenever the need to compile a new dynamically typed language arises, an appealing option is to repurpose an existing statically typed language Just-In-Time (JIT) compiler (repurposed JIT compiler). Existing repurposed JIT compilers (RJIT compilers), ...
Compile-time meta-programming in a dynamically typed OO language
DLS '05: Proceedings of the 2005 symposium on Dynamic languagesCompile-time meta-programming allows programs to be constructed by the user at compile-time. Although LISP derived languages have long had such facilities, few modern languages are capable of compile-time meta-programming, and of those that do many of ...







Comments