JDK-8055340 : EliminateAutoBox seems flaky when dealing with "effectively local" variables
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8u20,9,10,11,12
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2014-08-18
  • Updated: 2020-04-21
  • Resolved: 2020-04-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 13
13Resolved
Related Reports
Duplicate :  
Description
(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
Comments
JDK-8217919 made -XX:+AggressiveUnboxing turned ON by default. Closing as Fixed.
05-02-2019

Looking at loopedInlineable IR, autobox elimination is blocked by a range check on j.l.Integer cache. Doesn't happen with -XX:+AggressiveUnboxing (which delays inlining of boxing/unboxing methods thus avoiding problems caused by complex IR shapes).
07-09-2016

ILW=Flaky performance, but no regression; fullt deterministic common use cases; none; LHH=P4
27-08-2014