[pypy-dev] Virtualizable Frames getting half removed in trace

Timothy Baldridge tbaldridge at gmail.com
Tue Feb 25 15:06:09 CET 2014


So I spent two more hours on this this morning and finally got some good
results.

a) I turned on _immutable_ = True on the Code object. Should have done this
before.

Then I noticed that the trace contained the creation of the argument list,
but that that list was never made. The trace was also making a call out to
some C function so that it could do the array = [None] * argc. I couldn't
get that to go away even with promoting argc. So I changed pop_values to
this instead:

def pop_values(frame, argc):
    if argc == 0:
        return Arguments([], argc)
    elif argc == 1:
        return Arguments([frame.pop()], argc)
    elif argc == 2:
        b = frame.pop()
        a = frame.pop()
        return Arguments([a, b], argc)
    assert False

Since Clojure only supports up to 20 positional arguments, that'll work
just fine. Now the last part of my trace consists of this:

+266: label(p0, i26, p5, p7, p15, p17, i21, i25,
descr=TargetToken(4302275472))
debug_merge_point(0, 0, 'NO_OP')
debug_merge_point(0, 0, 'PUSH_LOCAL 0')
debug_merge_point(0, 0, 'PUSH_LOCAL 2')
debug_merge_point(0, 0, 'EQ')
+280: i27 = int_eq(i21, i26)
guard_false(i27, descr=<Guard0x1006f6480>) [p0, p5, p7, p15, p17, i26]
debug_merge_point(0, 0, 'COND_JMP 26')
debug_merge_point(0, 0, 'PUSH_LOCAL 0')
debug_merge_point(0, 0, 'PUSH_CONST 1')
debug_merge_point(0, 0, 'PUSH_CONST 2')
debug_merge_point(0, 0, 'INVOKE 2')
debug_merge_point(1, 1, 'ADD')
+289: i28 = int_add(i25, i26)
debug_merge_point(1, 1, 'RETURN')
debug_merge_point(0, 0, 'STORE_LOCAL 0')
debug_merge_point(0, 0, 'JMP 6')
debug_merge_point(0, 0, 'NO_OP')
+295: jump(p0, i28, p5, p7, p15, p17, i21, i25,
descr=TargetToken(4302275472))

Which is exactly what I was looking for, an add and an eq.

Thanks for the help everyone!

Timothy



On Tue, Feb 25, 2014 at 2:56 AM, Armin Rigo <arigo at tunes.org> wrote:

> Hi Maciej,
>
> On 25 February 2014 09:09, Maciej Fijalkowski <fijall at gmail.com> wrote:
> > ugh that looks really odd, why is p67 not removed escapes my attention
>
> Because we do setarrayitem and getarrayitem on non-constant indexes.
>
> > On Tue, Feb 25, 2014 at 6:36 AM, Timothy Baldridge <tbaldridge at gmail.com>
> wrote:
> >> I'm attaching a copy of my latest trace. The part I'm not happy with is
> at
> >> the end of the trace:
>
> We need tricks to avoid allocating the frame when we *leave* the
> function.  In PyPy it can only be done if we know for sure that nobody
> can potentially grab a reference to the frame for later (e.g. via
> exceptions).  I'm unsure to remember the latest version of this logic,
> but there were several ones...
>
>
> A bientôt,
>
> Armin.
>



-- 
"One of the main causes of the fall of the Roman Empire was that-lacking
zero-they had no way to indicate successful termination of their C
programs."
(Robert Firth)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20140225/e1e8ebec/attachment.html>


More information about the pypy-dev mailing list