[pypy-dev] JIT status
arigo at tunes.org
Thu Feb 8 12:23:21 CET 2007
The JIT has now reached the state it will have in the upcoming PyPy
release (it's still on a branch, but it will be merged).
What it does is produce machine code in memory, and run it.
What it does not do is gain much speed by doing so.
It's just bad timing that the release and EU-driven deadlines mean that
we have no time left to put the pieces together now - but essentially
they are there already. We expect the jit to become useful during
March, and then we'll in all likeliness do another release - if only
because we promized to the EU numbers like "50% of the speed of C" for
the most extremely algorithmic examples.
Back to the present. Let me describe the current status. The produced
machine code is kind of good (the backend performs some liftime analysis
and register allocation). The "timeshifter", which produces the jit
frontend, is able to handle rather incredibly tricky situations
successfully. From a user point of view the jit has some rough edges
but nothing fundamental, and by construction it can jit absolutely any
kind of Python code - generators, nested scopes, exec statements,
At the moment only the interpreter's main dispatch loop (i.e. mostly
only pyopcode.py) is fed to the timeshifter, so the produced jit can
remove the bytecode interpretation overhead, but cannot look inside the
implementation of space.add(), for example. So it gives results that
look like Python2C+gcc: it produces machine code that is essentially a
sequence of calls to space.add(), space.cmp(), space.is_true(), etc. As
we all know, Python2C gives a ~2x speed-up; we get about the same with
our jit, except that the start-up overhead is greater - calling small
functions is still quite slower with the jit than without. On the other
hand, Python2C doesn't emulate frames, for example, so AFAIK pypy
contains the first Python compiler ever where sys._getframe() completely
works (Psyco emulates frames but not at 100%).
Only the 386 backend is complete; mwh guesses that there is some degree
of likeliness that the ppc backend will be completed in time for the
How to compile a pypy-c with a jit: use translate.py on targetjit
(located in pypy/jit/goal/). Then:
export PYPYJITLOG=log # logs machine code into file 'log'
>>> def f(x): return x*5
>>> import pypyjit
More information about the Pypy-dev