[code-reflection] RFR: Exception regions patch

Adam Sotona asotona at openjdk.org
Thu Oct 17 14:43:26 UTC 2024


On Thu, 17 Oct 2024 14:21:52 GMT, Adam Sotona <asotona at openjdk.org> wrote:

> Proposed partial change of the `exception.region.enter` and `exception.region.exit`, as discussed at https://mail.openjdk.org/pipermail/babylon-dev/2024-October/001674.html
> 
> Summary of the change:
> - `exception.region.enter` catch handler blocks appear in reverse order of the try/catch declaration to reflect natural nesting "outer first"
> - return typeof `exception.region.enter` is void
> - `exception.region.exit` does not refer to `exception.region.enter`, its first successor is end block and following successors are catch handler blocks in order as they appear in try/catch declaration (reverse to `exception.region.enter` order)
> - `Interpreter`, `BytecodeGenerator`, `BytecodeLift`, `ExtendedOp`, `NormalizeBlockTransformer` and tests are fixed
> - no change in the documentation is a part of this PR
> 
> Please review.
> 
> Thanks,
> Adam

Minor disadvantage of this proposed exception regions model (similar to the actual model) is mandatory restoring of the exception stack when an exception is thrown in nested regions. Proposed change marks the actual exception stack position at the region entry and it is restored when any of the handled exception is thrown (to preserve actual "grouping" entry behavior). However there are theoretical situations, where it can cause problems (for example partial nested re-entries).

As a next step I suggest to go further and state the exception stack is cleared on any throw and it is each handler responsibility to explicitly declare exception region re-entries.

-------------

PR Comment: https://git.openjdk.org/babylon/pull/256#issuecomment-2419741755


More information about the babylon-dev mailing list