<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Indeed, I noted that our StackMapGenerator eagerly checks if a newly encountered store instruction (the istore_1 in the exception handler range) breaks the stack maps, and our StackMapGenerator would have failed fast in that case.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Chen</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Adam Sotona <adam.sotona@oracle.com><br>
<b>Sent:</b> Wednesday, January 29, 2025 11:35 AM<br>
<b>To:</b> Mark Roberts <markro@cs.washington.edu>; classfile-api-dev@openjdk.org <classfile-api-dev@openjdk.org><br>
<b>Cc:</b> Chen Liang <chen.l.liang@oracle.com><br>
<b>Subject:</b> Re: [External] : RE: StackMap problem</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Aptos}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
        {color:blue;
        text-decoration:underline}
.x_MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
        {}
-->
</style>
<div lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">I see, the
</span><span style="font-size:11.0pt">frame is listed at the end of the line.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">Key question still remains – how the instrumentation is done?</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">Class- File API regenerates the stack map when I create similar method and inject the istore_1 and iload_1 instructions.
</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">Adam</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif"> </span></p>
<div id="x_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="x_MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black">From:
</span></b><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black">Mark Roberts <markro@cs.washington.edu><br>
<b>Date: </b>Wednesday, 29 January 2025 at 17:45<br>
<b>To: </b>Adam Sotona <adam.sotona@oracle.com>, classfile-api-dev@openjdk.org <classfile-api-dev@openjdk.org><br>
<b>Cc: </b>Chen Liang <chen.l.liang@oracle.com><br>
<b>Subject: </b>[External] : RE: StackMap problem</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:11.0pt">The ‘before’ was compiled with javac version 24-ea+22-269, but I compiled with javac version 17.0.11 and got the exact same binary.  The stack map frames are there:</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">  StackMapTable:</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">  StackMap((SAME_LOCALS_1_STACK, offset delta=19, stack items={(type=Object, class=DataStructures.Overflow)}), (SAME, offset delta=0))</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">The first (@19) is the target of the exception handler, the second (@20) is the target of the branch @16.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">It all looks good to me.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">Mark</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b><span style="font-size:11.0pt">From:</span></b><span style="font-size:11.0pt"> Adam Sotona <</span><a href="mailto:adam.sotona@oracle.com"><span style="font-size:11.0pt">adam.sotona@oracle.com</span></a><span style="font-size:11.0pt">>
<br>
<b>Sent:</b> Wednesday, January 29, 2025 1:07 AM<br>
<b>To:</b> Mark Roberts <</span><a href="mailto:markro@cs.washington.edu"><span style="font-size:11.0pt">markro@cs.washington.edu</span></a><span style="font-size:11.0pt">>;
</span><a href="mailto:classfile-api-dev@openjdk.org"><span style="font-size:11.0pt">classfile-api-dev@openjdk.org</span></a><span style="font-size:11.0pt"><br>
<b>Cc:</b> Chen Liang <</span><a href="mailto:chen.l.liang@oracle.com"><span style="font-size:11.0pt">chen.l.liang@oracle.com</span></a><span style="font-size:11.0pt">><br>
<b>Subject:</b> Re: StackMap problem</span></p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">Hi Mark,</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">Both attached class listings are missing stack map frames at branch targets, and they seem to be invalid.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">I would like to ask what compiler generates the first class and how your tool adds the instrumentation code.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">My first impression is that I don’t see any trace of Class-File API stack map generator involment. Transformation of a method with missing or invalid stack map would generate
 new stack maps, unless explicitly disabled.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">Thanks,</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif">Adam</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Aptos",sans-serif"> </span></p>
<div id="x_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="x_MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black">From:
</span></b><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black">classfile-api-dev <</span><a href="mailto:classfile-api-dev-retn@openjdk.org"><span style="font-size:12.0pt; font-family:"Aptos",sans-serif">classfile-api-dev-retn@openjdk.org</span></a><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black">>
 on behalf of Mark Roberts <</span><a href="mailto:markro@cs.washington.edu"><span style="font-size:12.0pt; font-family:"Aptos",sans-serif">markro@cs.washington.edu</span></a><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black">><br>
<b>Date: </b>Tuesday, 28 January 2025 at 21:45<br>
<b>To: </b></span><a href="mailto:classfile-api-dev@openjdk.org"><span style="font-size:12.0pt; font-family:"Aptos",sans-serif">classfile-api-dev@openjdk.org</span></a><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black"> <</span><a href="mailto:classfile-api-dev@openjdk.org"><span style="font-size:12.0pt; font-family:"Aptos",sans-serif">classfile-api-dev@openjdk.org</span></a><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black">><br>
<b>Cc: </b>Chen Liang <</span><a href="mailto:chen.l.liang@oracle.com"><span style="font-size:12.0pt; font-family:"Aptos",sans-serif">chen.l.liang@oracle.com</span></a><span style="font-size:12.0pt; font-family:"Aptos",sans-serif; color:black">><br>
<b>Subject: </b>StackMap problem</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:11.0pt">The existence of compiler generated, unnamed local temps (no LocalVariable code element) seems to cause a problem with stack maps.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">The ‘source’ attachment shows the problem method.   The ‘before’ attachment shows the generated code before instrumentation.  Note that the compiler generates an unnamed temp at slot 0 to store the exception
 code. The stackmap for the branch target says same locals, which is correct.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">The ‘after’ attachment shows the code generated after our tool has added instrumentation code – note the addition of a new local variable at slot 1.  The stackmap for the branch target still says same locals,
 which is no longer correct. This causes the iload_1 @41 to fail.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">I tried to see if this issue has already been reported, but I was unable to figure out how to search
</span><a href="https://urldefense.com/v3/__https:/bugs.java.com/bugdatabase/__;!!ACWV5N9M2RV99hQ!Oxj6SR2NV9Ad-EfEdNCFmjPL0gx3yAPgZ8jQoj8jWrlF9W-NohRiSuxWzqdOPpnNxoTuYr4zSmL9s1LDi14H1ymI$"><span style="font-size:11.0pt">https://bugs.java.com/bugdatabase/</span></a><span style="font-size:11.0pt">
 by keyword.</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt">Mark</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>