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

C1 should fold arraylength for constant/trusted arrays

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b110

      Description

      The golden example is String.length() over static final Strings:

          static final String TEST_STRING = "Foo";

          @Benchmark
          public int string_length() {
              return TEST_STRING.length();
          }

      C2 folds the underlying (byte[].length >> coder) fine, because it both trusts the final String.value/coder, and folds arraylength.
      C1 trusts String.value/coder after JDK-8149813, but does not fold arraylength yet.

      Sample benchmark + generated code:
       http://cr.openjdk.java.net/~shade/8150102/FoldArrayLength.java

      Proof-of-concept webrev:
       http://cr.openjdk.java.net/~shade/8150102/webrev.00

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: