Hi all,
The JIT work finally reached an important step in the past week: there
is an RPython interface between the JIT frontend and any possible
machine-code-level backend. The interface (called RGenOp and To Be
Documented Soon, Tm) has two implementations so far:
* codegen/llgraph/rgenop.py that produces flow graphs again (don't look,
it's quite obscure to do that while still being RPython enough). It
is for testing only, so far.
* codegen/i386/ri386genop.py that produces i386 ("IA32", more precisely)
machine code into mmap-ed memory blocks.
There are some basic tests about using the interface in
i386/test/test_ri386genop.py. The tests there have the following
structure:
* def make_xxx(): this is an example RPython function that calls the
rgenop interface to generate some simple code.
* def test_xxx_interpret(): tries to run make_xxx() with the
codegen/llgraph implementation, and then llinterprets the produced
graph.
* def test_xxx_direct(): tries to run make_xxx() with the codegen/i386
implementation, and then executes the machine code. Gets nice
segfaults if the machine code is wrong.
* def test_xxx_compile(): compiles the make_xxx() function into a
stand-alone executable (via the normal genc route). This is where we
check that our ri386genop implementation is really RPython code only.
A hint about the "token" thingy: there are many rgenop.xxxToken() static
methods that are here basically because we cannot dynamically handle in
RPython code objects like low-level types. So a "token" is whatever
RPython value that the back-end needs in order to perform a specific
operation on that type. Each variant of token can be anything - it's
returned by rgenop only to be passed back to it - but they must be
RPython values. For example, 'fieldToken(T, name)' makes a token that
is passed back to methods like genop_getfield(). For the i386 backend,
the fieldToken is simply an integer: the offset of the field in the
structure T. This is used by genop_getfield() to encode the offset in
the machine instruction. In this way, genop_getfield() is a completely
RPython-friendly function, and only fieldToken() needs to be special (a
memo static method).
More in the above-promized documentation :-)
A bientot,
Armin
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev