Delimited Continuations in PyPy?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Delimited Continuations in PyPy?

Timothy Baldridge
I recently came across this paper: https://www.microsoft.com/en-us/research/publication/implementing-algebraic-effects-c/

The gist is that they use setjmp/longjmp to create delimited continuations in compliant C99.

It seems like this method is fairly close to what PyPy already does with stacklets. Any reason why this couldn't be ported to PyPy? Of course there'd have to be some sort of stack integration as with stacklets, but it seems that that mostly boils down to making sure the GC has a way to trace the bits of the stack contained in the continuations.

I'm considering trying my hand at using their library via rffi, and copying what I need from _stacklet_shadowstack.py. But perhaps there's something I'm missing that makes this a no-go from the start. 


Thanks,

Timothy Baldridge


_______________________________________________
pypy-dev mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/pypy-dev
Reply | Threaded
Open this post in threaded view
|

Re: Delimited Continuations in PyPy?

Armin Rigo-2
Hi Timothy,

On 4 August 2017 at 01:08, Timothy Baldridge <[hidden email]> wrote:
> It seems like this method is fairly close to what PyPy already does with
> stacklets. Any reason why this couldn't be ported to PyPy?

My first reaction is that this *is* stacklets.  Can you describe in
two words what there is more?


A bientôt,

Armin.
_______________________________________________
pypy-dev mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/pypy-dev
Reply | Threaded
Open this post in threaded view
|

Re: Delimited Continuations in PyPy?

cristipp
One may choose to invoke a continuation multiple times. Therefore, wouldn't
continuations require forkable stacklets? Which appear to be
unimplelemented:

> /* stacklet_handle _stacklet_switch_to_copy(stacklet_handle) --- later */

https://bitbucket.org/pypy/pypy/annotate/5ef9bb870cd2af8df10d9394ca7b8cd4bed3fd15/rpython/translator/c/src/stacklet/stacklet.h?at=default&fileviewer=file-view-default#stacklet.h-55



--
Sent from: http://pypy.1116445.n5.nabble.com/
_______________________________________________
pypy-dev mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/pypy-dev
Reply | Threaded
Open this post in threaded view
|

Re: Delimited Continuations in PyPy?

Armin Rigo-2
Hi,

On 15 December 2017 at 07:47, cristipp <[hidden email]> wrote:
> One may choose to invoke a continuation multiple times. Therefore, wouldn't
> continuations require forkable stacklets?

Answered on https://bitbucket.org/pypy/pypy/issues/2710/call-cc-delimited-continuations-reentrant.


Armin
_______________________________________________
pypy-dev mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/pypy-dev