<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;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@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:541747565;
        mso-list-template-ids:-1538253356;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:36.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:72.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:108.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:144.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:180.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:216.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:252.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:288.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7 ;
        mso-level-tab-stop:324.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style>
</head>
<body lang="en-CZ" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="color:black">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">I would like to hear your comments to proposed optional stack tracking functionality integrated in CodeBuilder.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black">Here is the pull request proposing to add</span><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#24292F">:</span><span style="color:black"><o:p></o:p></span></p>
<ul style="margin-top:0cm;caret-color: rgb(0, 0, 0);font-variant-caps: normal;orphans: auto;text-align:start;widows: auto;-webkit-text-size-adjust: auto;-webkit-text-stroke-width: 0px;word-spacing:0px" type="disc">
<li class="MsoNormal" style="color:#24292F;margin-top:3.0pt;mso-list:l0 level1 lfo1">
<span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">Classfile.Option::trackStack boolean option with default to false</span><span class="apple-converted-space"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"> </span></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">(the
 new option enabling stack tracking during code build)</span><o:p></o:p></li><li class="MsoNormal" style="color:#24292F;margin-top:3.0pt;mso-list:l0 level1 lfo1">
<span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">Optional<Collection</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"><TypeKind></span><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">> CodeBuilder::stack</span><span class="apple-converted-space"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"> </span></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">–
 a method returning view of the actual stack synchronously during the build process (if enabled)</span><o:p></o:p></li><li class="MsoNormal" style="color:#24292F;margin-top:3.0pt;mso-list:l0 level1 lfo1">
<span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">Optional</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"><Integer></span><span class="apple-converted-space"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"> </span></span><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">CodeBuilder::maxStackSize</span><span class="apple-converted-space"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"> </span></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">-
 a method calculating maxStackSize (if enabled)</span><o:p></o:p></li><li class="MsoNormal" style="color:#24292F;margin-top:3.0pt;mso-list:l0 level1 lfo1">
<span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">impl.StackTracker implementation</span><span class="apple-converted-space"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"> </span></span><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">–
 a lightweight synchronous stack tracker</span><o:p></o:p></li><li class="MsoNormal" style="color:#24292F;margin-top:3.0pt;mso-list:l0 level1 lfo1">
<span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif">StackTrackerTest tests</span><o:p></o:p></li></ul>
<p class="MsoNormal"><span style="color:#24292F"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#24292F">Beside the stack tracking the pull request adds  </span><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#24292F">ConstantInstruction::typeKind and</span><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#24292F">
</span><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#24292F">LoadableConstantEntry::typeKind</span><span class="apple-converted-space"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#24292F"> methods
 self-describing ConstantInstruction and LoadableConstantEntry (not just) for the stack tracking purpose.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="color:#24292F"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-top:3.0pt"><span lang="EN-US" style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#24292F">Here is the pull request:</span><span style="color:#24292F"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:black"><a href="https://github.com/openjdk/jdk-sandbox/pull/34" title="https://github.com/openjdk/jdk-sandbox/pull/34">https://github.com/openjdk/jdk-sandbox/pull/34</a></span><span style="color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">Primary purpose of the lightweight synchronous stack tracking is to support building of complex swap functions like stack-to-locals and locals-to-stack in CodeBuilder.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Example use case can be found in the StackTrackerTest:<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">        Classfile.build(ClassDesc.of(</span><span style="font-size:10.0pt;font-family:"Courier New";color:#1E9347;mso-fareast-language:EN-GB">"Foo"</span><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">),
 List.of(<b>Classfile.Option.trackStack(</b></span><b><span style="font-size:10.0pt;font-family:"Courier New";color:#336BDD;mso-fareast-language:EN-GB">true</span></b><b><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">)</span></b><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">),
 clb -><o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">            clb.withMethodBody(</span><span style="font-size:10.0pt;font-family:"Courier New";color:#1E9347;mso-fareast-language:EN-GB">"m"</span><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">,
 MethodTypeDesc.of(ConstantDescs.CD_Void), 0, cob -> {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                assertEquals(<b>cob.stack()</b>.get(), List.of<b>()</b>);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                cob.<b>aload</b>(0);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                assertEquals(<b>cob.stack()</b>.get(), List.of(<b>ReferenceType</b>));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                cob.<b>lconst</b>_0();<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                assertEquals(<b>cob.stack()</b>.get(), List.of(<b>LongType, ReferenceType</b>));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                cob.trying(tryb -> {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    assertEquals(<b>tryb.stack()</b>.get(), List.of(<b>LongType, ReferenceType</b>));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    tryb.<b>iconst</b>_1();<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    assertEquals(<b>tryb.stack()</b>.get(), List.of(<b>IntType, LongType, ReferenceType</b>));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    tryb.ifThen(thb -> {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                        assertEquals(<b>thb.stack()</b>.get(), List.of(<b>LongType, ReferenceType</b>));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                        thb.<b>constantInstruction</b>(ClassDesc.of(</span><span style="font-size:10.0pt;font-family:"Courier New";color:#1E9347;mso-fareast-language:EN-GB">"Phee"</span><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                        assertEquals(<b>thb.stack()</b>.get(), List.of(<b>ReferenceType, LongType, ReferenceType</b>));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                        thb.<b>athrow</b>();<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                        assertFalse(<b>thb.stack().isPresent()</b>);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    });<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    assertEquals(<b>tryb.stack()</b>.get(), List.of(<b>LongType, ReferenceType</b>));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    tryb.<b>return</b>_();<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    assertFalse(<b>tryb.stack().isPresent</b>());<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                }, catchb ->
<b>catchb.catching</b>(ClassDesc.of(</span><span style="font-size:10.0pt;font-family:"Courier New";color:#1E9347;mso-fareast-language:EN-GB">"Phee"</span><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">), cb ->
 {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    assertEquals(<b>cb.stack()</b>.get(), List.of(<b>ReferenceType</b>));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    cb.<b>athrow</b>();<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                    assertFalse(<b>cb.stack().isPresent</b>());<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                }));<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                assertTrue(<b>cob.maxStackSize()</b>.isPresent());<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">                assertEquals((</span><span style="font-size:10.0pt;font-family:"Courier New";color:#336BDD;mso-fareast-language:EN-GB">int</span><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">)cob.maxStackSize().get(),
 4);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:black;mso-fareast-language:EN-GB">            }));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Adam<o:p></o:p></span></p>
</div>
</body>
</html>