[pypy-dev] What is RuntimeTypeInfo?

Armin Rigo armin.rigo at gmail.com
Wed Mar 15 03:13:06 EDT 2017


Hi,

On 15 March 2017 at 04:40, William ML Leslie
<william.leslie.ttg at gmail.com> wrote:
> The RTTI are a hook that the backend can implement, there is a fair
> bit of flexibility in what values they can take.

That's right, but also, the RTTI is actually something from the early
days of PyPy and not used any more nowadays.  It is used with our
test-only refcounting GC but not by "real code".  I wouldn't start
with that.

>> It seems that by default the JIT transformer throws away the actual type information
>> (GcStruct etc., which is not representable under RPython, I know) and only keeps
>> the size. However, in Mu, memory allocation requires specific type information.

That's not really true.  We need to keep at least the typeid (a
number, also called "tid") in addition to the size.  This is stored in
the SizeDescr, for GcStructs, which is a small piece of type
information built at translation time by cpu.sizeof().  Look for
get_size_descr() in jit/backend/llsupport/, and for init_size_descr()
in jit/backend/llsupport/gc.py.  You can tweak SizeDescr to attach
whatever info is needed there.

As William said, depending on what exactly you need, you need to also
tweak jit/codewriter/, which is the code that ultimately invokes the
translation-time setting up of SizeDescr.

Also, the same applies to the other Descr classes in
llsupport/descr.py, at least ArrayDescr.


A bientôt,

Armin.


More information about the pypy-dev mailing list