This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Full continuations with heap-based program stack?


Am 11.09.2011 21:58, schrieb Denis Washington:
Am 11.09.2011 21:17, schrieb Per Bothner:
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.

Oh, this is great to hear!

By the way, I think the documentation on the Kawa homepage still says that full tail calls are not supported.


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.

Thanks for the pointers. I cannot promise that I'll go ahead and implement this, but I'll sure have a look at the proposal and paper and maybe I could try to help (with a bit of support :).

I went through both the proposal and the paper. Like I understood it, the approach presented in the paper is like normal full CPS except for the fact that continuation closures are only created on-demand via throwing an exception, instead of implicitly on each application, is that correct?


As such an implementation does not decrease the speed of code not using continuations much (if at all), I guess that this way of implementing continuations in Kawa is more desirable than a traditional full CPS transformation. (Many programs can do without first-class continuations, after all.) Do you think the same?

Regards,
Denis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]