Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #686 > unrolled thread

grab the continuation at specific point in a program

Started byYakov Z <yakov@clickgrab.net>
First post2012-06-09 10:07 -0700
Last post2012-06-11 13:22 +0200
Articles 2 — 2 participants

Back to article view | Back to comp.compilers


Contents

  grab the continuation at specific point in a program Yakov Z <yakov@clickgrab.net> - 2012-06-09 10:07 -0700
    Re: grab the continuation at specific point in a program torbenm@diku.dk (Torben Ægidius Mogensen) - 2012-06-11 13:22 +0200

#686 — grab the continuation at specific point in a program

FromYakov Z <yakov@clickgrab.net>
Date2012-06-09 10:07 -0700
Subjectgrab the continuation at specific point in a program
Message-ID<12-06-025@comp.compilers>
AFAIU, to grab the continuation at specific point in a program I still
have to do CPS conversion of the whole program (because CPS is global)
I then end up with a lot of uninteresting continuations (like for
constants and variables etc.)

If I want to get rid of those and leave only one "at that point"
continuation (with everything on which it depends upward the call
path) I need to perform another transformation.  Do you know if
approaches exist to do the above in one run?

[toc] | [next] | [standalone]


#692

Fromtorbenm@diku.dk (Torben Ægidius Mogensen)
Date2012-06-11 13:22 +0200
Message-ID<12-06-031@comp.compilers>
In reply to#686
Yakov Z <yakov@clickgrab.net> writes:

> AFAIU, to grab the continuation at specific point in a program I still
> have to do CPS conversion of the whole program (because CPS is global)
> I then end up with a lot of uninteresting continuations (like for
> constants and variables etc.)
>
> If I want to get rid of those and leave only one "at that point"
> continuation (with everything on which it depends upward the call
> path) I need to perform another transformation.  Do you know if
> approaches exist to do the above in one run?

You don't need CPS conversion if you can get access to the computation
state -- specifically the function call stack.  The continuation is in
that case "just" a copy of the call stack.  This makes it rather costly
to grab or call a continuation, but there is next to no cost for
programs not using call/cc.  If the call "stack" is represented by a
linked list, grabbing and using continuations is cheaper, but it means
you have to GC the call frames instead of unstacking them, which may or
may not be more expensive.  CPS transformation gives essentially the
same effect, as closures are typically heap allocated.

In all cases, continuations are a bit questionable if you have mutable
variables: When a continuation is called, do you want to return these to
the state they had at the time the continuation was grabbed, or do they
keep the values they have at the time of the call?  Is there a
difference between register-allocated variables, stack-alloctaed
variables and heap-allocated variables?  The answers to these questions
may limit the choices of how to implement continuations.

	Torben

[toc] | [prev] | [standalone]


Back to top | Article view | comp.compilers


csiph-web