[pypy-dev] [pypy-commit] pypy dynamic-specialized-tuple: kill an assert that doesn't hold now.

Hakan Ardo hakan at debian.org
Fri Mar 30 15:15:05 CEST 2012

On Fri, Mar 30, 2012 at 2:49 PM, Alex Gaynor <alex.gaynor at gmail.com> wrote:
> I'm a bit concerned that this branch may be breaking too many assumptions in
> the JIT with the current approach.  The idea of this branch is to
> dynamically specialize the shape of a tuple's memory, to store unboxed
> objects.  Based on the current approach (storing all data in an array of
> integers) you get traces that look like:
> p0 = new(<untyped storage>)
> setfield_gc(p0, ConstPtr("io"), <FieldDescr shape>)
> setarrayitem_gc(p0, 0, i0, <ArrayDescr int>)
> setarrayitem_gc(p0, 1, p1, <ArrayDescr ptr>)
> finish(p0)
> This is a trace for allocating a tuple like (int1, ptr1) and returning it.
>  Do you think a trace like this breaks too many assumptions in the JIT, and
> if so, how can we go about making the JIT work with this.

That part might be fine. In this case the descr depends is not realy
changing it just depends on the constant index. The assert could
probably be relaxed to allow that. But what would traces reading
values from the tuple look like. In cases where the tuple may conatin
different types or if the index is not constant? Say something like

sa = 0
a = (1, 2.0)
while sa < 3000:
    sa += a[0] + a[1]
    if sa > 1500:
        a = (a[1], a[0])

Håkan Ardö

More information about the pypy-dev mailing list