G'day all. On Fri, Apr 19, 2002 at 09:55:46AM +0100, Piers Cawley wrote:
> It's fine for partial continuations certainly, but less fine if you > want to implement full continations which require you to save the > state of the entire stack. I was hoping I'd find a way to do this > without having to wait for Parrot to get its own continuations. I suspect that using relative offsets for jump instructions might have been a bad idea in retrospect. Sure it's faster, but now we have prederef, which could turn absolute offsets into relative offsets at run time. > If > > set I0, LABEL > > sets I0 to an address which I can C<jump> to from anywhere then I have > what I need. One possible solution is to introduce a new op: inline op codeoffset(inconst INT, out INT) The idea is to turn a relative offset into an absolute address which can then be passed to "goto ADDRESS()". Another possibility is: inline op adjustoffset(in INT, inconst INT, inconst INT, out INT) { $4 = $1 + $2 - $3; goto NEXT(); } The idea is that this: adjustoffset I0, LABEL1, LABEL2, I1 will adjust an offset I0 (which is relative to LABEL1) to make it relative to LABEL2. That way, you can canonicalise all your offsets and just re-adjust them before jumping. (Note: Yes, this could be done with two existing ops. The benefit of making it another op is that a JIT compiler can easily compile it away if it chooses to use only absolute offsets.) > What's SECD by the way? http://www.wikipedia.com/wiki/SECD+machine If you have a well-stocked university library handy: @book{Henderson80, author = {Peter Henderson}, title = {{Functional Programming -- Application and Implementation}}, publisher = {Prentice/Hall International}, year = 1980, series = {Series in Computer Science}, topics = {FP - General,FP - Implementation} } Cheers, Andrew Bromage