Try/catch/finally builder
Paul Sandoz
paul.sandoz at oracle.com
Tue Aug 30 21:33:39 UTC 2022
Here’s an initial try at that.
https://github.com/openjdk/jdk-sandbox/compare/classfile-api-branch...PaulSandoz:jdk-sandbox:try-catch-finally-builder?expand=1
BlockCodeBuilder tracks labels created via newLabel, and returns a “live” set of those labels. When a label is to be bound we reject labels that are not members of that set (we need to be careful to propagate the LabelTarget pseudoinstruction to the terminal builder).
We inline a finally block if a the target label of a branch instruction is not a member of the block's labels.
Ideally when block goes out of scope then all the block’s labels become “dead” and therefore they can never be used as targets (or bound if not already).
Paul.
> On Aug 25, 2022, at 5:49 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
>
>
> So here's another possible thought: what if BlockBuilder could dispense labels, as well as dispensing blocks, and could then keep track of containment? So if you are branching to a label *outside this block builder* (including returning), we'd inline the finally at that point. (With nested block builders, we'd have to keep track of which BBs belonged to other BBs, but we already do this.)
>
More information about the classfile-api-dev
mailing list