[pypy-dev] pypy for typed languages?

Geoffrey Irving irving at naml.us
Fri Mar 13 16:48:39 CET 2009


On Fri, Mar 13, 2009 at 11:19 AM, Maciej Fijalkowski <fijall at gmail.com> wrote:
> On Fri, Mar 13, 2009 at 3:04 PM, Geoffrey Irving <irving at naml.us> wrote:
>> On Fri, Mar 13, 2009 at 7:13 AM, Armin Rigo <arigo at tunes.org> wrote:
>>>> In particular, what restrictions does pypy impose on storage layout?
>>>> For example, would it be able to handle dynamically-typed homogeneous
>>>> lists, represented as a single pointer to a type object and an array
>>>> of structs required to be of that type?
>>>
>>> RPython doesn't have support for this.  If you go directly to the lltype
>>> type system, then it's possible -- but our current JIT generator doesn't
>>> support it.  And also, if you write an interpreter using the lltype type
>>> system directly, you loose the abstraction level of writing an
>>> interpreter in RPython in the first place -- e.g. it would not be
>>> translatable any more to the ootype type system, thus to Java or CLI.
>>>
>>> So all in all, PyPy could probably be subverted to do what you want, but
>>> it's not really meant to (and we are a bit unlikely to give much
>>> support, as far as I can see).
>>
>> Thanks for the reply.  It seems like targeting LLVM directly is the
>> way to go for such projects for now.
>
> I don't know, do you have any example?

At this point I'm just in the curiosity stage, so I don't have a
concrete example.  Roughly, I'm imagining a language based on System
CT [1] or the like, which is somewhat like duck typing for static
languages with homogeneous data structures.  Since all function can be
overloaded, at runtime functions would pass around large dictionaries
of overloads, which would need to be optimized away via JIT for
reasonable speed.

A JIT would have an easier job on a System CT-like language than with
python or java, due to the guarantee of homogeneity.  For example, in
the sum function

def sum(container):
    sum = zero
    for elem in container:
        sum = sum + elem
    return sum

a language with homogeneous containers knows that "+" is constant
throughout the loop even if it is impossible to know which constant it
is in advance.

Geoffrey

[1] http://homepages.dcc.ufmg.br/~camarao/CT



More information about the Pypy-dev mailing list