Type speculation should be used to optimize explicit null checks

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 9
    • Affects Version/s: hs25
    • Component/s: hotspot
    • b08

      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.

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

              Created:
              Updated:
              Resolved: