JDK-8031755 : Type speculation should be used to optimize explicit null checks
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs25
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-01-15
  • Updated: 2016-07-07
  • Resolved: 2014-03-31
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 9
9 b08Fixed
Related Reports
Relates :  
Relates :  
Description
To optimize this:

m(Object o) {
  if (o == null) {
  }  else {
  }
}

C2 uses branch profiling. If the object is never null, profiling tells it that one branch is always taken and it's not compiled. If m() is called from many places branch profiling can be polluted and C2 may not be able to optimize one of the branch out.

Several type profiling points also record whether they see a null object or not so in the example above some method that calls m() may have profile data that indicate whether o is null or not and that can be used to overcome branch profile pollution in m(). To achieve this, we need type speculation to take advantage of the part of the profile data that tells whether a null was seen.
Comments
no regression test: this change affects code generation and is hard to observe from a java application
31-03-2014