Hi,

To note in e.g. logic programming one can inline a lot of code and 
the final result of peval is that it will and should not expand the lambdas at site 
due to code explosion. What happens now, as I understand, is that closures
are created at a resulting quite hefty overhead. In stead if one employed
local functions inside the stack and issued a goto to these functions and a
corresponding return to the call site with return value in appropriate slot we 
would be much better off because we would simply not need to create closures
on the heap and have very low overhead in the argument handling and function
dispatch. To make this work we would only need to have named gotos, the rest
should be handled by the scheme in scheme compiler.

So there are good arguments to have
1. Named goto operations in the VM
2. A notion of local execution unit that are of two kinds
   i)  Stateless aka functions, can reuse register space
   ii) Statefull  aka need to allocate a fixed register space to the local funciton

WDYT?




On Fri, Aug 30, 2013 at 8:54 PM, Stefan Israelsson Tampe <stefan.itampe@gmail.com> wrote:
Hi all,

In the wake of the wowely code Andy Mark and Noah have been producing
I want to lift the question of what we can do to compile some
delimeted continuation code effeciently.

Delimeted continuations can be looked upon as a generalization of
common lisps tagbody e.g. it's trivial to produce tagbody semantics
with the help of prompts. Now a quesiton is how we should make sure
that most sane code that can be compiled to goto's in the rtl backend
really get that far. As I understand the cps compiler is well suited
to take on this task. But we should not aim towards atgbody, but also
generators and similar constructs. To see what kind of semantics to
support maybe the code in

  https://gitorious.org/guile-coroutines/guile-
coroutines/source/fc49d41dfa0cc0647aaeeddf8fb15d55dc2fb6ef:stis/coroutine.scm

Can help as well as the example in the same repo,

https://gitorious.org/guile-coroutines/guile-
coroutines/source/fc49d41dfa0cc0647aaeeddf8fb15d55dc2fb6ef:stis/coroutine/test.scm

So what can we do in rtl that we cannot do before? To note here is
that in rtl we can basically allocate a region of the register space
for e.g. a generator. The nice thing with rtl is that all functions
are executed at the end of the register space and therefore we could
basically use named gotos to jump between the different
generators located at different stack areas. This is not possible in a
stack based VM. So not only do we skip expensive function call's but
tear down and setup of the stack is not needed. Of cause to be
able to take advantage of this not all generators can be used in such
a scheme. (It would be nice to get Academic references for this) but
it should be doable.

We would need some more one more instruction from RTL, namely named
gotos.

It's also perhaps possible to enlarge the ideas to separate where
functions are evaluated and where the "local rigister area" of the
generator is
situated. E.g. An area allocated from the heap. But this lead to a
complete redesign of RTL but it would could be a cool concept.

WDYT?