C2: Fold identity hash code if object is constant

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 26
    • Component/s: hotspot
    • In Review

      Currently, in the intrinsic for Object::hashCode or System::identityHashCode, we perform a read of the mark word/object header. This load is not constant and cannot be eliminated. As a result, we cannot evaluate the identity hash code of a constant object as a constant value.

      Evaluating the hash of a constant as a constant would be helpful for certain workloads: for example, if a call uses class literals to look up in a map, and the map supports constant folding, if the class hash becomes a constant, the whole map lookup can get eliminated.

      We can easily add a shortcut to constant-fold a hash value for an object to provide such benefits.

            Assignee:
            Chen Liang
            Reporter:
            Chen Liang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: