coroutine support

Charles Oliver Nutter headius at headius.com
Fri Nov 13 09:48:55 PST 2009


On Fri, Nov 13, 2009 at 11:27 AM, Jochen Theodorou <blackdrag at gmx.org> wrote:
> Charles Oliver Nutter schrieb:
>> This is basically what all the bytecode-weaving coroutine/continuation
>> libraries do. Jython also does this for their
>> lambda/generator/coroutine stuff so they can jump in and out. The
>> primary issue is that you can only jump in and out of the methods you
>> have performed this transformation on. That means you can't call
>> through any untransformed code and expect to be able to resume it.
>
> but isn't here yield responsible for that? Does this means the coroutine
> support here will allow calling yield from outside or from deep down the
> stack? It will it mean the stack will be kept? This was not clear from
> the first post. Since only one Thread is used I assumed it might not be
> the case.

Here's the Java stack leading up to the yield call in my previous example:

	at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:106)
	at ruby.__dash_e__.block_0$RUBY$__block__(-e:1)
	at ruby.__dash_e__BlockCallback$block_0$RUBY$__block__xx1.call(Unknown Source)
	at org.jruby.runtime.CompiledBlock.yield(CompiledBlock.java:105)
	at org.jruby.runtime.Block.yield(Block.java:194)
	at org.jruby.RubyArray.eachCommon(RubyArray.java:1611)
	at org.jruby.RubyArray.each(RubyArray.java:1618)
	at org.jruby.RubyArray$i_method_0_0$RUBYFRAMEDINVOKER$each.call(org/jruby/RubyArray$i_method_0_0$RUBYFRAMEDINVOKER$each.gen)
	at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:299)
	at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:117)
	at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:132)
	at ruby.__dash_e__.method__1$RUBY$each(-e:1)
	at ruby.__dash_e__Invokermethod__1$RUBY$eachFixed0.call(__dash_e__#each)
	at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:299)
	at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:117)
	at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:132)
	at ruby.__dash_e__.__file__(-e:1)

All of this would have to be instrumented to be resumable. Basically
an impossible task.

Here's another way to explain it that: what if your calls require
reflection, as most in Groovy do? You can't make a reflective call
resumable, so you're stuck.

- Charlie


More information about the mlvm-dev mailing list