<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>I can reproduce this locally:<br>
    </p>
    <pre><font face="monospace">Benchmark                               Mode  Cnt  Score   Error  Units
ReproducerBenchmarks.control            avgt    5  1.280 ± 0.015  ns/op
ReproducerBenchmarks.gwt2_methodhandle  avgt    5  1.690 ± 0.008  ns/op
ReproducerBenchmarks.gwt_methodhandle   avgt    5  1.305 ± 0.038  ns/op</font>
</pre>
    <p>Disabling tiered compilation 'fixes' the performance of gwt2:<font face="monospace"><br>
      </font></p>
    <pre><font face="monospace">Benchmark                               Mode  Cnt  Score   Error  Units
ReproducerBenchmarks.control            avgt    5  1.299 ± 0.016  ns/op
ReproducerBenchmarks.gwt2_methodhandle  avgt    5  1.312 ± 0.030  ns/op
ReproducerBenchmarks.gwt_methodhandle   avgt    5  1.303 ± 0.034  ns/op</font></pre>
    <p>In both cases the assembly looks identical though. So, this may
      just be up to a different code cache layout (or something like
      that).<br>
    </p>
    <p>Jorn<br>
    </p>
    <div class="moz-cite-prefix">On 25/04/2024 00:28, Maurizio
      Cimadamore wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:b21217d6-0d0c-4cbb-b807-b589ce8fe067@oracle.com">
      
      <p>Cool benchmark/test case!</p>
      <p>I don't know off-hand where the difference could be coming from
        - but just curious: did you try accessing in a loop (e.g. to see
        if checks are hoisted as expected) ?</p>
      <p>I seem to recall that the lambda forms for guards-with-test are
        rather complex, as they need to profile the various branches. I
        wonder if some "leftover" from the profiling code stays there
        and pollutes the benchmark?</p>
      <p>Maurizio<br>
      </p>
      <div class="moz-cite-prefix">On 24/04/2024 07:37, Remi Forax
        wrote:<br>
      </div>
      <blockquote type="cite" cite="mid:144453100.12179950.1713940662054.JavaMail.zimbra@univ-eiffel.fr">
        <pre>I get

Benchmark                               Mode  Cnt  Score   Error  Units
ReproducerBenchmarks.control            avgt    5  1.250 ± 0.024  ns/op
ReproducerBenchmarks.gwt2_methodhandle  avgt    5  1.852 ± 0.024  ns/op

and I don't understand why there is a difference in performance because 
for c2, the strings "x" and "y" are constant so the corresponding 
VarHandles should be constant thus optimized the same way.</pre>
      </blockquote>
    </blockquote>
  </body>
</html>