<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=Windows-1252">
<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:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:12.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
font-size:12.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:896555108;
mso-list-type:hybrid;
mso-list-template-ids:1219020050 988458580 134807577 134807579 134807567 134807577 134807579 134807567 134807577 134807579;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1
{mso-list-id:1433359411;
mso-list-template-ids:-643111406;}
@list l1:level1
{mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level2
{mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level3
{mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level4
{mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level5
{mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level6
{mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level7
{mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level8
{mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level9
{mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style>
</head>
<body lang="en-CZ" link="#0563C1" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">I see it a bit opposite.<o:p></o:p></span></p>
<ol style="margin-top:0cm" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo3"><span lang="EN-US" style="font-size:11.0pt">Processing stack maps is extremely advanced feature and 99.9% of users don’t want to touch it, so why
</span><span style="font-size:11.0pt">PROCESS_STACK_MAP</span><span lang="EN-US" style="font-size:11.0pt"> is off by default and GENERATE_STACK_MAPS is on by default<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo3"><span lang="EN-US" style="font-size:11.0pt">When the 0.1% user needs to process the stack maps, he needs full control over it. So when user enables
</span><span style="font-size:11.0pt">PROCESS_STACK_MAP</span><span lang="EN-US" style="font-size:11.0pt">, full control of what drops to code builder is up-to user.<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo3"><span lang="EN-US" style="font-size:11.0pt">Most of the #2 cases are complex transformations (3-way merges, instrumentations, etc…) and per-method control is important. For example
jdk.jfr class instrumentation involve all cases:<o:p></o:p></span></li><ol style="margin-top:0cm" start="1" type="a">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level2 lfo3"><span lang="EN-US" style="font-size:11.0pt">Some methods from the first (shared CP) source are unchanged and so original stack maps can be reused<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level2 lfo3"><span lang="EN-US" style="font-size:11.0pt">Some methods from the second source (non-shared CP) are also unchanged, so inflated stack maps can be passed down the transformation<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level2 lfo3"><span lang="EN-US" style="font-size:11.0pt">Some methods are combined from both sources, so user may need to manually combine stack maps or just little adjust existing maps<o:p></o:p></span></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level2 lfo3"><span lang="EN-US" style="font-size:11.0pt">Some methods may be synthetized from scratch and generated stack maps are first choice<o:p></o:p></span></li></ol>
</ol>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">By dropping </span>
<span style="font-size:11.0pt">PROCESS_STACK_MAP</span><span lang="EN-US" style="font-size:11.0pt"> switch and keep it always on we would slow down a bit parsing for 99.9% cases.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">GENERATE_STACK_MAPS switch as the only one would not allow per-method individual handling.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">If we want to reduce number of switches I would rather drop GENERATE_STACK_MAPS as the StackMapTableAttribute is mandatory and when user does not provide/transform its own – we should generate
it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<b><span style="color:black">From: </span></b><span style="color:black">Brian Goetz <brian.goetz@oracle.com><br>
<b>Date: </b>Wednesday, 17 August 2022 18:25<br>
<b>To: </b>Adam Sotona <adam.sotona@oracle.com>, classfile-api-dev@openjdk.org <classfile-api-dev@openjdk.org><br>
<b>Subject: </b>Re: RFR: Classfile API stack maps processing</span><span style="color:black;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span style="font-size:13.5pt;font-family:"Courier New"">I'd like to be a little more aggressive on that: if generation is not disabled, then any stack map sent downstream is dropped on the floor, and either the original stackmap reused, or a new one generated.
Generating stack maps is definitely an advanced, error-prone feature; users should have to turn it on.
<br>
<br>
Given this, though, I think we can drop the PROCESS_STACK_MAP attribute, and always send it downstream, as this costs us almost nothing and the user can ignore it.
<br>
<br>
We should definitely not generate Code attributes with more than one stack map attribute in them.
</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">On 8/17/2022 12:02 PM, Adam Sotona wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="font-size:11.0pt">Yes, user can send the stack maps to the builder anytime and it will disable generation for the actual method.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="font-size:11.0pt">However user has to explicitly construct the attribute:</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="font-size:11.0pt">cob.with(StackMapTableAttribute.of(List.of(StackMapFrameInfo.of(myLabel, locals, stack), …));</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="font-size:11.0pt">Generation switch works independently, so user can keep the generation on for some methods and explicitly specify/transform StackMapTableAttribute for other methods
of the same class.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:72.0pt">
<b><span style="color:black">From: </span></b><span style="color:black">Brian Goetz
<a href="mailto:brian.goetz@oracle.com"><brian.goetz@oracle.com></a><br>
<b>Date: </b>Wednesday, 17 August 2022 17:53<br>
<b>To: </b>Adam Sotona <a href="mailto:adam.sotona@oracle.com"><adam.sotona@oracle.com></a>,
<a href="mailto:classfile-api-dev@openjdk.org">classfile-api-dev@openjdk.org</a> <a href="mailto:classfile-api-dev@openjdk.org">
<classfile-api-dev@openjdk.org></a><br>
<b>Subject: </b>Re: RFR: Classfile API stack maps processing</span><o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:72.0pt">
<span style="font-size:13.5pt;font-family:"Courier New"">See the RFR, I think I found a place where we might end up putting TWO stack map attributes into the builder.
<br>
<br>
With this patch, I believe the treatment of stack maps is intended to be:<br>
<br>
if (generation not disabled) { <br>
try to reuse original stackmap, if transforming and code array/exception table is unchanged<br>
otherwise generate stack map<br>
}<br>
else { <br>
if a stack map has been sent to the builder, put that in the class file<br>
}<br>
<br>
I am not sure this is the effect, though; since the user can send stack maps down the pipe and they are stored as attributes regardless of options, I think these may be written to the classfile even if we are in generation mode.
<br>
<br>
</span><o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:72.0pt">On 8/17/2022 11:45 AM, Adam Sotona wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Hi,</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">I would like to ask for review of proposed change in the Classfile API stack maps processing.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Primary motivation is to better align stack maps processing with the Classfile API and to allow manual constructions and transformations of stack maps.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Pull request for review is here:
<a href="https://github.com/openjdk/jdk-sandbox/pull/32">https://github.com/openjdk/jdk-sandbox/pull/32</a></span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">And it includes following changes:</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]><span lang="EN-US" style="font-size:11.0pt">New boolean Classfile.Option::processStackMaps with default to false has been added</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]><span style="font-size:11.0pt">StackMapTableAttribute</span><span lang="EN-US" style="font-size:11.0pt"> become a CodeElement processed when the above option is explicitly enabled by user</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">3.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]><span style="font-size:11.0pt">StackMapTableAttribute</span><span lang="EN-US" style="font-size:11.0pt">, StackMapFrameInfo, VerificationTypeInfo, SimpleVerificationTypeInfo, ObjectVerificationTypeInfo and UninitializedVerificationTypeInfo
have been simplified, refactored to use Labels instead of offsets and equipped with relevant static factory methods</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">4.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]><span lang="EN-US" style="font-size:11.0pt">Redundant content of the StackMapFrameInfo and its sub-classes reflecting compressed frame forms have been removed</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">5.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]><span lang="EN-US" style="font-size:11.0pt">UnboundStackMapTableAttribute with proper serialization has been implemented</span><o:p></o:p></p>
<p class="MsoListParagraph" style="margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<![if !supportLists]><span style="mso-list:Ignore">6.<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]><span lang="EN-US" style="font-size:11.0pt">CorpusTest with RebuildingTransformations has been extended to process stack maps using the new API</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">New stack maps processing option affects inflation of stack maps and appearance of StackMapTableAttribute in the CodeElement stream.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Enabled stack maps processing inflates and decompresses StackMapTableAttribute with translated offsets to Labels and pass it to CodeTransformation(s).</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">User can individually filter StackMapTableAttribute out or transform it manually when explicitly enabled stack maps processing.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">User-provided or transformed StackMapTableAttribute passed to CodeBuilder overrides stack maps generation process for the actual method.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Compressed source form of the parsed stack map frame can be identified from StackMapFrameInfo::tag</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">All new created StackMapFrameInfos always represent full frames with complete list of locals and stack.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Compression of StackMapTableAttribute frames is contextual operation and it is applied at the writing phase.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Any NO-OP transformation of inflated and decompressed StackMapTableAttribute may result in a different compressed form.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Performance boost tricks by-passing stack maps generation for unchanged methods are unaffected by this enhancement.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Thanks for your comments,</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt">Adam</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:72.0pt"><span lang="EN-US" style="font-size:11.0pt"> </span><o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:72.0pt"><span style="font-size:11.0pt;mso-fareast-language:EN-GB"> </span><o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt;mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
</div>
</body>
</html>