JDK-8278429 : Escape analysis not behaving correctly with superclasses
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 18
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2021-12-08
  • Updated: 2021-12-13
  • Resolved: 2021-12-13
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 19
19Resolved
Related Reports
Duplicate :  
Description
The attached benchmark shows a hot loop in which some objects are allocated as intermediate computations, but are then thrown away, as the loop is interested in a value that should really be scalarized.

I noticed that EA behavior for this benchmark is erratic: if one of the objects being created has a superclass, then EA won't work, even though the benchmark doesn't touch any of the superclass fields. 

If the object hierarchy is flattened, EA works as expected, and the benchmark becomes considerably faster.

Benchmark                      Mode  Cnt  Score   Error  Units
PointerBenchmarkAnon.test      avgt   30  4.836 ± 0.067  ms/op
PointerBenchmarkAnon.testFlat  avgt   30  0.242 ± 0.003  ms/op
Comments
I verified that this will be fixed by Iterative EA (JDK-8276455). Closing as duplicate.
13-12-2021

I attached a minimal Test (Test.java) to reproduce the issue. C2 compiled Test::testFast simply returns the `val` arg while Test::testSlow contains allocations.
13-12-2021

ILW = Performance issue due to C2 EA failing in unexpected case, with Panama's MemorySegment API, no workaround = MMH = P3 Targeting to JDK 19 for now. If the fix is simple, we can still put it into 18.
08-12-2021

This particular use case seems to be triggered frequently when working with Panama's MemorySegment API: creating "dumb" memory segment views (e.g. slices, or unsafe segments) seem to always cause EA-related performance regression. This is a bit problematic when attempting to build efficient APIs on top of the Panama API.
08-12-2021