[Newcompiler] Finding enough bytecodes for closures.

bryce at kampjes.demon.co.uk bryce at kampjes.demon.co.uk
Wed May 2 20:02:59 UTC 2007


Klaus D. Witzel writes:
 > Given the bytecode set you proposed in the other message I'd suggest to  
 > not be lazy and add a #nonLocalReturnFromClosure bytecode which guarantees  
 > not to cancel the context-recycling condition (since a single NLR is able  
 > to cancel the full stack).

Stack recycling is canceled at the method which is returned to as
that's the context that is captured.

Implementing the bytecode you suggest should be easy. commonReturn
practically does all the work anyway so all that's left to implement
is decoding and fetching the context to return to.

It would be possible to avoid capturing the context returned to. The
return logic walks up the stack checking for exception unwinds that
may need to be performed. If there was a cheap way of checking that
the context is the one we wanted to return to without needing a
pointer to it then we could keep context recycling here.

My feeling is that a return byte code that works using commonReturn
is the way to go. Efficiency will be equivilent to the status quo, 
changes are minimal, and the implementation simple.

Bryce


More information about the Newcompiler mailing list