Leopold Toetsch <[EMAIL PROTECTED]> writes: > Piers Cawley <[EMAIL PROTECTED]> wrote: >> Leopold Toetsch <[EMAIL PROTECTED]> writes: > >>> Matt Fowles <[EMAIL PROTECTED]> wrote: >>> >>>> Thanks for the clear explanation. I did not realize that S registers >>>> could switch pointers, that does make things a little harder. I have >>>> a recommendation for a possible hybrid solution. Incur the cost of >>>> spilling I,S,N registers heavily. Restore the state of P register. >>> >>> My conclusion was that with the copying approach I,S,N registers are >>> unusable. > >> But you only need to copy when the frame you're restoring is a full >> continuation > > Yes. With the effect that semantics of I,S,N (i.e. value registers) > suddenly changes. > >> I'd submit that, in the vast majority of cases you're not going to be >> dealing with full continuations, and on the occasions when you are the >> programmer using them will be aware of the cost and will be willing to >> pay it. > > *If* the programmer is aware of the fact that a subroutine can return > multiple times, he can annotate the source so that a correct CFG is > created that prevents register reusing alltogether. The problem is > gone in the first place. > > *If* that's not true, you'd get the effect that suddenly I,S,N registers > restore to some older values which makes this registers de facto unusable.
But they're bloody value registers. They're *supposed* to restore to the state they were in when the function was originally called. Which is what copying semantics does.