<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <font size="4"><font face="monospace">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.  <br>
      </font></font><br>
    <div class="moz-cite-prefix">On 8/17/2022 12:02 PM, Adam Sotona
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CY4PR1001MB21503530B4EFCB740A794E558C6A9@CY4PR1001MB2150.namprd10.prod.outlook.com">
      
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@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;}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;}div.WordSection1
        {page:WordSection1;}ol
        {margin-bottom:0cm;}ul
        {margin-bottom:0cm;}</style>
      <div class="WordSection1">
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">Yes,
            user can send the stack maps to the builder anytime and it
            will disable generation for the actual method.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">However
            user has to explicitly construct the attribute:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">cob.with(StackMapTableAttribute.of(List.of(StackMapFrameInfo.of(myLabel,
            locals, stack), …));<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US">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.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt" lang="EN-US"><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
              <a class="moz-txt-link-rfc2396E" 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 class="moz-txt-link-rfc2396E" href="mailto:adam.sotona@oracle.com"><adam.sotona@oracle.com></a>,
              <a class="moz-txt-link-abbreviated" href="mailto:classfile-api-dev@openjdk.org">classfile-api-dev@openjdk.org</a>
              <a class="moz-txt-link-rfc2396E" 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><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"">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><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
            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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">Hi,</span><o:p></o:p></p>
          <p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">Pull request for
              review is here:
              <a href="https://github.com/openjdk/jdk-sandbox/pull/32" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/jdk-sandbox/pull/32</a></span><o:p></o:p></p>
          <p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt" lang="EN-US">And it includes
              following changes:</span><o:p></o:p></p>
          <p class="MsoListParagraph" style="margin-left:72.0pt;text-indent:-18.0pt;mso-list:l0
            level1 lfo3">
            <!--[if !supportLists]--><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">     
              </span></span><!--[endif]--><span style="font-size:11.0pt" lang="EN-US">New boolean
              Classfile.Option::processStackMaps with default to false
              has been added</span><o:p></o:p></p>
          <p class="MsoListParagraph" style="margin-left:72.0pt;text-indent:-18.0pt;mso-list:l0
            level1 lfo3">
            <!--[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 style="font-size:11.0pt" lang="EN-US"> 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:72.0pt;text-indent:-18.0pt;mso-list:l0
            level1 lfo3">
            <!--[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 style="font-size:11.0pt" lang="EN-US">, 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:72.0pt;text-indent:-18.0pt;mso-list:l0
            level1 lfo3">
            <!--[if !supportLists]--><span style="mso-list:Ignore">4.<span style="font:7.0pt "Times New Roman"">     
              </span></span><!--[endif]--><span style="font-size:11.0pt" lang="EN-US">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:72.0pt;text-indent:-18.0pt;mso-list:l0
            level1 lfo3">
            <!--[if !supportLists]--><span style="mso-list:Ignore">5.<span style="font:7.0pt "Times New Roman"">     
              </span></span><!--[endif]--><span style="font-size:11.0pt" lang="EN-US">UnboundStackMapTableAttribute with proper
              serialization has been implemented</span><o:p></o:p></p>
          <p class="MsoListParagraph" style="margin-left:72.0pt;text-indent:-18.0pt;mso-list:l0
            level1 lfo3">
            <!--[if !supportLists]--><span style="mso-list:Ignore">6.<span style="font:7.0pt "Times New Roman"">     
              </span></span><!--[endif]--><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US">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:36.0pt"><span style="font-size:11.0pt" lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt" lang="EN-US">Thanks for your
              comments,</span><o:p></o:p></p>
          <p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt" lang="EN-US">Adam</span><o:p></o:p></p>
          <p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt" lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt" lang="EN-US"> </span><o:p></o:p></p>
          <p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt" lang="EN-US"> </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>
    </blockquote>
    <br>
  </body>
</html>