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

C1 Class.cast optimization breaks when Class is loaded from static final

    XMLWordPrintable

Details

    • b77

    Backports

      Description

        This is observed in VarHandles work for JDK-8130923.

        The reason is that C1 canonicalizer seems to assume a particular constant shape (InstanceConstant), while the Class instances coming through @Stable/static-final seem to be ObjectConstants. Accepting ObjectConstants as well fixes it:
          http://cr.openjdk.java.net/~shade/8131782/webrev.01/

        Simple benchmark articulates it clearly:
          http://cr.openjdk.java.net/~shade/8131782/ClassCastConstants.java

        (Runnable JAR: http://cr.openjdk.java.net/~shade/8131782/benchmarks.jar)

        Baseline result calls into Runtime::isInstance in "static final" case, experiencing the 2x hit:
          http://cr.openjdk.java.net/~shade/8131782/baseline.perfasm

        Patched VM behaves perfectly well in both cases:
          http://cr.openjdk.java.net/~shade/8131782/patched.perfasm

        Attachments

          Issue Links

            Activity

              People

                shade Aleksey Shipilev
                shade Aleksey Shipilev
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: