[pypy-dev] FW: PyPy JIT and other languages

Carl Friedrich Bolz cfbolz at gmx.de
Wed Feb 6 15:58:29 CET 2008


Hi Ben,

Ben.Young at sungard.com wrote:
> I’m playing around with a bit of language design, and was wondering if 
> the JIT is able to support languages that run by traversing an AST, 
> rather than by interpreting bytecode?

That is possible in principle, yes.

> The reason is, my toy language is 
> able to mutate itself at runtime, and so the AST that’s running is also 
> exposed at applevel.

So the AST can be changed by the program too? Or only be inspected? If 
the AST is changeable it would be harder to support. The JIT could do 
something like generating code for every version of the AST it sees or 
so. However, currently there is no mechanism for throwing away existing 
machine code, so if the code is changed and run very often, you get 
memory leaks.

You could do other stuff like generating machine code only as long as 
the AST is not changed and fall back to interpreting once it is. In the 
future we might add ways to remove generated code later (by giving the 
interpreter a way to trigger that or by removing code that is rarely 
executed).


> Also, can any of you give a 2 sentence description of what a rainbow 
> interpreter is? It looks like a very low level bytecode interpreter, but 
> I’m sure it’s more than that.

The rainbow interpreter is the component that will replace the 
timeshifter when it is done. The timeshifter transforms an interpreter 
into a compiler and is a rather complex component. The rainbow 
interpreter takes a different approach where the interpreter flow graphs 
are interpreted to generate source code. The hope is that this 
interpreter is simpler than the transformation to allow experimentation 
with different approaches to figure out which things work.

Cheers,

Carl Friedrich



More information about the Pypy-dev mailing list