ABSTRACT
We attempt to apply the technique of Tracing JIT Compilers in the context of the PyPy project, i.e., to programs that are interpreters for some dynamic languages, including Python. Tracing JIT compilers can greatly speed up programs that spend most of their time in loops in which they take similar code paths. However, applying an unmodified tracing JIT to a program that is itself a bytecode interpreter results in very limited or no speedup. In this paper we show how to guide tracing JIT compilers to greatly improve the speed of bytecode interpreters. One crucial point is to unroll the bytecode dispatch loop, based on two kinds of hints provided by the implementer of the bytecode interpreter. We evaluate our technique by applying it to two PyPy interpreters: one is a small example, and the other one is the full Python interpreter.
References
- D. Ancona, M. Ancona, A. Cuni, and N. D. Matsakis. RPython: a step towards reconciling dynamically and statically typed OO languages. In Proceedings of the 2007 Symposium on Dynamic Languages, pages 53--64, Montreal, Quebec, Canada, 2007. ACM. Google Scholar
Digital Library
- V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: a transparent dynamic optimization system. ACM SIGPLAN Notices, 35(5):1--12, 2000. Google Scholar
Digital Library
- C. F. Bolz. Automatic JIT Compiler Generation with Runtime Partial Evaluation. Master thesis, Heinrich-Heine-Universität Düsseldorf, 2008.Google Scholar
- C. F. Bolz, A. Kuhn, A. Lienhard, N. Matsakis, O. Nierstrasz, L. Renggli, A. Rigo, and T. Verwaest. Back to the Future in One Week --- Implementing a Smalltalk VM in PyPy, pages 123--139. 2008.Google Scholar
- C. F. Bolz and A. Rigo. How to not write a virtual machine. In Proceedings of the 3rd Workshop on Dynamic Languages and Applications (DYLA), 2007.Google Scholar
- C. Bruni and T. Verwaest. PyGirl: generating Whole-System VMs from High-Level prototypes using PyPy. In Tools, accepted for publication, 2009.Google Scholar
- S. Brunthaler. Virtual-Machine abstraction and optimization techniques. In Proceedings of the 4th International Workshop on Bytecode Semantics, Verification, Analysis and Transformation, 2009. to appear.Google Scholar
Digital Library
- M. Chang, M. Bebenita, A. Yermolovich, A. Gal, and M. Franz. Efficient Just-In-Time execution of dynamically typed languages via code specialization using precise runtime type inference. Technical Report ICS-TR-07-10, Donald Bren School of Information and Computer Science, University of California, Irvine, 2007.Google Scholar
- M. Chang, E. Smith, R. Reitmaier, M. Bebenita, A. Gal, C. Wimmer, B. Eich, and M. Franz. Tracing for Web 3.0: Trace compilation for the next generation web applications. In Proceedings of the 2009 ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, pages 71--80, Washington, DC, USA, 2009. ACM. Google Scholar
Digital Library
- C. Consel, L. Hornof, F. Noël, J. Noyé, and N. Volanschi. A uniform approach for compile-time and run-time specialization. Dagstuhl Seminar on Partial Evaluation, pages 54--72, 1996. Google Scholar
Digital Library
- C. Consel and F. Noël. A general approach for run-time specialization and its application to C. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 145--156, St. Petersburg Beach, Florida, United States, 1996. ACM. Google Scholar
Digital Library
- A. Cuni, D. Ancona, and A. Rigo. Faster than C#: Efficient implementation of dynamic languages on .NET. Accepted at ICOOOLPS'09. Google Scholar
Digital Library
- R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems, 13(4):451--490, Oct. 1991. Google Scholar
Digital Library
- M. A. Ertl and D. Gregg. Retargeting JIT compilers by using C-Compiler generated executable code. In Proceedings of the 13th International Conference on Parallel Architectures and Compilation Techniques, pages 41--50. IEEE Computer Society, 2004. Google Scholar
Digital Library
- Y. Futamura. Partial evaluation of computation process - an approach to a Compiler-Compiler. Higher-Order and Symbolic Computation, 12(4):381--391, 1999. Google Scholar
Digital Library
- A. Gal, B. Eich, M. Shaver, D. Anderson, B. Kaplan, G. Hoare, D. Mandelin, B. Zbarsky, J. Orendorff, M. Bebenita, M. Chang, M. Franz, E. Smith, R. Reitmaier, and M. Haghighat. Trace-based Just-in-Time type specialization for dynamic languages. In PLDI, 2009. Google Scholar
Digital Library
- A. Gal and M. Franz. Incremental dynamic code generation with trace trees. Technical Report ICS-TR-06-16, University of California, Irvine, Nov. 2006.Google Scholar
- A. Gal, C. W. Probst, and M. Franz. HotpathVM: an effective JIT compiler for resource-constrained devices. In Proceedings of the 2nd International Conference on Virtual Execution Environments, pages 144--153, Ottawa, Ontario, Canada, 2006. ACM. Google Scholar
Digital Library
- B. Grant, M. Mock, M. Philipose, C. Chambers, and S. J. Eggers. DyC: an expressive annotation-directed dynamic compiler for C. Theoretical Computer Science, 248(1--2):147--199, 2000. Google Scholar
Digital Library
- U. Hölzle. Adaptive optimization for SELF: reconciling high performance with exploratory programming. Technical report, Stanford University, 1994. Google Scholar
Digital Library
- N. D. Jones, C. K. Gomard, and P. Sestoft. Partial evaluation and Automatic Program Generation. Prentice-Hall, Inc., 1993. Google Scholar
Digital Library
- I. Piumarta and F. Riccardi. Optimizing direct threaded code by selective inlining. SIGPLAN Not., 33(5):291--300, 1998. Google Scholar
Digital Library
- A. Rigo. Representation-based just-in-time specialization and the Psyco prototype for Python. In Proceedings of the 2004 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 15--26, Verona, Italy, 2004. ACM. Google Scholar
Digital Library
- A. Rigo and S. Pedroni. PyPy's approach to virtual machine construction. In Companion to the 21st ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 944--953, Portland, Oregon, USA, 2006. ACM. Google Scholar
Digital Library
- A. Rigo and S. Pedroni. JIT compiler architecture. Technical Report D08.2, PyPy, May 2007.Google Scholar
- G. T. Sullivan. Dynamic partial evaluation. In Proceedings of the Second Symposium on Programs as Data Objects, pages 238--256. Springer-Verlag, 2001. Google Scholar
Digital Library
- G. T. Sullivan, D. L. Bruening, I. Baron, T. Garnett, and S. Amarasinghe. Dynamic native optimization of interpreters. In Proceedings of the 2003 Workshop on Interpreters, Virtual Machines and Emulators, pages 50--57, San Diego, California, 2003. ACM. Google Scholar
Digital Library
Index Terms
Tracing the meta-level: PyPy's tracing JIT compiler






Comments