This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: How often are continuations created?
Jost Boekemeier <jostobfe@calvados.zrz.TU-Berlin.DE> writes:
> [intermediate value rib]
>
> > I don't know where they put intermediate results, but I guess they
> > use local variables in the frame for every computation.
>
> They push them directly onto the control frame. For example
>
> (v 1 (p 9) 2) translates into
>
> push 2
> make-frame ;; -> push FRAME_DYNAMIC_LINK; push FRAME_RETURN_ADDRESS;
> push 9
> loadt p
> call 1
> push
> push 1
> make-frame
> loadt v
> call 3
Looks similar to mine, but I don't understand when they use make-frame.
Is there a reference that explains their algorithm?
> A simple fix would be to turn the value stack into a scheme list and
> push a pointer to it onto the control stack. -- Not elegant but the
> hybrid solution needs a value rib anyway. :) But maybe there is a
> better solution?
Hmm, you'll need to modify the POP operation, which makes the VM slows
down. I think keeping the current simple implementation is a good thing
and sufficiently fast. To avoid the worst case, maybe you'll want to
implement a "copy when needed" method. I still use stack segments, so
not all segments need not be copied when a continuation is reinstated.
By the way, you might want to use make_vm_frame to convert the stack to
heap-allocated frames. I implemented this for simple backtraces.