Perhaps more controversially, it also makes it an error if clear_eh
finds something other than an exception at TOS. The original code did
nothing, which doesn't seem right. Error handlers are lexical features
of the source code, as are most other things on the control stack [1],
so finding a non-exception at TOS indicates a compiler bug (or a logic
error in hand-written PIR). Fortunately, this doesn't affect any of the
existing test cases -- so I added a new one to test regression.
You could also argue that the stack unwinding in
RetContinuation.invoke is broken. I tend to agree, but any such fix
would be superceded by an implemention of rezipping. This pop_exception
fix might also have to change, but probably only in detail.
-- Bob
[1] The sole exception is the return address used by the bsr/jsr and
ret instructions; these aren't bound to any lexical features of the
compiled language.
If sub A pushes an error handler and then calls B, B can do a
'clear_eh' to get rid of A's handler. This seems to work until B
returns, at which point the control stack unwinding done by
RetContinuation destroys the rest of the stack looking for the missing
handler. The patch detects the problem in clear_eh, and signals a
real_exception . . .
You could also argue that the stack unwinding in
RetContinuation.invoke is broken. I tend to agree, but any such fix
would be superceded by an implemention of rezipping. This pop_exception
fix might also have to change, but probably only in detail.
Just in case this patch is still under consideration, I would like to
withdraw it; I think it's better to include it as part of the
rezipping-related control stack cleanup (the design rev for which is
still in progress). Unless somebody would like to see a patch with just
the test cases, both marked 'TODO'?
-- Bob Rogers
http://rgrjr.dyndns.org/
Foolish question, I suppose. On the other hand, who knows when someone
might say, "Hey, that's not a bug; I need that!" . . .
-- Bob
I've now implemented the proposed stricter clear_eh semantics. That is
* clear_eh can only clear exception handlers
* and only from the current context
Tests unTODOed and applied - r11444
Thanks,
leo