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

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

    Details

    • Subcomponent:
    • Resolved In Build:
      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

          Issue Links

            Activity

            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/df802f98b828
            User: dlong
            Date: 2015-07-25 04:54:08 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/df802f98b828 User: dlong Date: 2015-07-25 04:54:08 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/df802f98b828
            User: lana
            Date: 2015-08-11 20:21:41 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/df802f98b828 User: lana Date: 2015-08-11 20:21:41 +0000

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: