[Ironruby-core] Entering try-catch with non-empty stack

Charles Oliver Nutter charles.nutter at sun.com
Mon Oct 1 23:45:25 EDT 2007


Tomas Matousek wrote:
> We are thinking about an AST transformation that would push forward expression evaluations, store results to temp variables and reload them where necessary. But we didn't conclude on this yet. Introducing additional method calls is IMO not necessary.

To me the complexity of this approach is for many nested sets of such 
expressions:

x = 1
x += begin
   x += begin
     x += begin
       x += begin
         raise
       rescue
         1
       end
     end
   end
end

This is somewhat contrived, but there are many cases of at least a 
couple nested expressions with exception handling that may happen during 
stack-building. You would need to continue pushing down and storing 
values on the stack at each level, restoring as you climb back out.

FWIW, the above works ok in JRuby right now, but if the begin/rescue is 
replaced with while loops it fails to compile. I will likely have to use 
the same approach for while loops, since they also implicitly handle 
LocalJumpError exceptions.

- Charlie


More information about the Ironruby-core mailing list