<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word;line-break:after-white-space">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">So good news, after a brief scan I haven't found a single method in the JDK which would violate the LIFO of the exception region entries and exits.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">FYI: I've also counted the max exception stack depth and number of gaps.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Here is a frequency table of the max exception stack depths:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">0: 205345 // methods with no exception regions<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">1: 11392 <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">2: 1866<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">3: 509<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">4: 205<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">5: 61<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">6: 23<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">7: 16<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">8: 10<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">9: 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">10: 3<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Across the JDK I found 9792 gaps in the exception regions (split exception regions).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">It would be interesting to see a model of the code with 10 layers of try/catch blocks ;)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Adam<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">babylon-dev <babylon-dev-retn@openjdk.org> on behalf of Adam Sotona <adam.sotona@oracle.com><br>
<b>Date: </b>Thursday, 10 October 2024 at 10:04<br>
<b>To: </b>Paul Sandoz <paul.sandoz@oracle.com><br>
<b>Cc: </b>babylon-dev@openjdk.org <babylon-dev@openjdk.org><br>
<b>Subject: </b>Re: ExceptionRegion modeling issues and proposed improvements<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">Paul Sandoz <paul.sandoz@oracle.com></span><o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal">> Is the catch block stack order important? Can we encounter an exception region exit that refers to B when the top of the stack is C? <o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<p class="MsoNormal">Intuitively I would say the order should be preserved and my brain model for that is a lifo stack, however that idea is inferred from JLS.<o:p></o:p></p>
<p class="MsoNormal">Practically there is nothing preventing to have a bytecode with exception table entries starting and ending independently of each other.<o:p></o:p></p>
<p class="MsoNormal">Absolute order of the exception table entries is critical, however the whole exception region (a section of bytecode handling specific exception by a specific handler) can consist of multiple exception table entries and can (theoretically)
 appear in a different relative order to other regions in different situations.<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I'll scan some code to collect all real situations versus what is theoretically possible. I think I've seen gaps (instructions exclusions) of a top level try block, while the nested was uninterrupted (however
 need to find it to confirm).</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Adam</span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>