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

Type speculation should be used to optimize explicit null checks

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • hs25
    • hotspot
    • b08

    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.

      Attachments

        Issue Links

          Activity

            People

              roland Roland Westrelin
              roland Roland Westrelin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: