Tracing the meta-level: PyPy's tracing JIT compiler

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.

[1]  Markus Mock,et al.  DyC: an expressive annotation-directed dynamic compiler for C , 2000, Theor. Comput. Sci..

[2]  Samuele Pedroni,et al.  PyPy's approach to virtual machine construction , 2006, OOPSLA '06.

[3]  Saman Amarasinghe,et al.  Dynamic native optimization of interpreters , 2003, IVME '03.

[4]  Michael Franz,et al.  Incremental Dynamic Code Generation with Trace Trees , 2006 .

[5]  Yoshihiko Futamura,et al.  Partial Evaluation of Computation Process--An Approach to a Compiler-Compiler , 1999, High. Order Symb. Comput..

[6]  Michael Franz,et al.  Tracing for web 3.0: trace compilation for the next generation web applications , 2009, VEE '09.

[7]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.

[8]  Mark N. Wegman,et al.  Efficiently computing static single assignment form and the control dependence graph , 1991, TOPL.

[9]  Armin Rigo,et al.  Representation-based just-in-time specialization and the psyco prototype for python , 2004, PEPM '04.

[10]  Davide Ancona,et al.  RPython: a step towards reconciling dynamically and statically typed OO languages , 2007, DLS '07.

[11]  Carl Friedrich Bolz,et al.  How to not write Virtual Machines for Dynamic Languages , 2007 .

[12]  Urs Hölzle,et al.  Adaptive optimization for self: reconciling high performance with exploratory programming , 1994 .

[13]  David Gregg,et al.  Retargeting JIT Compilers by using C-Compiler Generated Executable Code , 2004, IEEE PACT.

[14]  Vasanth Bala,et al.  Dynamo: a transparent dynamic optimization system , 2000, SIGP.

[15]  Michael Franz,et al.  HotpathVM: an effective JIT compiler for resource-constrained devices , 2006, VEE '06.

[16]  Toon Verwaest,et al.  PyGirl: Generating Whole-System VMs from High-Level Prototypes Using PyPy , 2009, TOOLS.

[17]  Stefan Brunthaler Virtual-Machine Abstraction and Optimization Techniques , 2009, Electron. Notes Theor. Comput. Sci..

[18]  Charles Consel,et al.  A general approach for run-time specialization and its application to C , 1996, POPL '96.

[19]  Jacques Noyé,et al.  A Uniform Approach for Compile-Time and Run-Time Specialization , 1996, Dagstuhl Seminar on Partial Evaluation.

[20]  Michael Leuschel,et al.  Automatic JIT Compiler Generation with Runtime Partial Evaluation , 2008 .

[21]  Mason Chang,et al.  Efficient Just-InTime Execution of Dynamically Typed Languages Via Code Specialization Using Precise Runtime Type Inference , 2007 .

[22]  Ian Piumarta,et al.  Optimizing direct threaded code by selective inlining , 1998, PLDI 1998.

[23]  Peter Sestoft,et al.  Partial evaluation and automatic program generation , 1993, Prentice Hall international series in computer science.

[24]  Oscar Nierstrasz,et al.  Back to the Future in One Week - Implementing a Smalltalk VM in PyPy , 2008, S3.

[25]  Gregory T. Sullivan Dynamic Partial Evaluation , 2001, PADO.

[26]  Davide Ancona,et al.  Faster than C#: efficient implementation of dynamic languages on .NET , 2009, ICOOOLPS@ECOOP.