[pypy-dev] question on rpython stack reconstruction feature

alan yung yung2.alan at gmail.com
Sat May 30 05:23:52 CEST 2009


Thanks Armin.
I fixed the code accordingly, and resume() function seems to be (somehow)
working.
However, freeze() function does not work the way I wanted. Following is how
I fixed it.

http://paste.pocoo.org/show/119851/

After translating pypy with stackless option with above code, I ran
following python code

def foo():
    def foo2():
        freeze()
        print "foo"
    foo2()

def bar():
    print "bar"
    resume()

if __name__ == '__main__':
    foo()
    bar()

resume() function needs to be fixed alittle bit, but when I run above code,
I wanted it to print out "bar" first, and not "foo"
but it prints out "foo" first.

So, it seems like rstack.stack_unwind() function does not seems to work.

Any thought?



On Fri, May 29, 2009 at 9:13 AM, Armin Rigo <arigo at tunes.org> wrote:

> Hi Alan,
>
> On Fri, May 29, 2009 at 08:19:27AM -0700, alan yung wrote:
> > I called them from normal Python application (in stackless translated
> pypy
> > vm) and the behaviour is that they don't have any effect. There's no
> > (interpreter level/application level) stack unwinding or resuming.
>
> Ah, that's step 1.  I see.  As this is RPython code, it means that you
> cannot use some constructs -- in this case, the problem is that "if not
> freezed_executioncontext:" is constant-folded, so it is always True
> (which is of course not the case in a normal Python program).  You don't
> have varying global lists in RPython, so you need to create a small
> class, create a global instance of it, and then you can read/write an
> attribute "freeze_executioncontext" on it.
>
>
> A bientot,
>
> Armin.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20090529/b478745e/attachment.html>


More information about the Pypy-dev mailing list