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

Duplicate code in C2 optimizer

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Won't Fix
    • P4
    • None
    • 7, 9, 10
    • hotspot
    • generic
    • generic

    Description

      From the beginning, the C2 ideal-graph optimizer has distinguished Ideal from Identity transformations on nodes, with differing (and subtle) invariants governing their use. The code for Ideal and Identity is often very similar, up to the point where an optimization result is returned to the IGVN driver. The code embodies this similarity with parallel versions (substantially) the same logic for Ideal and Identity, notably for class PhiNode.

      Over time, this has given rise to a number of occasions where the two versions of the same computation diverge from each other, with the usual sorts of subtle failures.

      The solution is straightforward: Refactor the affected node types so that Ideal and Identity are combined into one call, Improve. For those few cases where the caller cares about the difference (including possible future optimizations), there is a mode argument to Improve which selects among the differing optimization constraints (such as Identity's rule of never creating a new node). Most per-node methods can check this mode bit in an extra line of code, which is a great improvement, since we are merging two methods into one.

      At the same time, there are three versions of the optimizer driver Phase::transform, with essentially irrelevant differences. (Sometimes the differences are only in comments.) Recent engineering has created a few new differences, but they appear to be spurious. These versions must also be refactored back together, to prevent future bit-rot.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jrose John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: