This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Full continuations with heap-based program stack?
- From: Per Bothner <per at bothner dot com>
- To: Denis Washington <denisw at online dot de>
- Cc: kawa at sourceware dot org
- Date: Sun, 11 Sep 2011 12:17:10 -0700
- Subject: Re: Full continuations with heap-based program stack?
- References: <4E6CF79A.8060004@online.de>
On 09/11/2011 11:02 AM, Denis Washington wrote:
I understand that the JVM does not have any support for continuations
and does also not allow to introspect the program stack. So I guess the
only way to support full first-class continuations in Kawa would be to
move the complete program stack used by Scheme code onto the heap. This
would probably also make it possible to support full tail-call
elimination, as the stack would then be fully introspectable.
Kawa already supports full tail-call elimination. Just run/compile
with the --full-tailcalls flag.
Given that the JVM does is not able support these essential Scheme
features, and that this will probably not change soon (if ever, let
alone for non-openjdk based VMs such as Dalvik), such an approach might
well be appropiate for implementation within Kawa. However, it seems as
if this change would have a rather big performance impact, so maybe it
would be a better idea to make this behavior optional for those
applications where full continuation and tail call support is not required.
Is there a possibility that something like this could be implemented in
Kawa? Is there maybe someone actually working on it? If not, I could
help to implement this, though I don't know anything about the Kawa code
base currently.
There is nobody currently working on it, though it's long been on the
wish-list.
In fact there is some long-dead experimental unfinished code in the
code-base
- search for usingCPStyle in gnu/expr/*.java.
There was a Goggle Summer of Code proposal for full continuations, but
unfortunately we didn't get enough "slots":
http://www.google-melange.com/gsoc/proposal/review/google/gsoc2011/tartanllama/1
In addition to reading the proposal, I suggest studying:
http://www.ccs.neu.edu/scheme/pubs/stackhack4.html
Even if you don't follow the approach in that link, it point out the kind
of re-writing that would be needed. Basically, it seems feasible to get full
continuations without too much pain by doing certain transformations on the
abstract syntax tree (awa's Expression nodes), and then just compiling with
full-tailcalls support enabled.
--
--Per Bothner
per@bothner.com http://per.bothner.com/