<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Thanks Liam!</p>
    <p>Do you have a way to measure how many for loops there are in your
      code base? (It's ok if not)</p>
    <p>Maurizio<br>
    </p>
    <div class="moz-cite-prefix">On 18/10/2024 01:07, Liam Miller-Cushon
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAL4Qsgs1G=s_Tp1iQUuHieXQEVxY-i2=eBQp1RoEd3nHuVCJtw@mail.gmail.com">
      
      <div dir="ltr">I redid the sample with the latest patch, and as
        expected got fewer IFs:
        <div><br>
        </div>
        <div>    165 METHODDEF<br>
               31 FORLOOP<br>
                9 IF<br>
                7 TRY<br>
                6 INIT<br>
                4 WHILELOOP<br>
                3 FOREACHLOOP<br>
                1 LAMBDA</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Thu, Oct 17, 2024 at
          10:18 AM Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">maurizio.cimadamore@oracle.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <p>I believe in the new patch Archie has, IF means IF (e.g.
              the variable we are snapshotting is declared in the if
              statement).</p>
            <p>But since Liam was using an earlier iteration, it is
              possible that the results here are a bit skewed.</p>
            <p>(Thanks Liam!)</p>
            <p>Maurizio<br>
            </p>
            <div>On 17/10/2024 18:14, Brian Goetz wrote:<br>
            </div>
            <blockquote type="cite"> <font size="4" face="monospace">I'm
                guessing, too, that many of those IFs really are hiding
                METHODDEF or FORLOOP?</font><br>
              <br>
              <br>
              <div>On 10/17/2024 1:12 PM, Liam Miller-Cushon wrote:<br>
              </div>
              <blockquote type="cite">
                <div dir="ltr">I analyzed a sample of code using the
                  changes at 08c8b1f3c64. I can re-analyze with the
                  latest version, but the initial results were:
                  <div><br>
                  </div>
                  <div>    120 METHODDEF<br>
                         74 IF<br>
                         44 FORLOOP<br>
                         13 WHILELOOP<br>
                         10 TRY<br>
                          5 FOREACHLOOP<br>
                          2 DOLOOP<br>
                          1 LAMBDA</div>
                  <div><br>
                  </div>
                </div>
                <br>
                <div class="gmail_quote">
                  <div dir="ltr" class="gmail_attr">On Thu, Oct 17, 2024
                    at 8:08 AM Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">maurizio.cimadamore@oracle.com</a>>
                    wrote:<br>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                    <div>
                      <p><br>
                      </p>
                      <div>On 17/10/2024 16:03, Archie Cobbs wrote:<br>
                      </div>
                      <blockquote type="cite">
                        <div dir="ltr">
                          <div dir="ltr">On Thu, Oct 17, 2024 at 5:34 AM
                            Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">maurizio.cimadamore@oracle.com</a>>
                            wrote:</div>
                          <div class="gmail_quote">
                            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                              <div>
                                <div>Funny to see the FOREACHLOOP
                                  popping out. This code is (at least)
                                  from 17 years ago (!!) and predates
                                  any form of effectively final analysis
                                  - back then even for-each required to
                                  hoist the variable in a separate <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">final</code>
                                  one :-)</div>
                              </div>
                            </blockquote>
                            <div><br>
                            </div>
                            <div>I was wondering about that as well. I
                              didn't realize that there was a point
                              where foreach() already existed and this
                              effectively final tweak was added. I don't
                              see a relevant JEP, did it predate the JEP
                              process?<br>
                            </div>
                          </div>
                        </div>
                      </blockquote>
                      Effectively final support was added as part of
                      Java 8 and Project Lambda. Java 7 also had some
                      bits of effective finality here and there, but
                      Java 8 is what sealed the deal. Back then we did
                      not have the JEP process.<br>
                      <blockquote type="cite">
                        <div dir="ltr">
                          <div class="gmail_quote">
                            <div> <br>
                            </div>
                            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                              <div>
                                <div>I realize, the important info is
                                  not where the dummy variable is
                                  declared. It's the declaration of the
                                  variable it points to in the
                                  initializer that matters!</div>
                              </div>
                            </blockquote>
                            <div><br>
                            </div>
                            <div>D'oh, yes of course... easy to fix
                              though.</div>
                          </div>
                        </div>
                      </blockquote>
                      Thanks<br>
                      <blockquote type="cite">
                        <div dir="ltr">
                          <div class="gmail_quote">
                            <div><br>
                            </div>
                            <div>Here are the new stats - these look
                              more like what one might expect:</div>
                            <div><br>
                            </div>
                            <div><span style="font-family:monospace"> 
                                87 METHODDEF<br>
                                  11 FORLOOP<br>
                                   3 TRY<br>
                                   3 IF<br>
                                   3 FOREACHLOOP<br>
                                   3 DOLOOP<br>
                                   2 WHILELOOP<br>
                                   1 CASE</span></div>
                            <div><br>
                            </div>
                            <div>Now there are 3 <span style="font-family:monospace">FOREACHLOOP</span>'s
                              :)<br>
                            </div>
                          </div>
                        </div>
                      </blockquote>
                      <p>Yowza! For each gained more than the regular
                        loop :-)</p>
                      <p>Maurizio<br>
                      </p>
                      <blockquote type="cite">
                        <div dir="ltr">
                          <div class="gmail_quote">
                            <div><br>
                            </div>
                            <div>-Archie<br>
                            </div>
                          </div>
                          <br>
                          <span class="gmail_signature_prefix">-- </span><br>
                          <div dir="ltr" class="gmail_signature">Archie
                            L. Cobbs<br>
                          </div>
                        </div>
                      </blockquote>
                    </div>
                  </blockquote>
                </div>
              </blockquote>
              <br>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>