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

C2: Optimize MemorySegment shape in int loop

XMLWordPrintable

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

      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.

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

              Created:
              Updated:
              Resolved: