Continuations, here I come
Arthur Peters
amp at singingwizard.org
Wed Jul 29 07:30:56 PDT 2009
<Delurk>
Although I have nothing to do with the project I thought the scala
delimited continuations plugin should be mentioned.
http://blog.richdougherty.com/2009/02/delimited-continuations-in-scala_24.html
http://dcsobral.blogspot.com/2009/07/delimited-continuations-explained-in.html
Right now it is implemented using a CPS transformation, but I wonder
if it could be implemented better using built in JVM support. I just
thought it would be good to keep it in mind while designing a JVM
extension for this.
Also good greenlets would be great for actor libraries in any
language. It would allow true erlang style "receive" to be implemented
without having each actor block a thread.
-Arthur
On Wed, Jul 29, 2009 at 1:18 AM, Jim Baker<jbaker at zyasoft.com> wrote:
> There's certainly significant interest in Jython dev for continuation
> support in the JVM.
>
> Compared to Ruby's fibers, Python's standard coroutines can be readily
> compiled to Java bytecode, simply because yield is a keyword in Python and
> the exit point always returns to the caller. We always know our yield
> points, and we simply compile a given coroutine into a large switch
> statement of these entry points, doing stack restore/save against our
> function frame objects. (Tobias' and my presentation at JavaOne 2008 goes
> into this in some detail.)
>
> However, this is not at all exhaustive. We would like to support greenlets,
> which are extensively used by IronPort, Yahoo Groups, and Slide, among
> others, pretty much in the same way as RIFE is used. Greenlets look just
> like the full coroutine switching available with Ruby's fiber.transfer (at
> least as I understand it), and the switch function cannot be identified in
> advance. Although it's possible to implement pure-Python greenlets with a VM
> on the JVM trick (in our case running Python bytecode), Java
> interoperability is severely limited, and it's slower too. Continuation
> support would of course solve this for Jython.
>
> - Jim
>
> On Tue, Jul 28, 2009 at 2:15 PM, Charles Oliver Nutter <headius at headius.com>
> wrote:
>>
>> Ok, I've decided that along with tail calls and indy, the next thing
>> on my list is delimited continuations.
>>
>> Ruby 1.9 has started to make heavier use of "fibers", which are
>> basically just coroutines or generators. Not only can you use them
>> directly, a la fiber = Fiber.new, you can also get generator behavior
>> out of any method on Enumerable. So instead of writing:
>>
>> foo.each {|a| p a}
>>
>> you can do
>>
>> enum = foo.each
>> p enum.next
>> p enum.next
>> ...
>>
>> This is implemented in CRuby by using coroutines and stack-saving
>> techniques. On the JVM, if we can't reduce the enumeration to a simple
>> case (like known core classes), or if the iteration is arbitrarily
>> complex (as it could be for a user-defined enumerable type), our only
>> option is to use a thread. And that will be pretty heavy if people are
>> doing a lot of enumeration.
>>
>> So I need to ask:
>>
>> What's the status of the continuation patch?
>> Who else has interest in it?
>> Would delimited continuations reduce security concerns?
>>
>> - Charlie
>> _______________________________________________
>> mlvm-dev mailing list
>> mlvm-dev at openjdk.java.net
>> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>
>
>
> --
> Jim Baker
> jbaker at zyasoft.com
>
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>
>
More information about the mlvm-dev
mailing list