<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Hi Adam,
<div><br>
</div>
<div>Thanks for looking at this complicated topic. Lifting up from bytecode makes this more challenging and was not originally factored into the design.</div>
<div>To better focus I think it would be helpful for now to place aside multi-catch. We chose to model for now using the LUB, and we can revisit later.</div>
<div><br>
</div>
<div>I am guessing you explicitly generated the bytecode example? although it is indicative of similar issues for bytecode generated from source?</div>
<div><br>
</div>
<div><br>
</div>
<div>
<blockquote type="cite">
<div class="WordSection1" style="page: WordSection1;">
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">- detach exception table entry declaration from the region entry</div>
</div>
</blockquote>
</div>
<div>
<div class="WordSection1" style="page: WordSection1;">
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><br>
</div>
</div>
</div>
<div>It’s not clear to me from this example why we need to detach the referencing of catch blocks from the exception region entry op.</div>
<div><br>
</div>
<div>Note that the exception.region op can already reference multiple catch blocks. That would likely significantly collapse the horrific number of blocks.</div>
<div><br>
</div>
<div>Will it always be the case that an exception.region.enter will dominate a corresponding exception.region.exit? It seems so, and if so an exit can reference an enter. </div>
<div><br>
</div>
<div><br>
</div>
<div>
<blockquote type="cite">
<div class="WordSection1" style="page: WordSection1;">
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">- allow exception.region.enter and exception.region.exit to enter resp. exit one or more exception table entries</div>
</div>
</blockquote>
<div><br>
</div>
<div>Is it related to region exit and re-entry along some particular path of control where eventually all paths join to the region exit? </div>
<div><br>
</div>
<br>
<blockquote type="cite">
<div class="WordSection1" style="page: WordSection1;">
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">- behavioral change: an exception thrown causes to leave all levels exception regions (transition to a handler clears the actual exception stack). The change requires each exception
 handler to explicitly declare relevant exception regions re-entries.</div>
</div>
</blockquote>
</div>
<div><br>
</div>
<div>Ok. I don’t yet fully understand this and the implications. </div>
<div><br>
</div>
<div>AFAICT another change in behavior is that a return from a method requires no preceding region exits (similar to throw).</div>
<div><br>
</div>
<div>Also with your proposal I don’t yet know the implications when lowering try/catch/finally blocks.</div>
<div><br>
</div>
<div><br>
</div>
<div>What about the following? (I am unsure of the cbranch in block_4)</div>
<div><br>
</div>
<div>
<div><br>
</div>
<div>
<div><font face="Courier New">func @"tryMethod" ()void -> {</font></div>
<div><font face="Courier New">    // Reference multiple catch blocks</font></div>
<div><font face="Courier New">    %r1 = exception.region.enter ^block_1 ^block_8 ^block_9 ^block_10;</font></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New">  ^block_1:</font></div>
<div><font face="Courier New">    %3 : int = constant @"0";</font></div>
<div><font face="Courier New">    %4 : boolean = neq %3 %3;</font></div>
<div><font face="Courier New">    cbranch %4 ^block_2 ^block_5;</font></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New">  ^block_2:</font></div>
<div><font face="Courier New">    </font><span style="font-family: "Courier New";">// %r1 dominates this operation, so we can refer to it for the catch blocks</span></div>
<div><span style="font-family: "Courier New";">    exception.region.exit %r1 ^block_3;</span></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New">  ^block_3:</font></div>
<div><font face="Courier New">    // Reenter region %r1, could be modeled as a distinct operation</font></div>
<div><font face="Courier New">    </font><span style="font-family: "Courier New";">// %r1 dominates this operation, so we can refer to it</span></div>
<div><font face="Courier New">    // %r2 is unused, or should never be used because we defer to %r1</font></div>
<div><font face="Courier New">    // Could be a no-op if region is already entered</font></div>
<div><font face="Courier New">    %r2 = exception.region.enter %r1 ^block_4;</font></div>
<div><font face="Courier New">    </font></div>
<div><font face="Courier New">  ^block_4:</font></div>
<div><font face="Courier New">    %5 : boolean = neq %3 %3;</font></div>
<div><font face="Courier New">    // Did you intend that </font><span style="font-family: "Courier New";">block_5 is referenced twice?</span><span style="font-family: "Courier New";"> </span></div>
<div><font face="Courier New">    cbranch %5 ^block_5 ^block_5;</font></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New">  ^block_5:</font></div>
<div><font face="Courier New">    // This is the join point where %r1 is definitively exited</font></div>
<div><font face="Courier New">    </font><span style="font-family: "Courier New";">// %r1 dominates this operation, so we can refer to it for the catch blocks</span></div>
<div><span style="font-family: "Courier New";">    // Error if at this point we are not in region %r1</span></div>
<div><font face="Courier New">    exception.region.exit %r1 ^block_6;</font></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New">  ^block_6:</font></div>
<div><font face="Courier New">    // Re-reference multiple catch blocks</font></div>
<div><font face="Courier New">    // Same order as %r1 but it is a distinct region w.r.t control flow</font></div>
<div><span style="font-family: "Courier New";">    %r3 = exception.region.enter ^block_7 ^block_8 ^block_9 ^block_10;</span></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New">  ^block_7:</font></div>
<div><font face="Courier New">    </font><span style="font-family: "Courier New";">// Implicit region exit for %r3</span></div>
<div><font face="Courier New">    return;</font></div>
<div><font face="Courier New">    </font></div>
<div><font face="Courier New">  ^block_8(%6 : java.lang.NullPointerException):</font></div>
<div><font face="Courier New">    </font><span style="font-family: "Courier New";">// Implicit exception region exit for %r1 and %r3</span></div>
<div><font face="Courier New">    throw %6;</font></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New">  ^block_9(%7 : java.lang.RuntimeException):</font></div>
<div><font face="Courier New">    </font><span style="font-family: "Courier New";">// Implicit exception region exit for %r1 and %r3</span></div>
<div><span style="font-family: "Courier New";">    throw %7;</span></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New">  ^block_10(%8 : java.lang.Throwable):</font></div>
<div><font face="Courier New">    </font><span style="font-family: "Courier New";">// Implicit exception region exit for %r1 and %r3</span></div>
<div><span style="font-family: "Courier New";">    throw %8;</span></div>
<div><font face="Courier New">};</font></div>
<div><font face="Courier New"><br>
</font></div>
<div>
<div style="background-color: rgb(255, 255, 255); color: rgb(8, 8, 8);">
<pre style="font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: rgb(140, 140, 140); font-style: italic;"> be  enter %r1<br></span><span style="color: rgb(140, 140, 140); font-style: italic;"> |<br></span><span style="color: rgb(140, 140, 140); font-style: italic;"> b1<br></span><span style="color: rgb(140, 140, 140); font-style: italic;">/  \<br></span><span style="color: rgb(140, 140, 140); font-style: italic;">|   \<br></span><span style="color: rgb(140, 140, 140); font-style: italic;">|   b2  exit %r1<br></span><span style="color: rgb(140, 140, 140); font-style: italic;">|   |<br></span><span style="color: rgb(140, 140, 140); font-style: italic;">|   b3  enter %r1<br></span><span style="color: rgb(140, 140, 140); font-style: italic;">|   |<br></span><span style="color: rgb(140, 140, 140); font-style: italic;">|   b4<br></span><span style="color: rgb(140, 140, 140); font-style: italic;">\  /<br></span><span style="color: rgb(140, 140, 140); font-style: italic;"> b5  exit %r1<br></span><span style="color: rgb(140, 140, 140); font-style: italic;"> |<br></span><span style="color: rgb(140, 140, 140); font-style: italic;"> b6  enter %r2<br></span><span style="color: rgb(140, 140, 140); font-style: italic;"> |<br></span><span style="color: rgb(140, 140, 140); font-style: italic;"> b7  exit %r2<br></span></pre>
</div>
</div>
</div>
<div>
<div><br>
</div>
<div><br>
</div>
<div>Paul.</div>
<div><br>
</div>
<blockquote type="cite">
<div>On Oct 8, 2024, at 5:28 AM, Adam Sotona <adam.sotona@oracle.com> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">Hi,</div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">Current exception regions model is weak in modeling nested try blocks, shared catch handlers and transitions between try blocks.  Each of this complication multiplies complexity of the
 code model.</div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">Following example consists of 9 bytecode instructions, wrapped in 3-level try catch, with two gaps and transitions between the try blocks:</div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">- method name: tryMethod</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    flags: [STATIC]</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    method type: ()V</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    attributes: [Code]</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    code:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        max stack: 1</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        max locals: 0</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        0: {opcode: ICONST_0, constant value: 0}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        1: {opcode: IFEQ, target: 8}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        4: {opcode: ICONST_0, constant value: 0}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        5: {opcode: IFEQ, target: 9}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        8: {opcode: NOP}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        9: {opcode: RETURN}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        10: {opcode: ATHROW}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        11: {opcode: ATHROW}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        12: {opcode: ATHROW}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        exception handlers:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 1: {start: 0, end: 4, handler: 10, type: java/lang/NullPointerException}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 2: {start: 4, end: 8, handler: 10, type: java/lang/NullPointerException}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 3: {start: 8, end: 10, handler: 10, type: java/lang/NullPointerException}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 4: {start: 0, end: 4, handler: 11, type: java/lang/RuntimeException}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 5: {start: 4, end: 8, handler: 11, type: java/lang/RuntimeException}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 6: {start: 8, end: 10, handler: 11, type: java/lang/RuntimeException}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 7: {start: 0, end: 4, handler: 12, type: java/lang/Throwable}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 8: {start: 4, end: 8, handler: 12, type: java/lang/Throwable}</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            handler 9: {start: 8, end: 10, handler: 12, type: java/lang/Throwable}</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">When we try to lift the above bytecode, we get following 47 blocks of model:</div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">func @"tryMethod" ()void -> {</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %0 : java.lang.reflect.code.op.CoreOp$ExceptionRegion = exception.region.enter ^block_1 ^block_46;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_1:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %1 : java.lang.reflect.code.op.CoreOp$ExceptionRegion = exception.region.enter ^block_2 ^block_44;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_2:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %2 : java.lang.reflect.code.op.CoreOp$ExceptionRegion = exception.region.enter ^block_3 ^block_41;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_3:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %3 : int = constant @"0";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %4 : boolean = neq %3 %3;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    cbranch %4 ^block_4 ^block_21;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_4:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %2 ^block_5;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_5:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %1 ^block_6;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_6:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %0 ^block_7;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_7:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %5 : java.lang.reflect.code.op.CoreOp$ExceptionRegion = exception.region.enter ^block_8 ^block_46;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;">     <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">.<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">. (skipped due to mailing list size limit)<o:p></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">.<span class="Apple-converted-space"> </span><o:p></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><o:p> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_41(%24 : java.lang.NullPointerException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %1 ^block_42(%24);</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_42(%25 : java.lang.NullPointerException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %0 ^block_43(%25);</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_43(%26 : java.lang.NullPointerException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    throw %26;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_44(%27 : java.lang.RuntimeException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %0 ^block_45(%27);</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_45(%28 : java.lang.RuntimeException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    throw %28;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_46(%29 : java.lang.Throwable):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    throw %29;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">};</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">My first proposal consists of:</div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">- detach exception table entry declaration from the region entry</div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">- allow exception.region.enter and exception.region.exit to enter resp. exit one or more exception table entries</div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">- behavioral change: an exception thrown causes to leave all levels exception regions (transition to a handler clears the actual exception stack). The change requires each exception
 handler to explicitly declare relevant exception regions re-entries.</div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">The above example model will significantly simplify and may be easily optimized even more:</div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">func @"tryMethod" ()void -> {</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %0 : java.lang.reflect.code.op.CoreOp$ExceptionRegion = exception.region ^block_8;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %1 : java.lang.reflect.code.op.CoreOp$ExceptionRegion = exception.region ^block_9;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %2 : java.lang.reflect.code.op.CoreOp$ExceptionRegion = exception.region ^block_10;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.enter %0 %1 %2 ^block_1;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_1:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %3 : int = constant @"0";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %4 : boolean = neq %3 %3;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    cbranch %4 ^block_2 ^block_5;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> </span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_2:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %0 %1 %2 ^block_3;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> </span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_3:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.enter %0 %1 %2 ^block_4;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;">    </span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_4:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %5 : boolean = neq %3 %3;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    cbranch %5 ^block_5 ^block_5;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> </span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_5:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %0 %1 %2 ^block_6;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> </span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_6:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.enter %0 %1 %2 ^block_7;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_7:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    return;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;">    </span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_8(%6 : java.lang.NullPointerException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    throw %6;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_9(%7 : java.lang.RuntimeException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    throw %7;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_10(%8 : java.lang.Throwable):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    throw %8;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">};</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">My second concern and proposal related to inability to model multi-catch try blocks. Following code:</div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    @CodeReflection</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    static void multicatch() {</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        try {</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            System.out.println("do something");</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        } catch (NullPointerException | IllegalArgumentException e) {</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            throw e;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        } catch (RuntimeException e) {</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">            return;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">        }</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    }</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">is lowered to:</div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">func @"multicatch" ()void -> {</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %0 : java.lang.reflect.code.op.CoreOp$ExceptionRegion = exception.region.enter ^block_1 ^block_4 ^block_5;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_1:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %1 : java.io.PrintStream = field.load @"java.lang.System::out()java.io.PrintStream";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %2 : java.lang.String = constant @"do something";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    invoke %1 %2 @"java.io.PrintStream::println(java.lang.String)void";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    branch ^block_2;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_2:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %0 ^block_3;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_3:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    return;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_4(%3 : java.lang.RuntimeException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %4 : Var<java.lang.RuntimeException> = var %3 @"e";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %5 : java.lang.RuntimeException = var.load %4;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    throw %5;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_5(%6 : java.lang.RuntimeException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %7 : Var<java.lang.RuntimeException> = var %6 @"e";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    return;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">};</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">Which is not correct and information about exact catch type is lost.</div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">I propose to add specific catch type to the exception table entry declaration, so the model will change to:</div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
 </p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">func @"multicatch" ()void -> {</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %0 : java.lang.reflect.code.op.CoreOp$ExceptionRegion<java.lang.NullPointerException> = exception.region ^block_4;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %1 : java.lang.reflect.code.op.CoreOp$ExceptionRegion<java.lang.IllegalArgumentException> = exception.region ^block_4;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %2 : java.lang.reflect.code.op.CoreOp$ExceptionRegion<java.lang.RuntimeException> = exception.region ^block_5;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.enter %0 %1 %2 ^block_1;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> </span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_1:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %3 : java.io.PrintStream = field.load @"java.lang.System::out()java.io.PrintStream";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %4 : java.lang.String = constant @"do something";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    invoke %3 %4 @"java.io.PrintStream::println(java.lang.String)void";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    branch ^block_2;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_2:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    exception.region.exit %0 %1 %2 ^block_3;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_3:</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    return;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_4(%3 : java.lang.RuntimeException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %4 : Var<java.lang.RuntimeException> = var %3 @"e";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %5 : java.lang.RuntimeException = var.load %4;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    throw %5;</span></div>
<p class="MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">
<span style="font-size: 9pt; font-family: Consolas;"> <span class="Apple-converted-space"> </span></span></p>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">  ^block_5(%6 : java.lang.RuntimeException):</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    %7 : Var<java.lang.RuntimeException> = var %6 @"e";</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">    return;</span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span style="font-size: 9pt; font-family: Consolas;">};</span></div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>