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

C2: Optimize MemorySegment shape in int loop

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 20
    • 19, 20
    • hotspot
    • b02

    Description

      The loop body to optimize is:
              for (int i = 0; i < size; i++) {
                  long j = i * UNSAFE.ARRAY_INT_INDEX_SCALE;

                  j = Objects.checkIndex(j, size * 4);

                  if (((base + j) & 3) != 0) {
                      throw new RuntimeException();
                  }

                  v += UNSAFE.getInt(base + j);
              }

      loop iv is first scaled, result is then casted to long, range checked and finally address of memory location is computed.

      Attachments

        Issue Links

          Activity

            People

              roland Roland Westrelin
              roland Roland Westrelin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: