First-class continuations in Kawa
Arvydas Silanskas
nma.arvydas.silanskas@gmail.com
Wed Jun 9 09:04:22 GMT 2021
Has anyone taken up on this? If not, I'll give it a try.
2021-05-02, sk, 00:50 Per Bothner <per@bothner.com> rašė:
> It is indeed a shame that this has been languishing so long.
> However, we need someone to drive it - not me.
>
> It is not just a matter of merging in the code. We need someone who is
> willing to study and understand the code, test it (including writing
> testcases),
> and measure the performance.
>
> The implementation is I believe functional (conceptually - things may have
> broken over the years), but I suspect it is not very efficient. Still,
> if it works correctly (which requires testing by someone who understands
> continuations better than I do), one can always work on performance later.
>
> There is some old code dependent on the usingSPSStyle method that could
> potentially be more efficient. It is based on using the JVM tableswitch
> instruction, so it might be more efficient - at least worth studying for
> ideas.
>
> On the other hand, using MethodHandle to call all the stub procedures
> that result from CPS conversion might be better style, and would probably
> be more elegant and fit better with the existing framework:
> Basically have CALL_WITH_CONTINUATIONS build on the CALL_WITH_TAILCALLS
> framework. which uses MethodHandles.
>
> Basically, I'm hoping for someone willing who understands and wants to
> use continuations, and who is willling to put in the time to understand
> the callcc branch, how CALL_WITH_TAILCALLS uses MethodHandles, the JVM,
> and the ideas behind old commented-out usingSPSStyle code.
>
> That's a tall order - but you would learn a lot!
>
> Using Project Loom would almost certainly be more efficient and
> simpler to code - but I think it will take a long time before Loom
> is useful to us. My impression is Loom is focusing initially on
> low-overhead
> threads ("fibers"), which can use useful for some call/cc use-cases
> (such as co-routines and "async" programing - or more generally
> "single-use"
> continuations). Delimited continuations may take longer - and even
> for low-overhead threads I haven't seen any timeframe.
>
> > Or would there be some
> > compatibility issues with other JVM languages and libraries?
>
> I suspect if you create a continuation, call some Java methods
> (or Kawa code that has not been compiled with the necessary switches),
> and then invoke the continuation, I doubt it will work, at least in
> general.
> --
> --Per Bothner
> per@bothner.com http://per.bothner.com/
>
More information about the Kawa
mailing list