Jens Rieks <[EMAIL PROTECTED]> writes:

> Hi,
>
> does the attached test use the Continuation in a correct way?
> The test failes, what am I doing wrong?

Without running it I'm guessing that it prints out something like

456=789
456=456
123=123

And on running it, I see that I'm right.

Remember that invoking a continuation does nothing to the existing
register state (which is as it should be).

So why does it work like this?

Letting IMCC handle calling _func saves all the registers and sets P1
to a RetContinuation that points to _func's return point (which is sort
of inside the _func() line because of the stuff IMCC does on a function
return). 

_func then sets P16-18 to 4-6 respectively and you make the
continuation.

Calling _do_something saves all the registers and sets P1 to
(essentially) _end

_do_something sets P16-18 to 7-9 then jumps through the continuation
back to _end.

Which prints out '456=789' because P16-18 haven't been restored

Then it returns. Returning invokes P1, which is currently set to point
to _end. However, returning using .pcc_*_return also restores the
registers, which means P16-18 now contain 4-6, so it prints out
456=456 and returns through P1, which now boints back to the original
place that _func was called from.

Easy.

One part of your problem (The state of P16-18) is, therefore, a bug in
your program. The other part seems to be a bug in the current
implementation of Continuation.

A new Continuation should grab the current P1 continuation. If you
later invoke that Continuation, it should make the jump and reset
P1. Until that's done, all we have is a heavyweight goto.

Reply via email to