[LLVMdev] LLVM and coroutines/microthreads

Jonathan D. Turner jonathan.d.turner at gmail.com
Thu Apr 16 08:47:57 PDT 2009


I saw this was mentioned briefly last year, but there seemed to be
some confusion as to what coroutines entailed and the thread died out.
 This technique has an unfortunate number of names, but it does get a
lot of use, including popular languages like Ruby.

I'm currently working on a programming language called Minnow
(http://www.minnow-lang.org).  It's an actor-based language, where
each actor has its own microthread.  In the current implementation I'm
manually saving and restoring the stack and live variables by hand to
get this effect.  After spending months wrestling with these manual
continuations, I can safely say they are a total pain in the butt.
The story doesn't improve much with 3rd party coroutine libraries,
which have their own limitations (for instance, can you resume a
microthread on a different OS thread than it was created?).

The million dollar question is: can LLVM capture the live variables
and stack into a buffer?  Or, even just save off register variables to
the stack, and give me a way to capture and restore that stack (and
pc)?

Thanks,

Jonathan



More information about the llvm-dev mailing list