Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8055340

EliminateAutoBox seems flaky when dealing with "effectively local" variables

XMLWordPrintable

      (The synopsis is probably bad, please adjust if you think up something better)

      This was found in much larger benchmark, and it affects JMH at 8u20+.

      In short, after EliminateAutoBox was enabled in 8u20, users figure out the additional oddities in the performance scores, which is attributable to EliminateAutoBox stopping to work in surprising cases. E.g. these two methods will have drastically different performance:

          @Benchmark
          @CompilerControl(CompilerControl.Mode.DONT_INLINE)
          public int basicHeap() {
              int acc = 0;
              for (int i = 0; i < count; i++) {
                  acc = acc ^ Integer.valueOf(data).hashCode();
              }
              return acc;
          }

          @Benchmark
          @CompilerControl(CompilerControl.Mode.DONT_INLINE)
          public int basicLocal() {
              int d = data; // cache in local
              int acc = 0;
              for (int i = 0; i < count; i++) {
                  acc = acc ^ Integer.valueOf(d).hashCode();
              }
              return acc;
          }

      ...which in the end suggests EliminateAutoBox failing in basicHeap case, and working fine in basicLocal case. Since our instance of JIRA is monospace-hostile, the rest of the analysis, as well as more benchmarks is here:
        http://cr.openjdk.java.net/~shade/8055340/AutoBoxingFailsBenchmark.java

      The runnable benchmark JAR is:
        http://cr.openjdk.java.net/~shade/8055340/benchmarks.jar

            vlivanov Vladimir Ivanov
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: